Search in sources :

Example 11 with PredicateBase

use of edu.uci.ics.texera.dataflow.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.texera.dataflow.common.PredicateBase) ProjectionPredicate(edu.uci.ics.texera.dataflow.projection.ProjectionPredicate) Test(org.junit.Test)

Example 12 with PredicateBase

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

the class CreateViewStatementTest method testCreateViewStatementBeansBuilder01.

/**
 * Test the correctness of the generated beans by a CreateViewStatement with
 * a SelectExtractStatement as sub-statement with a
 * SelectSomeFieldsPredicate and a KeywordExtractPredicate.
 * 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 testCreateViewStatementBeansBuilder01() {
    ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("x", "y"));
    ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "zzz", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
    Statement subStatement = new SelectStatement("id", projectPredicate, extractPredicate, "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) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) 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) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) Statement(edu.uci.ics.texera.textql.statements.Statement) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Example 13 with PredicateBase

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

the class SelectStatementTest method testSelectStatementBeansBuilder01.

/**
 * Test the correctness of the generated beans by a SelectStatement with a
 * ProjectAllFieldsPredicate.
 * 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 testSelectStatementBeansBuilder01() {
    ProjectPredicate projectPredicate = new ProjectAllFieldsPredicate();
    SelectStatement selectStatement = new SelectStatement("id", projectPredicate, null, "Table", null, null);
    List<PredicateBase> expectedGeneratedBeans = Collections.emptyList();
    List<String> dependencies = Arrays.asList("Table");
    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) ProjectAllFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate) Test(org.junit.Test)

Example 14 with PredicateBase

use of edu.uci.ics.texera.dataflow.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.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) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) ProjectionPredicate(edu.uci.ics.texera.dataflow.projection.ProjectionPredicate) KeywordPredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Example 15 with PredicateBase

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

the class KeywordExtractPredicateTest method testGeneratePredicateBase01.

/**
 * Test the generatePredicateBase method.
 * Build a KeywordExtractPredicate, invoke the generatePredicateBase and
 * check whether a KeywordMatcherBean with the right attributes is returned.
 * A list with one field is used as the list of fields to perform the match.
 */
@Test
public void testGeneratePredicateBase01() {
    String operatorId = "operator";
    List<String> matchingFields = Arrays.asList("fieldOne");
    String keywords = "keyword(s)";
    String matchingType = KeywordMatchingType.PHRASE_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);
}
Also used : PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) KeywordPredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate) 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