Search in sources :

Example 6 with TripleCard

use of org.apache.rya.joinselect.mr.utils.TripleCard in project incubator-rya by apache.

the class JoinSelectProspectOutputTest method testOutput.

@Test
public void testOutput() throws InterruptedException, IOException {
    String s = "urn:gem:etype#1234";
    String p = "urn:gem#pred";
    String ts = "798497748386999999";
    Text t1 = new Text(TripleValueType.subject.name() + DELIM + s + DELIM + 1);
    Text t2 = new Text(TripleValueType.predicate.name() + DELIM + p + DELIM + 2);
    Text t3 = new Text(TripleValueType.subjectpredicate.name() + DELIM + s + DELIM + p + DELIM + ts);
    byte[] b = new byte[0];
    byte[] c = "25".getBytes();
    byte[] d = "47".getBytes();
    byte[] e = "15".getBytes();
    Key key1 = new Key(t1.getBytes(), b, b, b, 1);
    Key key2 = new Key(t2.getBytes(), b, b, b, 1);
    Key key3 = new Key(t3.getBytes(), b, b, b, 1);
    Value val1 = new Value(c);
    Value val2 = new Value(d);
    Value val3 = new Value(e);
    // System.out.println("Keys are " + key1 + " and " + key2);
    new MapDriver<Key, Value, CompositeType, TripleCard>().withMapper(new JoinSelectProspectOutput.CardinalityMapper()).withInput(key1, val1).withInput(key2, val2).withInput(key3, val3).withOutput(new CompositeType(s, 1), new TripleCard(new CardinalityType(25, "subject", 1))).withOutput(new CompositeType(p, 1), new TripleCard(new CardinalityType(47, "predicate", 2))).withOutput(new CompositeType(s + DELIM + p, 1), new TripleCard(new CardinalityType(15, "subjectpredicate", Long.parseLong(ts)))).runTest();
}
Also used : MapDriver(org.apache.hadoop.mrunit.mapreduce.MapDriver) CardinalityType(org.apache.rya.joinselect.mr.utils.CardinalityType) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) TripleCard(org.apache.rya.joinselect.mr.utils.TripleCard) Key(org.apache.accumulo.core.data.Key) CompositeType(org.apache.rya.joinselect.mr.utils.CompositeType) Test(org.junit.Test)

Aggregations

CompositeType (org.apache.rya.joinselect.mr.utils.CompositeType)6 TripleCard (org.apache.rya.joinselect.mr.utils.TripleCard)6 Test (org.junit.Test)6 CardinalityType (org.apache.rya.joinselect.mr.utils.CardinalityType)5 TripleEntry (org.apache.rya.joinselect.mr.utils.TripleEntry)4 ArrayList (java.util.ArrayList)3 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 Text (org.apache.hadoop.io.Text)3 MapDriver (org.apache.hadoop.mrunit.mapreduce.MapDriver)3 CardList (org.apache.rya.joinselect.mr.utils.CardList)3 JoinSelectAggregate (org.apache.rya.joinselect.mr.JoinSelectAggregate)2 IntWritable (org.apache.hadoop.io.IntWritable)1 ReduceDriver (org.apache.hadoop.mrunit.mapreduce.ReduceDriver)1 TABLE_LAYOUT (org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT)1 RyaStatement (org.apache.rya.api.domain.RyaStatement)1 RyaType (org.apache.rya.api.domain.RyaType)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 TripleRow (org.apache.rya.api.resolver.triple.TripleRow)1 TripleRowResolver (org.apache.rya.api.resolver.triple.TripleRowResolver)1