blob: 723cdae67d8bd0c66ba4848bdf4a97a000b4326d [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ignite.scalar.examples
import org.apache.ignite.scalar.scalar
import org.apache.ignite.scalar.scalar._
/**
* Shows the world's shortest MapReduce application that calculates non-space
* length of the input string. This example works equally on one computer or
* on thousands requiring no special configuration or deployment.
* <p/>
* Remote nodes should always be started with special configuration file which
* enables P2P class loading: `'ignite.{sh|bat} examples/config/example-ignite.xml'`.
* <p/>
* Alternatively you can run `ExampleNodeStartup` in another JVM which will
* start node with `examples/config/example-ignite.xml` configuration.
*/
object ScalarWorldShortestMapReduce extends App {
scalar("examples/config/example-ignite.xml") {
val input = "World shortest mapreduce application"
println("Non-space characters count: " +
ignite$.reduce$[Int, Int](for (w <- input.split(" ")) yield () => w.length, _.sum, null)
)
}
}