use of org.apache.jena.hadoop.rdf.types.NodeWritable in project jena by apache.
the class AbstractCharacteristicSetGeneratingReducerTests method characteristic_set_generating_reducer_05.
/**
* Test basic characteristic set computation
*
* @throws IOException
*/
@Test
public void characteristic_set_generating_reducer_05() throws IOException {
MapReduceDriver<LongWritable, T, NodeWritable, T, CharacteristicSetWritable, NullWritable> driver = this.getMapReduceDriver();
T tuple = this.createTuple(1, "http://predicate");
driver.addInput(new LongWritable(1), tuple);
tuple = this.createTuple(1, "http://other");
driver.addInput(new LongWritable(2), tuple);
tuple = this.createTuple(1, "http://third");
driver.addInput(new LongWritable(3), tuple);
// Single entry sets
this.createSet(driver, 1, "http://predicate");
this.createSet(driver, 1, "http://other");
this.createSet(driver, 1, "http://third");
// Two entry sets
this.createSet(driver, 1, "http://predicate", "http://other");
this.createSet(driver, 1, "http://predicate", "http://third");
this.createSet(driver, 1, "http://other", "http://third");
// Three entry sets
this.createSet(driver, 1, "http://predicate", "http://other", "http://third");
driver.runTest(false);
}
use of org.apache.jena.hadoop.rdf.types.NodeWritable in project jena by apache.
the class AbstractNodeTupleNodeCountReducedTests method generateData.
/**
* Generates tuples for the tests
*
* @param driver
* Driver
* @param num
* Number of tuples to generate
*/
protected void generateData(MapReduceDriver<LongWritable, T, NodeWritable, LongWritable, NodeWritable, LongWritable> driver, int num) {
Map<NodeWritable, Long> counts = new HashMap<NodeWritable, Long>();
for (int i = 0; i < num; i++) {
LongWritable key = new LongWritable(i);
T value = this.createValue(i);
NodeWritable[] nodes = this.getNodes(value);
driver.addInput(key, value);
for (NodeWritable n : nodes) {
if (counts.containsKey(n)) {
counts.put(n, counts.get(n) + 1);
} else {
counts.put(n, 1l);
}
}
}
for (Entry<NodeWritable, Long> kvp : counts.entrySet()) {
driver.addOutput(kvp.getKey(), new LongWritable(kvp.getValue()));
}
}
use of org.apache.jena.hadoop.rdf.types.NodeWritable in project jena by apache.
the class AbstractNodeTupleNodeCountTests method generateData.
/**
* Generates tuples for the tests
*
* @param driver
* Driver
* @param num
* Number of tuples to generate
*/
protected void generateData(MapDriver<LongWritable, T, NodeWritable, LongWritable> driver, int num) {
LongWritable expectedCount = new LongWritable(1);
for (int i = 0; i < num; i++) {
LongWritable key = new LongWritable(i);
T value = this.createValue(i);
NodeWritable[] nodes = this.getNodes(value);
driver.addInput(key, value);
for (NodeWritable n : nodes) {
driver.addOutput(n, expectedCount);
}
}
}
use of org.apache.jena.hadoop.rdf.types.NodeWritable in project jena by apache.
the class AbstractNodeTupleSplitWithNodesTests method generateData.
/**
* Generates data for use in tests
*
* @param driver
* Driver
* @param num
* Number of tuples to generate
*/
protected void generateData(MapDriver<LongWritable, T, T, NodeWritable> driver, int num) {
for (int i = 0; i < num; i++) {
LongWritable key = new LongWritable(i);
T value = this.createValue(i);
NodeWritable[] nodes = this.getNodes(value);
driver.addInput(key, value);
for (NodeWritable n : nodes) {
driver.addOutput(value, n);
}
}
}
Aggregations