Search in sources :

Example 6 with PredicateBase

use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.

the class CreateViewStatementTest method testCreateViewStatementBeansBuilder00.

/**
     * Test the correctness of the generated beans by a CreateViewStatement with
     * a SelectExtractStatement as sub-statement without a SelectPredicate nor
     * ExtractPredicate.
     * Get a graph by calling getInternalOperatorBeans() 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 testCreateViewStatementBeansBuilder00() {
    Statement subStatement = new SelectStatement("id2", null, null, "from", null, null);
    CreateViewStatement createViewStatement = new CreateViewStatement("idx", subStatement);
    List<PredicateBase> expectedGeneratedBeans = Collections.emptyList();
    List<String> dependencies = Arrays.asList(subStatement.getId());
    Assert.assertEquals(createViewStatement.getInputViews(), dependencies);
    StatementTestUtils.assertGeneratedBeans(createViewStatement, expectedGeneratedBeans);
}
Also used : SelectStatement(edu.uci.ics.textdb.textql.statements.SelectStatement) CreateViewStatement(edu.uci.ics.textdb.textql.statements.CreateViewStatement) PredicateBase(edu.uci.ics.textdb.exp.common.PredicateBase) Statement(edu.uci.ics.textdb.textql.statements.Statement) CreateViewStatement(edu.uci.ics.textdb.textql.statements.CreateViewStatement) SelectStatement(edu.uci.ics.textdb.textql.statements.SelectStatement) Test(org.junit.Test)

Example 7 with PredicateBase

use of edu.uci.ics.textdb.exp.common.PredicateBase in project textdb by TextDB.

the class SelectStatementTest method testSelectStatementBeansBuilder03.

/**
     * Test the correctness of the generated beans by a SelectStatement with 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 testSelectStatementBeansBuilder03() {
    ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("c", "d"), "word", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
    SelectStatement selectStatement = new SelectStatement("id", null, extractPredicate, "TableP9", null, null);
    List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("word", Arrays.asList("c", "d"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "id_e"));
    List<String> dependencies = Arrays.asList("TableP9");
    Assert.assertEquals(selectStatement.getInputViews(), dependencies);
    StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
Also used : SelectStatement(edu.uci.ics.textdb.textql.statements.SelectStatement) PredicateBase(edu.uci.ics.textdb.exp.common.PredicateBase) KeywordExtractPredicate(edu.uci.ics.textdb.textql.statements.predicates.KeywordExtractPredicate) ExtractPredicate(edu.uci.ics.textdb.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.textdb.textql.statements.predicates.KeywordExtractPredicate) KeywordPredicate(edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Example 8 with PredicateBase

use of edu.uci.ics.textdb.exp.common.PredicateBase 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);
}
Also used : SelectStatement(edu.uci.ics.textdb.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.textdb.textql.statements.predicates.ProjectPredicate) PredicateBase(edu.uci.ics.textdb.exp.common.PredicateBase) KeywordExtractPredicate(edu.uci.ics.textdb.textql.statements.predicates.KeywordExtractPredicate) ExtractPredicate(edu.uci.ics.textdb.textql.statements.predicates.ExtractPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.textdb.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.textdb.textql.statements.predicates.KeywordExtractPredicate) ProjectionPredicate(edu.uci.ics.textdb.exp.projection.ProjectionPredicate) KeywordPredicate(edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Example 9 with PredicateBase

use of edu.uci.ics.textdb.exp.common.PredicateBase 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 10 with PredicateBase

use of edu.uci.ics.textdb.exp.common.PredicateBase 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)

Aggregations

PredicateBase (edu.uci.ics.textdb.exp.common.PredicateBase)17 Test (org.junit.Test)15 SelectStatement (edu.uci.ics.textdb.textql.statements.SelectStatement)8 KeywordPredicate (edu.uci.ics.textdb.exp.keywordmatcher.KeywordPredicate)6 ProjectionPredicate (edu.uci.ics.textdb.exp.projection.ProjectionPredicate)5 ProjectPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectPredicate)5 ExtractPredicate (edu.uci.ics.textdb.textql.statements.predicates.ExtractPredicate)4 KeywordExtractPredicate (edu.uci.ics.textdb.textql.statements.predicates.KeywordExtractPredicate)4 PassThroughPredicate (edu.uci.ics.textdb.textql.planbuilder.beans.PassThroughPredicate)3 Statement (edu.uci.ics.textdb.textql.statements.Statement)3 ProjectSomeFieldsPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectSomeFieldsPredicate)3 CreateViewStatement (edu.uci.ics.textdb.textql.statements.CreateViewStatement)2 ProjectAllFieldsPredicate (edu.uci.ics.textdb.textql.statements.predicates.ProjectAllFieldsPredicate)2 OperatorLink (edu.uci.ics.textdb.exp.plangen.OperatorLink)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Assert (org.junit.Assert)1