Search in sources :

Example 6 with ProjectionPredicate

use of edu.uci.ics.textdb.exp.projection.ProjectionPredicate in project textdb by TextDB.

the class ProjectSomeFieldsPredicateTest method testGenerateOperatorBean01.

/**
     * 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 field names is used as the list of projected fields.
     */
@Test
public void testGenerateOperatorBean01() {
    String operatorId = "zwx";
    List<String> projectedFields = Arrays.asList("field0", "field1");
    ProjectSomeFieldsPredicate projectSomeFieldsPredicate = new ProjectSomeFieldsPredicate(projectedFields);
    PredicateBase computedProjectionBean = projectSomeFieldsPredicate.generateOperatorBean(operatorId);
    PredicateBase expectedProjectionBean = new ProjectionPredicate(Arrays.asList("field0", "field1"));
    expectedProjectionBean.setID(operatorId);
    Assert.assertEquals(expectedProjectionBean, computedProjectionBean);
}
Also used : PredicateBase(edu.uci.ics.textdb.exp.common.PredicateBase) ProjectionPredicate(edu.uci.ics.textdb.exp.projection.ProjectionPredicate) Test(org.junit.Test)

Example 7 with ProjectionPredicate

use of edu.uci.ics.textdb.exp.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);
}
Also used : PredicateBase(edu.uci.ics.textdb.exp.common.PredicateBase) ProjectionPredicate(edu.uci.ics.textdb.exp.projection.ProjectionPredicate) Test(org.junit.Test)

Example 8 with ProjectionPredicate

use of edu.uci.ics.textdb.exp.projection.ProjectionPredicate 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);
}
Also used : PredicateBase(edu.uci.ics.textdb.exp.common.PredicateBase) ProjectionPredicate(edu.uci.ics.textdb.exp.projection.ProjectionPredicate) Test(org.junit.Test)

Example 9 with ProjectionPredicate

use of edu.uci.ics.textdb.exp.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;
}
Also used : ProjectionPredicate(edu.uci.ics.textdb.exp.projection.ProjectionPredicate)

Aggregations

ProjectionPredicate (edu.uci.ics.textdb.exp.projection.ProjectionPredicate)9 Test (org.junit.Test)8 PredicateBase (edu.uci.ics.textdb.exp.common.PredicateBase)5 ProjectionOperator (edu.uci.ics.textdb.exp.projection.ProjectionOperator)2 SelectStatement (edu.uci.ics.textdb.textql.statements.SelectStatement)2 ProjectPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectPredicate)2 ProjectSomeFieldsPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectSomeFieldsPredicate)2 IOperator (edu.uci.ics.textdb.api.dataflow.IOperator)1 IField (edu.uci.ics.textdb.api.field.IField)1 TextField (edu.uci.ics.textdb.api.field.TextField)1 Schema (edu.uci.ics.textdb.api.schema.Schema)1 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)1 FuzzyTokenMatcherSourceOperator (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenMatcherSourceOperator)1 FuzzyTokenSourcePredicate (edu.uci.ics.textdb.exp.fuzzytokenmatcher.FuzzyTokenSourcePredicate)1 JoinDistancePredicate (edu.uci.ics.textdb.exp.join.JoinDistancePredicate)1 KeywordMatcherSourceOperator (edu.uci.ics.textdb.exp.keywordmatcher.KeywordMatcherSourceOperator)1 KeywordPredicate (edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate)1 ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)1 ScanSourcePredicate (edu.uci.ics.textdb.exp.source.scan.ScanSourcePredicate)1 ExtractPredicate (edu.uci.ics.textdb.textql.statements.predicates.ExtractPredicate)1