Search in sources :

Example 6 with KeywordExtractPredicate

use of edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate in project textdb by TextDB.

the class CreateViewStatementTest method testConstructorAndGetters.

/**
 * Test the class constructor and the getter methods.
 * Call the constructor of CreateViewStatement and test if
 * the returned value by the getter is the same.
 */
@Test
public void testConstructorAndGetters() {
    Statement subStatement;
    ProjectPredicate projectPredicate;
    ExtractPredicate extractPredicate;
    CreateViewStatement createViewStatement;
    // Tests for the id attribute
    createViewStatement = new CreateViewStatement(null, null);
    Assert.assertEquals(createViewStatement.getId(), null);
    createViewStatement = new CreateViewStatement("statementId", null);
    Assert.assertEquals(createViewStatement.getId(), "statementId");
    createViewStatement = new CreateViewStatement("id6", null);
    Assert.assertEquals(createViewStatement.getId(), "id6");
    createViewStatement = new CreateViewStatement("_sid12", null);
    Assert.assertEquals(createViewStatement.getId(), "_sid12");
    // Tests for the subStatement attribute
    createViewStatement = new CreateViewStatement("statementId", null);
    Assert.assertEquals(createViewStatement.getSubStatement(), null);
    subStatement = new SelectStatement("substatementId0", null, null, "source", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    subStatement = new SelectStatement("substatementId1", null, null, "table", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    projectPredicate = new ProjectAllFieldsPredicate();
    subStatement = new SelectStatement("substatementId2", projectPredicate, null, "from", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("at1", "at0"));
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "keyword", KeywordMatchingType.CONJUNCTION_INDEXBASED.toString());
    subStatement = new SelectStatement("substatementIdX", projectPredicate, extractPredicate, "t", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
}
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) 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) ProjectAllFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Example 7 with KeywordExtractPredicate

use of edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate in project textdb by TextDB.

the class CreateViewStatementTest method testGettersAndGetters.

/**
 * Test the setter methods and the getter methods.
 * Call the setter of CreateViewStatement and test if the
 * returned value by the getter is the same.
 */
@Test
public void testGettersAndGetters() {
    Statement subStatement;
    ProjectPredicate projectPredicate;
    ExtractPredicate extractPredicate;
    CreateViewStatement createViewStatement = new CreateViewStatement(null, null);
    // Tests for the id attribute
    createViewStatement.setId(null);
    Assert.assertEquals(createViewStatement.getId(), null);
    createViewStatement.setId("statementId4");
    Assert.assertEquals(createViewStatement.getId(), "statementId4");
    createViewStatement.setId("_sid0");
    Assert.assertEquals(createViewStatement.getId(), "_sid0");
    // Tests for the subStatement attribute
    createViewStatement.setSubStatement(null);
    Assert.assertEquals(createViewStatement.getSubStatement(), null);
    projectPredicate = new ProjectAllFieldsPredicate();
    subStatement = new SelectStatement("substatementId0", projectPredicate, null, "from", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    projectPredicate = new ProjectAllFieldsPredicate();
    subStatement = new SelectStatement("substatementId1", projectPredicate, null, "table", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("c", "d"));
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("f0", "f1"), "xxx", KeywordMatchingType.PHRASE_INDEXBASED.toString());
    subStatement = new SelectStatement("id", projectPredicate, extractPredicate, "source", null, null);
    createViewStatement.setSubStatement(subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
}
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) 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) ProjectAllFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Example 8 with KeywordExtractPredicate

use of edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate 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 9 with KeywordExtractPredicate

use of edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate 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 10 with KeywordExtractPredicate

use of edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate in project textdb by TextDB.

the class TextQLParserTest method testExtractPredicate.

/**
 * Test the extractPredicate method of the parser.
 * It should parse an extract predicate and return the expected ExtractPredicate object.
 * @throws ParseException if an unexpected ParseException is thrown
 */
@Test
public void testExtractPredicate() throws ParseException {
    String keywordMatchPredicate00 = " KEYWORDMATCH(g0, \"key1\") ";
    ExtractPredicate keywordMatchParameters00 = new KeywordExtractPredicate(Arrays.asList("g0"), "key1", null);
    Assert.assertEquals((new TextQLParser(string2InputStream(keywordMatchPredicate00))).extractKeywordMatchPredicate(), keywordMatchParameters00);
    String keywordMatchPredicate01 = " KEYWORDMATCH(g1, \"key2\", conjunction) ";
    ExtractPredicate keywordMatchParameters01 = new KeywordExtractPredicate(Arrays.asList("g1"), "key2", "conjunction");
    Assert.assertEquals((new TextQLParser(string2InputStream(keywordMatchPredicate01))).extractKeywordMatchPredicate(), keywordMatchParameters01);
    String keywordMatchPredicate04 = " KEYWORDMATCH([g4], \"key0\") ";
    ExtractPredicate keywordMatchParameters04 = new KeywordExtractPredicate(Arrays.asList("g4"), "key0", null);
    Assert.assertEquals((new TextQLParser(string2InputStream(keywordMatchPredicate04))).extractKeywordMatchPredicate(), keywordMatchParameters04);
    String keywordMatchPredicate06 = " KEYWORDMATCH([g6,g7,h8,i9], \"key\") ";
    ExtractPredicate keywordMatchParameters06 = new KeywordExtractPredicate(Arrays.asList("g6", "g7", "h8", "i9"), "key", null);
    Assert.assertEquals((new TextQLParser(string2InputStream(keywordMatchPredicate06))).extractKeywordMatchPredicate(), keywordMatchParameters06);
    String keywordMatchPredicate07 = " KEYWORDMATCH([g6,g7,h8,i9], \"key\", substring) ";
    ExtractPredicate keywordMatchParameters07 = new KeywordExtractPredicate(Arrays.asList("g6", "g7", "h8", "i9"), "key", "substring");
    Assert.assertEquals((new TextQLParser(string2InputStream(keywordMatchPredicate07))).extractKeywordMatchPredicate(), keywordMatchParameters07);
}
Also used : 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) TextQLParser(edu.uci.ics.texera.textql.languageparser.TextQLParser) Test(org.junit.Test)

Aggregations

ExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate)14 KeywordExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate)14 Test (org.junit.Test)14 SelectStatement (edu.uci.ics.texera.textql.statements.SelectStatement)12 ProjectPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate)11 ProjectSomeFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate)10 ProjectAllFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate)9 CreateViewStatement (edu.uci.ics.texera.textql.statements.CreateViewStatement)7 Statement (edu.uci.ics.texera.textql.statements.Statement)7 TextQLParser (edu.uci.ics.texera.textql.languageparser.TextQLParser)6 PredicateBase (edu.uci.ics.texera.dataflow.common.PredicateBase)4 KeywordPredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate)3 ProjectionPredicate (edu.uci.ics.texera.dataflow.projection.ProjectionPredicate)1 ParseException (edu.uci.ics.texera.textql.languageparser.ParseException)1 TokenMgrError (edu.uci.ics.texera.textql.languageparser.TokenMgrError)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 PrintStream (java.io.PrintStream)1