use of edu.uci.ics.texera.dataflow.projection.ProjectionPredicate in project textdb by TextDB.
the class JoinDistanceTest method testOneOfTheOperatorResultContainsNoSpan.
// This case tests for the scenario when one of the operators result lists has no span.
// If one of the operators doesn't have span, then an exception will be thrown.
// Test result: DataflowException is thrown
@Test(expected = DataflowException.class)
public void testOneOfTheOperatorResultContainsNoSpan() throws Exception {
JoinTestHelper.insertToTable(BOOK_TABLE, JoinTestConstants.bookGroup1.get(0));
KeywordMatcherSourceOperator keywordSourceOuter = JoinTestHelper.getKeywordSource(BOOK_TABLE, "special", conjunction);
String fuzzyTokenQuery = "this writer writes well";
double thresholdRatio = 0.25;
List<String> textAttributeNames = JoinTestConstants.BOOK_SCHEMA.getAttributes().stream().filter(attr -> attr.getType() != AttributeType.TEXT).map(Attribute::getName).collect(Collectors.toList());
FuzzyTokenSourcePredicate fuzzySourcePredicateInner = new FuzzyTokenSourcePredicate(fuzzyTokenQuery, textAttributeNames, LuceneAnalyzerConstants.standardAnalyzerString(), thresholdRatio, BOOK_TABLE, SchemaConstants.SPAN_LIST);
FuzzyTokenMatcherSourceOperator fuzzyMatcherInner = new FuzzyTokenMatcherSourceOperator(fuzzySourcePredicateInner);
ProjectionPredicate removeSpanListPredicate = new ProjectionPredicate(JoinTestConstants.BOOK_SCHEMA.getAttributeNames());
ProjectionOperator removeSpanListProjection = new ProjectionOperator(removeSpanListPredicate);
removeSpanListProjection.setInputOperator(fuzzyMatcherInner);
JoinTestHelper.getJoinDistanceResults(keywordSourceOuter, removeSpanListProjection, new JoinDistancePredicate(JoinTestConstants.REVIEW, 20), Integer.MAX_VALUE, 0);
}
use of edu.uci.ics.texera.dataflow.projection.ProjectionPredicate in project textdb by TextDB.
the class ProjectSomeFieldsPredicate method generateOperatorBean.
/**
* Return this operator converted to an { @code OperatorBean }.
* @param projectOperatorId The ID of the OperatorBean to be created.
*/
public PredicateBase generateOperatorBean(String projectOperatorId) {
ProjectionPredicate projectionPredicate = new ProjectionPredicate(this.getProjectedFields());
projectionPredicate.setID(projectOperatorId);
return projectionPredicate;
}
use of edu.uci.ics.texera.dataflow.projection.ProjectionPredicate in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder05.
/**
* Test the correctness of the generated beans by a SelectStatement with a
* ProjectAllFieldsPredicate and a KeywordExtractPredicate.
* Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
* methods and check if the generated path form the node getInputNodeID() to
* the node getOutputNodeID() is correct. Also check whether getInputViews()
* is returning the correct dependencies.
*/
@Test
public void testSelectStatementBeansBuilder05() {
ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b"));
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "x", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
SelectStatement selectStatement = new SelectStatement("_sid4", projectPredicate, extractPredicate, "from", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("x", Arrays.asList("a", "b"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "_sid4_e"), new ProjectionPredicate(Arrays.asList("a", "b")));
List<String> dependencies = Arrays.asList("from");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.texera.dataflow.projection.ProjectionPredicate in project textdb by TextDB.
the class ProjectSomeFieldsPredicateTest method testGenerateOperatorBean00.
/**
* Test the generateOperatorBean method.
* Build a SelectSomeFieldsPredicate, invoke the generateOperatorBean and check
* whether a ProjectionBean with the right attributes is returned.
* An empty list is used as the list of projected fields.
*/
@Test
public void testGenerateOperatorBean00() {
String operatorId = "xxx";
List<String> projectedFields = Collections.emptyList();
ProjectSomeFieldsPredicate projectSomeFieldsPredicate = new ProjectSomeFieldsPredicate(projectedFields);
PredicateBase computedProjectionBean = projectSomeFieldsPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new ProjectionPredicate(Arrays.asList());
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
Aggregations