Class HelloWorld
- java.lang.Object
-
- com.marklogic.mapreduce.examples.HelloWorld
-
public class HelloWorld extends Object
Read the first word from each input document, then produce a single output document containing the words, sorted, and concatenated into a single string. Only XML documents with text nodes contribute to the final result.This sample uses the marklogic-hello-world.xml config file.
The config file name is hard-coded into the sample for simplicity, so no additional command line options are required by the sample.
The mapper creates key-value pairs where the key is always the same constant and the value is the first word from the document. The reducer sorts the words, concatenates them together, and writes them to an output document. Since all key-value pairs produced by the mapper have the same key, there's only one input pair to the reducer, producing a a single output document.
For example, given 2 input documents whose first words are "hello" and "world", the mapper produces: (1, "hello") and (1, "world"). The reducer receives (1, ("hello", "world")) as input and inserts HelloWorld.txt in the database, containing "hello world".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHelloWorld.MyMapperstatic classHelloWorld.MyReducer
-
Constructor Summary
Constructors Constructor Description HelloWorld()
-