use of edu.uci.ics.texera.api.engine.Plan in project textdb by TextDB.
the class LogicalPlanTest method testGetOutputSchema1.
/*
* Test getOutputSchema on a valid operator graph.
*
* KeywordSource --> RegexMatcher --> TupleSink
*
*/
@Test
public void testGetOutputSchema1() throws Exception {
LogicalPlan logicalPlan = getLogicalPlan1();
Plan queryPlan = logicalPlan.buildQueryPlan();
ISink tupleSink = queryPlan.getRoot();
IOperator regexMatcher = ((TupleSink) tupleSink).getInputOperator();
IOperator keywordSource = ((RegexMatcher) regexMatcher).getInputOperator();
regexMatcher.open();
Schema expectedSourceOutputSchema = keywordSource.getOutputSchema();
Schema expectedMatcherOutputSchema = regexMatcher.getOutputSchema();
regexMatcher.close();
Schema sourceOutputSchema = logicalPlan.getOperatorOutputSchema(KEYWORD_SOURCE_ID);
Schema matcherOutputSchema = logicalPlan.getOperatorOutputSchema(REGEX_ID);
Assert.assertEquals(expectedSourceOutputSchema, sourceOutputSchema);
Assert.assertEquals(expectedMatcherOutputSchema, matcherOutputSchema);
}
use of edu.uci.ics.texera.api.engine.Plan in project textdb by TextDB.
the class LogicalPlanTest method testLogicalPlan1.
/*
* Test a valid operator graph.
*
* KeywordSource --> RegexMatcher --> TupleSink
*
*/
@Test
public void testLogicalPlan1() throws Exception {
LogicalPlan logicalPlan = getLogicalPlan1();
Plan queryPlan = logicalPlan.buildQueryPlan();
ISink tupleSink = queryPlan.getRoot();
Assert.assertTrue(tupleSink instanceof TupleSink);
IOperator regexMatcher = ((TupleSink) tupleSink).getInputOperator();
Assert.assertTrue(regexMatcher instanceof RegexMatcher);
IOperator keywordSource = ((RegexMatcher) regexMatcher).getInputOperator();
Assert.assertTrue(keywordSource instanceof KeywordMatcherSourceOperator);
}
use of edu.uci.ics.texera.api.engine.Plan in project textdb by TextDB.
the class LogicalPlan method buildQueryPlan.
/**
* Builds and returns the query plan from the operator graph.
*
* @return the plan generated from the operator graph
* @throws PlanGenException, if the operator graph is invalid.
*/
public Plan buildQueryPlan() throws PlanGenException {
if (UPDATED) {
buildOperators();
validateOperatorGraph();
connectOperators(operatorObjectMap);
}
ISink sink = findSinkOperator(operatorObjectMap);
Plan queryPlan = new Plan(sink);
return queryPlan;
}
use of edu.uci.ics.texera.api.engine.Plan in project textdb by TextDB.
the class LogicalPlanTest method testGetOutputSchema4.
/*
* Test getOutputSchema on a operator graph without a sink operator
*
* KeywordSource --> RegexMatcher
*
*/
@Test
public void testGetOutputSchema4() throws Exception {
LogicalPlan validLogicalPlan = getLogicalPlan1();
Plan queryPlan = validLogicalPlan.buildQueryPlan();
ISink tupleSink = queryPlan.getRoot();
IOperator regexMatcher = ((TupleSink) tupleSink).getInputOperator();
IOperator keywordSource = ((RegexMatcher) regexMatcher).getInputOperator();
regexMatcher.open();
Schema expectedSourceOutputSchema = keywordSource.getOutputSchema();
Schema expectedMatcherOutputSchema = regexMatcher.getOutputSchema();
regexMatcher.close();
LogicalPlan logicalPlan = new LogicalPlan();
logicalPlan.addOperator(keywordSourcePredicate);
logicalPlan.addOperator(regexPredicate);
logicalPlan.addLink(new OperatorLink(KEYWORD_SOURCE_ID, REGEX_ID));
Schema sourceOutputSchema = logicalPlan.getOperatorOutputSchema(KEYWORD_SOURCE_ID);
Schema matcherOutputSchema = logicalPlan.getOperatorOutputSchema(REGEX_ID);
Assert.assertEquals(expectedSourceOutputSchema, sourceOutputSchema);
Assert.assertEquals(expectedMatcherOutputSchema, matcherOutputSchema);
}
use of edu.uci.ics.texera.api.engine.Plan in project textdb by TextDB.
the class LogicalPlanTest method testGetOutputSchema5.
/*
* Test a operator graph with a disconnected component
*
* KeywordSource --> RegexMatcher --> TupleSink
* RegexMatcher --> NlpEntityOperator
* (a disconnected graph)
*
*/
@Test(expected = TexeraException.class)
public void testGetOutputSchema5() throws Exception {
LogicalPlan validLogicalPlan = getLogicalPlan1();
Plan queryPlan = validLogicalPlan.buildQueryPlan();
ISink tupleSink = queryPlan.getRoot();
IOperator regexMatcher = ((TupleSink) tupleSink).getInputOperator();
IOperator keywordSource = ((RegexMatcher) regexMatcher).getInputOperator();
regexMatcher.open();
Schema expectedSourceOutputSchema = keywordSource.getOutputSchema();
Schema expectedMatcherOutputSchema = regexMatcher.getOutputSchema();
regexMatcher.close();
LogicalPlan logicalPlan = new LogicalPlan();
String REGEX_ID_2 = "regex 2";
RegexPredicate regexPredicate2 = new RegexPredicate("ca(lifornia)?", Arrays.asList("location", "content"), "regexResults");
regexPredicate2.setID(REGEX_ID_2);
logicalPlan.addOperator(keywordSourcePredicate);
logicalPlan.addOperator(regexPredicate);
logicalPlan.addOperator(tupleSinkPredicate);
logicalPlan.addOperator(regexPredicate2);
logicalPlan.addOperator(nlpEntityPredicate);
logicalPlan.addLink(new OperatorLink(KEYWORD_SOURCE_ID, REGEX_ID));
logicalPlan.addLink(new OperatorLink(REGEX_ID, TUPLE_SINK_ID));
logicalPlan.addLink(new OperatorLink(REGEX_ID_2, NLP_ENTITY_ID));
Schema sourceOutputSchema = logicalPlan.getOperatorOutputSchema(KEYWORD_SOURCE_ID);
Schema matcherOutputSchema = logicalPlan.getOperatorOutputSchema(REGEX_ID);
Assert.assertEquals(expectedSourceOutputSchema, sourceOutputSchema);
Assert.assertEquals(expectedMatcherOutputSchema, matcherOutputSchema);
Schema raiseExceptionSchema = logicalPlan.getOperatorOutputSchema(REGEX_ID_2);
}
Aggregations