Search in sources :

Example 1 with KeywordPredicate

use of edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate 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 2 with KeywordPredicate

use of edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate 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 3 with KeywordPredicate

use of edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate 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);
}
Also used : PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) KeywordPredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Example 4 with KeywordPredicate

use of edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate 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);
}
Also used : PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) KeywordPredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Example 5 with KeywordPredicate

use of edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate 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)

Aggregations

KeywordPredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate)8 Test (org.junit.Test)7 PredicateBase (edu.uci.ics.texera.dataflow.common.PredicateBase)6 SelectStatement (edu.uci.ics.texera.textql.statements.SelectStatement)3 ExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate)3 KeywordExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate)3 ProjectPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate)2 KeywordSourcePredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordSourcePredicate)1 ProjectionPredicate (edu.uci.ics.texera.dataflow.projection.ProjectionPredicate)1 ProjectAllFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate)1 ProjectSomeFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate)1