Search in sources :

Example 26 with NodeWritable

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);
}
Also used : NodeWritable(org.apache.jena.hadoop.rdf.types.NodeWritable) CharacteristicSetWritable(org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable) LongWritable(org.apache.hadoop.io.LongWritable) NullWritable(org.apache.hadoop.io.NullWritable) Test(org.junit.Test)

Example 27 with NodeWritable

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()));
    }
}
Also used : NodeWritable(org.apache.jena.hadoop.rdf.types.NodeWritable) HashMap(java.util.HashMap) LongWritable(org.apache.hadoop.io.LongWritable)

Example 28 with NodeWritable

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);
        }
    }
}
Also used : NodeWritable(org.apache.jena.hadoop.rdf.types.NodeWritable) LongWritable(org.apache.hadoop.io.LongWritable)

Example 29 with NodeWritable

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);
        }
    }
}
Also used : NodeWritable(org.apache.jena.hadoop.rdf.types.NodeWritable) LongWritable(org.apache.hadoop.io.LongWritable)

Aggregations

NodeWritable (org.apache.jena.hadoop.rdf.types.NodeWritable)29 Test (org.junit.Test)19 Node (org.apache.jena.graph.Node)16 LongWritable (org.apache.hadoop.io.LongWritable)10 NullWritable (org.apache.hadoop.io.NullWritable)6 CharacteristicSetWritable (org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable)5 Ignore (org.junit.Ignore)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 Triple (org.apache.jena.graph.Triple)1 CharacteristicWritable (org.apache.jena.hadoop.rdf.types.CharacteristicWritable)1 NodeTupleWritable (org.apache.jena.hadoop.rdf.types.NodeTupleWritable)1 QuadWritable (org.apache.jena.hadoop.rdf.types.QuadWritable)1 TripleWritable (org.apache.jena.hadoop.rdf.types.TripleWritable)1 Quad (org.apache.jena.sparql.core.Quad)1