use of edu.uci.ics.texera.dataflow.regexmatcher.RegexPredicate in project textdb by TextDB.
the class PredicateBaseTest method testRegexMatcher.
@Test
public void testRegexMatcher() throws Exception {
RegexPredicate regexPredicate = new RegexPredicate("regex", attributeNames, "spanListName");
testPredicate(regexPredicate);
RegexSourcePredicate regexSourcePredicate = new RegexSourcePredicate("regex", attributeNames, "tableName", "spanListName");
testPredicate(regexSourcePredicate);
}
use of edu.uci.ics.texera.dataflow.regexmatcher.RegexPredicate in project textdb by TextDB.
the class JoinTestHelper method getRegexMatcher.
public static RegexMatcher getRegexMatcher(String tableName, String query, String attrName) {
try {
ScanBasedSourceOperator scanBasedSourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
RegexMatcher regexMatcher = new RegexMatcher(new RegexPredicate(query, Arrays.asList(attrName), SchemaConstants.SPAN_LIST));
regexMatcher.setInputOperator(scanBasedSourceOperator);
return regexMatcher;
} catch (DataflowException e) {
e.printStackTrace();
return null;
}
}
use of edu.uci.ics.texera.dataflow.regexmatcher.RegexPredicate in project textdb by TextDB.
the class LogicalPlanTest method testInvalidLogicalPlan4.
/*
* Test a operator graph with a disconnected component
*
* KeywordSource --> RegexMatcher --> TupleSink
* RegexMatcher --> NlpEntityOperator
* (a disconnected graph)
*
*/
@Test(expected = TexeraException.class)
public void testInvalidLogicalPlan4() throws Exception {
LogicalPlan logicalPlan = new LogicalPlan();
String REGEX_ID_2 = "regex 2";
RegexPredicate regexPredicate2 = new RegexPredicate("ca(lifornia)?", Arrays.asList("location", "content"), "regexResults");
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));
logicalPlan.buildQueryPlan();
}
use of edu.uci.ics.texera.dataflow.regexmatcher.RegexPredicate in project textdb by TextDB.
the class LogicalPlanTest method testInvalidLogicalPlan3.
/*
* Test a operator graph with a disconnected component
*
* KeywordSource --> RegexMatcher --> TupleSink
* RegexMatcher --> NlpEntityOperator
* (a disconnected graph)
*
*/
@Test(expected = TexeraException.class)
public void testInvalidLogicalPlan3() throws Exception {
LogicalPlan logicalPlan = new LogicalPlan();
String REGEX_ID_2 = "regex 2";
RegexPredicate regexPredicate2 = new RegexPredicate("ca(lifornia)?", Arrays.asList("location", "content"), "regexResults");
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));
logicalPlan.buildQueryPlan();
}
use of edu.uci.ics.texera.dataflow.regexmatcher.RegexPredicate 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();
HashMap<String, ISink> sinkHashMap = queryPlan.getSinkMap();
Assert.assertEquals(1, sinkHashMap.size());
ISink tupleSink = null;
for (HashMap.Entry<String, ISink> entry : sinkHashMap.entrySet()) {
tupleSink = entry.getValue();
}
Assert.assertNotNull(tupleSink);
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