use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class ProjectSomeFieldsPredicateTest method testGenerateOperatorBean02.
/**
* Test the generateOperatorBean method.
* Build a SelectSomeFieldsPredicate, invoke the generateOperatorBean and check
* whether a ProjectionBean with the right attributes is returned.
* A list with some unordered field names is used as the list of projected fields.
*/
@Test
public void testGenerateOperatorBean02() {
String operatorId = "op00";
List<String> projectedFields = Arrays.asList("c", "a", "b");
ProjectSomeFieldsPredicate projectSomeFieldsPredicate = new ProjectSomeFieldsPredicate(projectedFields);
PredicateBase computedProjectionBean = projectSomeFieldsPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new ProjectionPredicate(Arrays.asList("c", "a", "b"));
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class SelectStatement method getInternalOperatorBeans.
/**
* Return a list of operators generated when this statement is converted to beans.
* Beans will be generated for the Alias, Projection, Extraction and Source operators.
* @return The list of operator beans generated by this statement.
*/
@Override
public List<PredicateBase> getInternalOperatorBeans() {
List<PredicateBase> operators = new ArrayList<>();
// Build and append a PassThroughBean as an alias for this Statement
operators.add(new PassThroughPredicate(getOutputNodeID()));
// Build and append bean for Projection
if (this.projectPredicate == null) {
operators.add(new PassThroughPredicate(getProjectionNodeID()));
} else {
operators.add(this.projectPredicate.generateOperatorBean(getProjectionNodeID()));
}
// Build and append bean for Extraction predicate
if (this.extractPredicate == null) {
operators.add(new PassThroughPredicate(getExtractionNodeID()));
} else {
operators.add(this.extractPredicate.generateOperatorBean(getExtractionNodeID()));
}
// Build and append bean for the Source
operators.add(new PassThroughPredicate(getInputNodeID()));
// return the built operators
return operators;
}
use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class SelectStatementTest method testSelectStatementBeansBuilder04.
/**
* 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 testSelectStatementBeansBuilder04() {
ProjectPredicate projectPredicate = new ProjectAllFieldsPredicate();
ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("f1"), "keyword", KeywordMatchingType.CONJUNCTION_INDEXBASED.toString());
SelectStatement selectStatement = new SelectStatement("id", projectPredicate, extractPredicate, "source", null, null);
List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("keyword", Arrays.asList("f1"), null, KeywordMatchingType.CONJUNCTION_INDEXBASED, "id_e"));
List<String> dependencies = Arrays.asList("source");
Assert.assertEquals(selectStatement.getInputViews(), dependencies);
StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class KeywordExtractPredicateTest method testGeneratePredicateBase02.
/**
* Test the generatePredicateBase method.
* Build a KeywordExtractPredicate, invoke the generatePredicateBase and
* check whether a KeywordMatcherBean with the right attributes is returned.
* A list with some fields is used as the list of fields to perform the match.
*/
@Test
public void testGeneratePredicateBase02() {
String operatorId = "keywordExtract00";
List<String> matchingFields = Arrays.asList("field0", "field1");
String keywords = "xxx";
String matchingType = KeywordMatchingType.SUBSTRING_SCANBASED.toString();
KeywordExtractPredicate keywordExtractPredicate = new KeywordExtractPredicate(matchingFields, keywords, matchingType);
PredicateBase computedProjectionBean = keywordExtractPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new KeywordPredicate(keywords, matchingFields, null, KeywordMatchingType.fromName(matchingType), operatorId);
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.
the class KeywordExtractPredicateTest method testGeneratePredicateBase00.
/**
* Test the generatePredicateBase method.
* Build a KeywordExtractPredicate, invoke the generatePredicateBase and
* check whether a KeywordMatcherBean with the right attributes is returned.
* An empty list is used as the list of fields to perform the match.
*/
@Test
public void testGeneratePredicateBase00() {
String operatorId = "xxx";
List<String> matchingFields = Collections.emptyList();
String keywords = "keyword";
String matchingType = KeywordMatchingType.CONJUNCTION_INDEXBASED.toString();
KeywordExtractPredicate keywordExtractPredicate = new KeywordExtractPredicate(matchingFields, keywords, matchingType);
PredicateBase computedProjectionBean = keywordExtractPredicate.generateOperatorBean(operatorId);
PredicateBase expectedProjectionBean = new KeywordPredicate(keywords, matchingFields, null, KeywordMatchingType.fromName(matchingType), operatorId);
expectedProjectionBean.setID(operatorId);
Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
Aggregations