use of org.apache.rya.api.resolver.triple.TripleRowResolver in project incubator-rya by apache.
the class JoinSelectMapperTest method testOutput.
@Test
public void testOutput() throws TripleRowResolverException, IOException {
RyaStatement rya = new RyaStatement(new RyaURI("urn:gem:etype#1234"), new RyaURI("urn:gem#pred"), new RyaType("mydata1"));
Text s = new Text(rya.getSubject().getData());
Text p = new Text(rya.getPredicate().getData());
Text o = new Text(rya.getObject().getData());
Text sp = new Text(rya.getSubject().getData() + DELIM + rya.getPredicate().getData());
Text so = new Text(rya.getSubject().getData() + DELIM + rya.getObject().getData());
Text po = new Text(rya.getPredicate().getData() + DELIM + rya.getObject().getData());
Text ps = new Text(rya.getPredicate().getData() + DELIM + rya.getSubject().getData());
Text op = new Text(rya.getObject().getData() + DELIM + rya.getPredicate().getData());
Text os = new Text(rya.getObject().getData() + DELIM + rya.getSubject().getData());
TripleEntry t1 = new TripleEntry(s, p, new Text("subject"), new Text("predicate"), new Text("object"));
TripleEntry t2 = new TripleEntry(p, o, new Text("predicate"), new Text("object"), new Text("subject"));
TripleEntry t3 = new TripleEntry(o, s, new Text("object"), new Text("subject"), new Text("predicate"));
TripleEntry t4 = new TripleEntry(o, new Text(""), new Text("object"), new Text(""), new Text("subjectpredicate"));
TripleEntry t5 = new TripleEntry(p, new Text(""), new Text("predicate"), new Text(""), new Text("objectsubject"));
TripleEntry t6 = new TripleEntry(s, new Text(""), new Text("subject"), new Text(""), new Text("predicateobject"));
TripleEntry t7 = new TripleEntry(s, new Text(""), new Text("subject"), new Text(""), new Text("objectpredicate"));
TripleEntry t8 = new TripleEntry(p, new Text(""), new Text("predicate"), new Text(""), new Text("subjectobject"));
TripleEntry t9 = new TripleEntry(o, new Text(""), new Text("object"), new Text(""), new Text("predicatesubject"));
TripleRowResolver trr = new WholeRowTripleResolver();
Map<TABLE_LAYOUT, TripleRow> map = trr.serialize(rya);
System.out.println(map);
TripleRow tr = map.get(TABLE_LAYOUT.SPO);
System.out.println("Triple row is" + tr);
System.out.println("ColumnV is " + tr.getTimestamp());
byte[] b = new byte[0];
Key key = new Key(tr.getRow(), tr.getColumnFamily(), tr.getColumnQualifier(), b, 1);
Value val = new Value(b);
new MapDriver<Key, Value, CompositeType, TripleCard>().withMapper(new JoinSelectSpoTableOutput.JoinSelectMapper()).withInput(key, val).withOutput(new CompositeType(o, new IntWritable(2)), new TripleCard(t1)).withOutput(new CompositeType(s, new IntWritable(2)), new TripleCard(t2)).withOutput(new CompositeType(p, new IntWritable(2)), new TripleCard(t3)).withOutput(new CompositeType(po, new IntWritable(2)), new TripleCard(t6)).withOutput(new CompositeType(so, new IntWritable(2)), new TripleCard(t5)).withOutput(new CompositeType(sp, new IntWritable(2)), new TripleCard(t4)).withOutput(new CompositeType(op, new IntWritable(2)), new TripleCard(t7)).withOutput(new CompositeType(os, new IntWritable(2)), new TripleCard(t8)).withOutput(new CompositeType(ps, new IntWritable(2)), new TripleCard(t9)).runTest();
}
use of org.apache.rya.api.resolver.triple.TripleRowResolver in project incubator-rya by apache.
the class DuplicateEliminationTest method testTableMapperOutput.
@Test
public void testTableMapperOutput() throws Exception {
RyaStatement rya = TestUtils.ryaStatement("x", "subOrganizationOf", "y");
TripleRowResolver trr = new WholeRowTripleResolver();
Map<TABLE_LAYOUT, TripleRow> map = trr.serialize(rya);
TripleRow tr = map.get(TABLE_LAYOUT.SPO);
byte[] b = new byte[0];
Key key = new Key(tr.getRow(), tr.getColumnFamily(), tr.getColumnQualifier(), b, 1);
Value val = new Value(b);
new MapDriver<Key, Value, Fact, Derivation>().withMapper(new DuplicateElimination.DuplicateTableMapper()).withInput(key, val).withOutput(X_SUB_Y, X_SUB_Y.getDerivation()).runTest();
}
use of org.apache.rya.api.resolver.triple.TripleRowResolver in project incubator-rya by apache.
the class ForwardChainTest method testTableMapperOutput.
@Test
public void testTableMapperOutput() throws Exception {
RyaStatement rya = TestUtils.ryaStatement("x", "subOrganizationOf", "y");
TripleRowResolver trr = new WholeRowTripleResolver();
Map<TABLE_LAYOUT, TripleRow> map = trr.serialize(rya);
TripleRow tr = map.get(TABLE_LAYOUT.SPO);
byte[] b = new byte[0];
Key key = new Key(tr.getRow(), tr.getColumnFamily(), tr.getColumnQualifier(), b, 1);
Value val = new Value(b);
ResourceWritable rw1 = new ResourceWritable();
ResourceWritable rw2 = new ResourceWritable();
rw1.set(TestUtils.uri("x"));
rw2.set(TestUtils.uri("y"));
new MapDriver<Key, Value, ResourceWritable, Fact>().withMapper(new ForwardChain.TableMapper(schema)).withInput(key, val).withOutput(rw1, X_SUB_Y).withOutput(rw2, X_SUB_Y).runTest();
}
Aggregations