Search in sources :

Example 6 with ReduceDriver

use of org.apache.hadoop.mrunit.mapreduce.ReduceDriver in project incubator-rya by apache.

the class JoinReducerTest method testSingleConstCard.

@Test
public void testSingleConstCard() throws InterruptedException, IOException {
    CompositeType ct = new CompositeType("urn:gem:etype#1234", 1);
    TripleEntry te = new TripleEntry("urn:gem#pred", "urn:gem:etype#4567", "predicate", "object", "subject");
    CardinalityType c5 = new CardinalityType(45, "object", 0);
    CardinalityType c1 = new CardinalityType(25, "subject", 2);
    CardinalityType c2 = new CardinalityType(27, "predicate", 2);
    CardinalityType c3 = new CardinalityType(29, "object", 2);
    CardinalityType c4 = new CardinalityType(31, "predicate", 1);
    List<TripleCard> list = new ArrayList<TripleCard>();
    list.add(new TripleCard(c1));
    list.add(new TripleCard(c2));
    list.add(new TripleCard(c3));
    list.add(new TripleCard(c4));
    list.add(new TripleCard(c5));
    list.add(new TripleCard(te));
    System.out.println("List is " + list);
    new ReduceDriver<CompositeType, TripleCard, TripleEntry, CardList>().withReducer(new JoinSelectAggregate.JoinReducer()).withInput(ct, list).withOutput(te, new CardList(25, 31, 45, 0, 0, 0)).runTest();
}
Also used : CardinalityType(org.apache.rya.joinselect.mr.utils.CardinalityType) CardList(org.apache.rya.joinselect.mr.utils.CardList) ArrayList(java.util.ArrayList) TripleEntry(org.apache.rya.joinselect.mr.utils.TripleEntry) TripleCard(org.apache.rya.joinselect.mr.utils.TripleCard) ReduceDriver(org.apache.hadoop.mrunit.mapreduce.ReduceDriver) CompositeType(org.apache.rya.joinselect.mr.utils.CompositeType) Test(org.junit.Test)

Example 7 with ReduceDriver

use of org.apache.hadoop.mrunit.mapreduce.ReduceDriver in project incubator-rya by apache.

the class DuplicateEliminationTest method testRetainSimplest.

@Test
public void testRetainSimplest() throws Exception {
    List<Derivation> facts = new LinkedList<>();
    facts.add(Y_SUPER_X_INV.getDerivation());
    facts.add(Y_SUPER_X.getDerivation());
    Fact unset = Y_SUPER_X.clone();
    unset.unsetDerivation();
    ReduceDriver<Fact, Derivation, Fact, NullWritable> driver = new ReduceDriver<>();
    driver.getConfiguration().setInt(MRReasoningUtils.STEP_PROP, 1);
    driver.withReducer(new DuplicateElimination.DuplicateEliminationReducer()).withInput(unset, facts).withMultiOutput(MRReasoningUtils.INTERMEDIATE_OUT, Y_SUPER_X, NullWritable.get()).runTest();
}
Also used : Derivation(org.apache.rya.reasoning.Derivation) Fact(org.apache.rya.reasoning.Fact) NullWritable(org.apache.hadoop.io.NullWritable) ReduceDriver(org.apache.hadoop.mrunit.mapreduce.ReduceDriver) LinkedList(java.util.LinkedList) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ReduceDriver (org.apache.hadoop.mrunit.mapreduce.ReduceDriver)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 CardList (org.apache.rya.joinselect.mr.utils.CardList)5 TripleEntry (org.apache.rya.joinselect.mr.utils.TripleEntry)5 Mutation (org.apache.accumulo.core.data.Mutation)4 Value (org.apache.accumulo.core.data.Value)4 Text (org.apache.hadoop.io.Text)4 NullWritable (org.apache.hadoop.io.NullWritable)2 Fact (org.apache.rya.reasoning.Fact)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 MapDriver (org.apache.hadoop.mrunit.mapreduce.MapDriver)1 ReduceFeeder (org.apache.hadoop.mrunit.mapreduce.ReduceFeeder)1 KeyValueReuseList (org.apache.hadoop.mrunit.types.KeyValueReuseList)1 Pair (org.apache.hadoop.mrunit.types.Pair)1 CardinalityType (org.apache.rya.joinselect.mr.utils.CardinalityType)1 CompositeType (org.apache.rya.joinselect.mr.utils.CompositeType)1