use of edu.uci.ics.texera.api.dataflow.ISink 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.dataflow.ISink 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.dataflow.ISink 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.dataflow.ISink in project textdb by TextDB.
the class LogicalPlan method findSinkOperator.
/*
* Finds the sink operator in the operator graph.
*
* This function assumes that the graph is valid and there is only one sink in the graph.
*/
private ISink findSinkOperator(HashMap<String, IOperator> operatorObjectMap) throws PlanGenException {
IOperator sinkOperator = adjacencyList.keySet().stream().filter(operator -> operatorPredicateMap.get(operator).getClass().toString().toLowerCase().contains("sink")).map(operator -> operatorObjectMap.get(operator)).findFirst().orElse(null);
PlanGenUtils.planGenAssert(sinkOperator != null, "Error: sink operator doesn't exist.");
PlanGenUtils.planGenAssert(sinkOperator instanceof ISink, "Error: sink operator's type doesn't match.");
return (ISink) sinkOperator;
}
use of edu.uci.ics.texera.api.dataflow.ISink 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);
}
Aggregations