Search in sources :

Example 1 with ISink

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);
}
Also used : ISink(edu.uci.ics.texera.api.dataflow.ISink) TupleSink(edu.uci.ics.texera.dataflow.sink.tuple.TupleSink) IOperator(edu.uci.ics.texera.api.dataflow.IOperator) Schema(edu.uci.ics.texera.api.schema.Schema) RegexMatcher(edu.uci.ics.texera.dataflow.regexmatcher.RegexMatcher) Plan(edu.uci.ics.texera.api.engine.Plan) Test(org.junit.Test)

Example 2 with ISink

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);
}
Also used : ISink(edu.uci.ics.texera.api.dataflow.ISink) TupleSink(edu.uci.ics.texera.dataflow.sink.tuple.TupleSink) IOperator(edu.uci.ics.texera.api.dataflow.IOperator) RegexMatcher(edu.uci.ics.texera.dataflow.regexmatcher.RegexMatcher) Plan(edu.uci.ics.texera.api.engine.Plan) KeywordMatcherSourceOperator(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator) Test(org.junit.Test)

Example 3 with ISink

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;
}
Also used : ISink(edu.uci.ics.texera.api.dataflow.ISink) Plan(edu.uci.ics.texera.api.engine.Plan)

Example 4 with ISink

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;
}
Also used : Plan(edu.uci.ics.texera.api.engine.Plan) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Join(edu.uci.ics.texera.dataflow.join.Join) PropertyNameConstants(edu.uci.ics.texera.dataflow.common.PropertyNameConstants) PlanGenException(edu.uci.ics.texera.api.exception.PlanGenException) HashMap(java.util.HashMap) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) InvocationTargetException(java.lang.reflect.InvocationTargetException) ArrayList(java.util.ArrayList) OneToNBroadcastConnector(edu.uci.ics.texera.dataflow.connector.OneToNBroadcastConnector) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) IOperator(edu.uci.ics.texera.api.dataflow.IOperator) ISink(edu.uci.ics.texera.api.dataflow.ISink) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) Schema(edu.uci.ics.texera.api.schema.Schema) LinkedHashSet(java.util.LinkedHashSet) ISink(edu.uci.ics.texera.api.dataflow.ISink) IOperator(edu.uci.ics.texera.api.dataflow.IOperator)

Example 5 with ISink

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);
}
Also used : ISink(edu.uci.ics.texera.api.dataflow.ISink) TupleSink(edu.uci.ics.texera.dataflow.sink.tuple.TupleSink) IOperator(edu.uci.ics.texera.api.dataflow.IOperator) Schema(edu.uci.ics.texera.api.schema.Schema) RegexMatcher(edu.uci.ics.texera.dataflow.regexmatcher.RegexMatcher) Plan(edu.uci.ics.texera.api.engine.Plan) Test(org.junit.Test)

Aggregations

ISink (edu.uci.ics.texera.api.dataflow.ISink)11 Plan (edu.uci.ics.texera.api.engine.Plan)10 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)8 TupleSink (edu.uci.ics.texera.dataflow.sink.tuple.TupleSink)8 RegexMatcher (edu.uci.ics.texera.dataflow.regexmatcher.RegexMatcher)7 Test (org.junit.Test)7 Schema (edu.uci.ics.texera.api.schema.Schema)5 OneToNBroadcastConnector (edu.uci.ics.texera.dataflow.connector.OneToNBroadcastConnector)4 Join (edu.uci.ics.texera.dataflow.join.Join)4 ConnectorOutputOperator (edu.uci.ics.texera.dataflow.connector.OneToNBroadcastConnector.ConnectorOutputOperator)3 KeywordMatcherSourceOperator (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)3 NlpEntityOperator (edu.uci.ics.texera.dataflow.nlp.entity.NlpEntityOperator)3 HashSet (java.util.HashSet)3 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 PlanGenException (edu.uci.ics.texera.api.exception.PlanGenException)1 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)1