use of org.apache.rya.joinselect.mr.utils.CardList in project incubator-rya by apache.
the class CardinalityIdentityReducerTest method testCIReducerOneConstant.
@Test
public void testCIReducerOneConstant() throws InterruptedException, IOException {
TripleEntry te = new TripleEntry(new Text("urn:gem:etype#1234"), new Text(""), new Text("subject"), new Text(""), new Text("object"));
CardList cL1 = new CardList(1, 2, 3, 0, 0, 0);
CardList cL2 = new CardList(4, 5, 6, 0, 0, 0);
CardList cl = new CardList(5, 7, 9, 0, 0, 0);
List<CardList> list = new ArrayList<CardList>();
list.add(cL1);
list.add(cL2);
Text row = new Text(te.getFirstPos().toString() + DELIM + te.getFirst().toString());
Mutation m1 = new Mutation(row);
m1.put(new Text(te.getKeyPos().toString() + "subject"), new Text(cl.getcardS().toString()), new Value(new byte[0]));
Mutation m2 = new Mutation(row);
m2.put(new Text(te.getKeyPos().toString() + "predicate"), new Text(cl.getcardP().toString()), new Value(new byte[0]));
Mutation m3 = new Mutation(row);
m3.put(new Text(te.getKeyPos().toString() + "object"), new Text(cl.getcardO().toString()), new Value(new byte[0]));
Text table = new Text("");
new ReduceDriver<TripleEntry, CardList, Text, Mutation>().withReducer(new JoinSelectStatisticsSum.CardinalityIdentityReducer()).withInput(te, list).withOutput(table, m1).withOutput(table, m2).withOutput(table, m3).runTest();
}
use of org.apache.rya.joinselect.mr.utils.CardList in project incubator-rya by apache.
the class CardinalityIdentityReducerTest method testJoinTwoVarsReverseOrder.
@Test
public void testJoinTwoVarsReverseOrder() throws InterruptedException, IOException {
TripleEntry te = new TripleEntry(new Text("urn:gem:etype#1234"), new Text(""), new Text("subject"), new Text(""), new Text("objectpredicate"));
CardList cL1 = new CardList(0, 0, 0, 1, 2, 3);
CardList cL2 = new CardList(0, 0, 0, 4, 5, 6);
CardList cl = new CardList(0, 0, 0, 5, 7, 9);
List<CardList> list = new ArrayList<CardList>();
list.add(cL1);
list.add(cL2);
Text row = new Text(te.getFirstPos().toString() + DELIM + te.getFirst().toString());
Mutation m1 = new Mutation(row);
m1.put(new Text("predicateobject" + "predicatesubject"), new Text(cl.getcardSP().toString()), new Value(new byte[0]));
Mutation m2 = new Mutation(row);
m2.put(new Text("predicateobject" + "objectpredicate"), new Text(cl.getcardPO().toString()), new Value(new byte[0]));
Mutation m3 = new Mutation(row);
m3.put(new Text("predicateobject" + "subjectobject"), new Text(cl.getcardSO().toString()), new Value(new byte[0]));
Text table = new Text("");
new ReduceDriver<TripleEntry, CardList, Text, Mutation>().withReducer(new JoinSelectStatisticsSum.CardinalityIdentityReducer()).withInput(te, list).withOutput(table, m1).withOutput(table, m2).withOutput(table, m3).runTest();
}
use of org.apache.rya.joinselect.mr.utils.CardList in project incubator-rya by apache.
the class CardinalityIdentityReducerTest method testCIReducerTwoConstant.
@Test
public void testCIReducerTwoConstant() throws InterruptedException, IOException {
TripleEntry te = new TripleEntry(new Text("urn:gem:etype#1234"), new Text("urn:gem#pred"), new Text("subject"), new Text("predicate"), new Text("object"));
CardList cL1 = new CardList(1, 2, 3, 0, 0, 0);
CardList cL2 = new CardList(4, 5, 6, 0, 0, 0);
CardList cl = new CardList(5, 7, 9, 0, 0, 0);
List<CardList> list = new ArrayList<CardList>();
list.add(cL1);
list.add(cL2);
Text row = new Text(te.getFirstPos().toString() + te.getSecondPos().toString() + DELIM + te.getFirst().toString() + DELIM + te.getSecond());
Mutation m1 = new Mutation(row);
m1.put(new Text(te.getKeyPos().toString() + "subject"), new Text(cl.getcardS().toString()), new Value(new byte[0]));
Mutation m2 = new Mutation(row);
m2.put(new Text(te.getKeyPos().toString() + "predicate"), new Text(cl.getcardP().toString()), new Value(new byte[0]));
Mutation m3 = new Mutation(row);
m3.put(new Text(te.getKeyPos().toString() + "object"), new Text(cl.getcardO().toString()), new Value(new byte[0]));
Text table = new Text("");
new ReduceDriver<TripleEntry, CardList, Text, Mutation>().withReducer(new JoinSelectStatisticsSum.CardinalityIdentityReducer()).withInput(te, list).withOutput(table, m1).withOutput(table, m2).withOutput(table, m3).runTest();
}
use of org.apache.rya.joinselect.mr.utils.CardList in project incubator-rya by apache.
the class CardinalityIdentityReducerTest method testJoinTwoVars.
@Test
public void testJoinTwoVars() throws InterruptedException, IOException {
TripleEntry te = new TripleEntry(new Text("urn:gem:etype#1234"), new Text(""), new Text("subject"), new Text(""), new Text("predicateobject"));
CardList cL1 = new CardList(0, 0, 0, 1, 2, 3);
CardList cL2 = new CardList(0, 0, 0, 4, 5, 6);
CardList cl = new CardList(0, 0, 0, 5, 7, 9);
List<CardList> list = new ArrayList<CardList>();
list.add(cL1);
list.add(cL2);
Text row = new Text(te.getFirstPos().toString() + DELIM + te.getFirst().toString());
Mutation m1 = new Mutation(row);
m1.put(new Text(te.getKeyPos().toString() + "subjectpredicate"), new Text(cl.getcardSP().toString()), new Value(new byte[0]));
Mutation m2 = new Mutation(row);
m2.put(new Text(te.getKeyPos().toString() + "predicateobject"), new Text(cl.getcardPO().toString()), new Value(new byte[0]));
Mutation m3 = new Mutation(row);
m3.put(new Text(te.getKeyPos().toString() + "objectsubject"), new Text(cl.getcardSO().toString()), new Value(new byte[0]));
Text table = new Text("");
new ReduceDriver<TripleEntry, CardList, Text, Mutation>().withReducer(new JoinSelectStatisticsSum.CardinalityIdentityReducer()).withInput(te, list).withOutput(table, m1).withOutput(table, m2).withOutput(table, m3).runTest();
}
use of org.apache.rya.joinselect.mr.utils.CardList in project incubator-rya by apache.
the class JoinReducerTest method testTwoConstCard.
@Test
public void testTwoConstCard() throws InterruptedException, IOException {
CompositeType ct1 = new CompositeType("urn:gem#pred" + DELIM + "urn:gem:etype#1234", 1);
TripleEntry te1 = new TripleEntry("uri:testSubject", "", "subject", "", "predicateobject");
TripleEntry te2 = new TripleEntry("uri:testSubject", "", "subject", "", "objectpredicate");
CardinalityType c5 = new CardinalityType(45, "subjectobject", 0);
CardinalityType c1 = new CardinalityType(25, "subjectobject", 2);
CardinalityType c2 = new CardinalityType(27, "predicateobject", 5);
CardinalityType c3 = new CardinalityType(29, "predicateobject", 2);
CardinalityType c4 = new CardinalityType(31, "subjectpredicate", 1);
CardinalityType c6 = new CardinalityType(56, "subjectpredicate", 2);
List<TripleCard> list1 = new ArrayList<TripleCard>();
list1.add(new TripleCard(c1));
list1.add(new TripleCard(c2));
list1.add(new TripleCard(c3));
list1.add(new TripleCard(c4));
list1.add(new TripleCard(c5));
list1.add(new TripleCard(c6));
list1.add(new TripleCard(te1));
list1.add(new TripleCard(te2));
// System.out.println("List is " + list);
new ReduceDriver<CompositeType, TripleCard, TripleEntry, CardList>().withReducer(new JoinSelectAggregate.JoinReducer()).withInput(ct1, list1).withOutput(te1, new CardList(0, 0, 0, 31, 29, 45)).withOutput(te2, new CardList(0, 0, 0, 31, 29, 45)).runTest();
}
Aggregations