Search in sources :

Example 1 with PredicateBase

use of edu.uci.ics.texera.dataflow.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;
}
Also used : PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) PassThroughPredicate(edu.uci.ics.texera.textql.planbuilder.beans.PassThroughPredicate) ArrayList(java.util.ArrayList)

Example 2 with PredicateBase

use of edu.uci.ics.texera.dataflow.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.texera.textql.statements.SelectStatement) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) Statement(edu.uci.ics.texera.textql.statements.Statement) Test(org.junit.Test)

Example 3 with PredicateBase

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

Example 4 with PredicateBase

use of edu.uci.ics.texera.dataflow.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.texera.textql.statements.SelectStatement) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) ExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) KeywordPredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Example 5 with PredicateBase

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

the class SelectStatementTest method testSelectStatementBeansBuilder00.

/**
 * Test the correctness of the generated beans by a SelectStatement without a
 * ProjectPredicate nor ExtractPredicate.
 * 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 testSelectStatementBeansBuilder00() {
    SelectStatement selectStatement = new SelectStatement("id", null, null, "tableX", null, null);
    List<PredicateBase> expectedGeneratedBeans = Collections.emptyList();
    List<String> dependencies = Arrays.asList("tableX");
    Assert.assertEquals(selectStatement.getInputViews(), dependencies);
    StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) Test(org.junit.Test)

Aggregations

PredicateBase (edu.uci.ics.texera.dataflow.common.PredicateBase)17 Test (org.junit.Test)15 SelectStatement (edu.uci.ics.texera.textql.statements.SelectStatement)8 KeywordPredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate)6 ProjectionPredicate (edu.uci.ics.texera.dataflow.projection.ProjectionPredicate)5 ProjectPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate)5 ExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate)4 KeywordExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate)4 PassThroughPredicate (edu.uci.ics.texera.textql.planbuilder.beans.PassThroughPredicate)3 Statement (edu.uci.ics.texera.textql.statements.Statement)3 ProjectSomeFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate)3 CreateViewStatement (edu.uci.ics.texera.textql.statements.CreateViewStatement)2 ProjectAllFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate)2 OperatorLink (edu.uci.ics.texera.dataflow.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