Search in sources :

Example 26 with KeywordMatcherSourceOperator

use of edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator in project textdb by TextDB.

the class LogicalPlanTest method testLogicalPlan2.

/*
     * Test a valid operator graph.
     *                  -> RegexMatcher -->
     * KeywordSource --<                     >-- Join --> TupleSink
     *                  -> NlpEntityOperator -->
     * 
     */
@Test
public void testLogicalPlan2() throws Exception {
    LogicalPlan logicalPlan = getLogicalPlan2();
    Plan queryPlan = logicalPlan.buildQueryPlan();
    ISink tupleSink = queryPlan.getRoot();
    Assert.assertTrue(tupleSink instanceof TupleSink);
    IOperator join = ((TupleSink) tupleSink).getInputOperator();
    Assert.assertTrue(join instanceof Join);
    IOperator joinInput1 = ((Join) join).getInnerInputOperator();
    Assert.assertTrue(joinInput1 instanceof RegexMatcher);
    IOperator joinInput2 = ((Join) join).getOuterInputOperator();
    Assert.assertTrue(joinInput2 instanceof NlpEntityOperator);
    IOperator connectorOut1 = ((RegexMatcher) joinInput1).getInputOperator();
    Assert.assertTrue(connectorOut1 instanceof ConnectorOutputOperator);
    IOperator connectorOut2 = ((NlpEntityOperator) joinInput2).getInputOperator();
    Assert.assertTrue(connectorOut2 instanceof ConnectorOutputOperator);
    HashSet<Integer> connectorIndices = new HashSet<>();
    connectorIndices.add(((ConnectorOutputOperator) connectorOut1).getOutputIndex());
    connectorIndices.add(((ConnectorOutputOperator) connectorOut2).getOutputIndex());
    Assert.assertEquals(connectorIndices.size(), 2);
    OneToNBroadcastConnector connector1 = ((ConnectorOutputOperator) connectorOut1).getOwnerConnector();
    OneToNBroadcastConnector connector2 = ((ConnectorOutputOperator) connectorOut2).getOwnerConnector();
    Assert.assertSame(connector1, connector2);
    IOperator keywordSource = connector1.getInputOperator();
    Assert.assertTrue(keywordSource instanceof KeywordMatcherSourceOperator);
}
Also used : TupleSink(edu.uci.ics.textdb.exp.sink.tuple.TupleSink) IOperator(edu.uci.ics.textdb.api.dataflow.IOperator) Join(edu.uci.ics.textdb.exp.join.Join) Plan(edu.uci.ics.textdb.api.engine.Plan) KeywordMatcherSourceOperator(edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator) ISink(edu.uci.ics.textdb.api.dataflow.ISink) ConnectorOutputOperator(edu.uci.ics.textdb.exp.connector.OneToNBroadcastConnector.ConnectorOutputOperator) NlpEntityOperator(edu.uci.ics.textdb.exp.nlp.entity.NlpEntityOperator) RegexMatcher(edu.uci.ics.textdb.exp.regexmatcher.RegexMatcher) OneToNBroadcastConnector(edu.uci.ics.textdb.exp.connector.OneToNBroadcastConnector) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

KeywordMatcherSourceOperator (edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator)26 Test (org.junit.Test)22 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)20 JoinDistancePredicate (edu.uci.ics.textdb.exp.join.JoinDistancePredicate)19 ArrayList (java.util.ArrayList)12 Span (edu.uci.ics.textdb.api.span.Span)10 IField (edu.uci.ics.textdb.api.field.IField)9 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)9 StringField (edu.uci.ics.textdb.api.field.StringField)9 TextField (edu.uci.ics.textdb.api.field.TextField)9 Schema (edu.uci.ics.textdb.api.schema.Schema)9 KeywordSourcePredicate (edu.uci.ics.textdb.exp.keywordmatcher.KeywordSourcePredicate)4 IOperator (edu.uci.ics.textdb.api.dataflow.IOperator)3 ISink (edu.uci.ics.textdb.api.dataflow.ISink)3 Plan (edu.uci.ics.textdb.api.engine.Plan)3 Join (edu.uci.ics.textdb.exp.join.Join)3 RegexMatcher (edu.uci.ics.textdb.exp.regexmatcher.RegexMatcher)3 TupleSink (edu.uci.ics.textdb.exp.sink.tuple.TupleSink)3 Attribute (edu.uci.ics.textdb.api.schema.Attribute)2 OneToNBroadcastConnector (edu.uci.ics.textdb.exp.connector.OneToNBroadcastConnector)2