Search in sources :

Example 6 with Tuple

use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.

the class ComparableMatcherTest method testDoubleMatching3.

/**
 * Verifies the behavior of ComparableMatcher<Double> with matching type LESS_THAN_OR_EQUAL_TO
 *
 * @throws Exception
 */
@Test
public void testDoubleMatching3() throws Exception {
    // Prepare the query
    double threshold = 5.95;
    Attribute attribute = TestConstants.HEIGHT_ATTR;
    String attributeName = attribute.getName();
    ComparisonType matchingType = ComparisonType.LESS_THAN_OR_EQUAL_TO;
    // Perform the query
    List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
    List<Tuple> expectedResults = new ArrayList<>();
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(0));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(1));
    // check the results
    Assert.assertEquals(expectedResults.size(), returnedResults.size());
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) ArrayList(java.util.ArrayList) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 7 with Tuple

use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.

the class ComparableMatcherTest method testDateTime1.

@Test
public void testDateTime1() throws Exception {
    // Prepare the query
    String dateCompared = "1970-01-01T11:11:11";
    String attributeName = TestConstants.DATE_OF_BIRTH_ATTR.getName();
    ComparisonType matchingType = ComparisonType.EQUAL_TO;
    ComparablePredicate comparablePredicate = new ComparablePredicate(attributeName, matchingType, dateCompared);
    ComparableMatcher comparableMatcher = new ComparableMatcher(comparablePredicate);
    setDefaultMatcherConfig(comparableMatcher);
    // Perform the query
    ScanBasedSourceOperator sourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(PEOPLE_TABLE_2));
    comparableMatcher.setInputOperator(sourceOperator);
    comparableMatcher.open();
    comparableMatcher.setLimit(Integer.MAX_VALUE);
    comparableMatcher.setOffset(0);
    List<Tuple> returnedResults = new ArrayList<>();
    Tuple nextTuple = null;
    while ((nextTuple = comparableMatcher.getNextTuple()) != null) {
        returnedResults.add(nextTuple);
    }
    comparableMatcher.close();
    List<Tuple> expectedResults = new ArrayList<>();
    expectedResults.add(TestConstantsRegexSplit.constructSamplePeopleTuples().get(0));
    // check the results
    Assert.assertEquals(expectedResults.size(), returnedResults.size());
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : ArrayList(java.util.ArrayList) ScanBasedSourceOperator(edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 8 with Tuple

use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.

the class ComparableMatcherTest method testDoubleMatching5.

/**
 * Verifies the behavior of ComparableMatcher<Double> with matching type EQUAL_TO
 *
 * @throws Exception
 */
@Test
public void testDoubleMatching5() throws Exception {
    // Prepare the query
    double threshold = 6.10;
    Attribute attribute = TestConstants.HEIGHT_ATTR;
    String attributeName = attribute.getName();
    ComparisonType matchingType = ComparisonType.EQUAL_TO;
    // Perform the query
    List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
    List<Tuple> expectedResults = new ArrayList<>();
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(2));
    // check the results
    Assert.assertEquals(expectedResults.size(), returnedResults.size());
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) ArrayList(java.util.ArrayList) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 9 with Tuple

use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.

the class ComparableMatcherTest method testDateTime2.

@Test
public void testDateTime2() throws Exception {
    // Prepare the query
    String dateCompared = "1970-01-01T11:11:12";
    String attributeName = TestConstants.DATE_OF_BIRTH_ATTR.getName();
    ComparisonType matchingType = ComparisonType.LESS_THAN;
    ComparablePredicate comparablePredicate = new ComparablePredicate(attributeName, matchingType, dateCompared);
    ComparableMatcher comparableMatcher = new ComparableMatcher(comparablePredicate);
    setDefaultMatcherConfig(comparableMatcher);
    // Perform the query
    ScanBasedSourceOperator sourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(PEOPLE_TABLE_2));
    comparableMatcher.setInputOperator(sourceOperator);
    comparableMatcher.open();
    comparableMatcher.setLimit(Integer.MAX_VALUE);
    comparableMatcher.setOffset(0);
    List<Tuple> returnedResults = new ArrayList<>();
    Tuple nextTuple = null;
    while ((nextTuple = comparableMatcher.getNextTuple()) != null) {
        returnedResults.add(nextTuple);
    }
    comparableMatcher.close();
    List<Tuple> expectedResults = new ArrayList<>();
    expectedResults.add(TestConstantsRegexSplit.constructSamplePeopleTuples().get(0));
    // check the results
    Assert.assertEquals(expectedResults.size(), returnedResults.size());
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : ArrayList(java.util.ArrayList) ScanBasedSourceOperator(edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 10 with Tuple

use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.

the class ComparableMatcherTest method testIntegerMatching3.

/**
 * Verifies the behavior of ComparableMatcher<Integer> with matching type GREATER_THAN_OR_EQAUL_TO
 *
 * @throws Exception
 */
@Test
public void testIntegerMatching3() throws Exception {
    // Prepare the query
    int threshold = 45;
    Attribute attribute = TestConstants.AGE_ATTR;
    String attributeName = attribute.getName();
    ComparisonType matchingType = ComparisonType.GREATER_THAN_OR_EQUAL_TO;
    // Perform the query
    List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
    List<Tuple> expectedResults = new ArrayList<>();
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(0));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(1));
    // check the results
    Assert.assertEquals(expectedResults.size(), returnedResults.size());
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) ArrayList(java.util.ArrayList) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Aggregations

Tuple (edu.uci.ics.texera.api.tuple.Tuple)280 ArrayList (java.util.ArrayList)167 Test (org.junit.Test)158 Schema (edu.uci.ics.texera.api.schema.Schema)108 IField (edu.uci.ics.texera.api.field.IField)106 Span (edu.uci.ics.texera.api.span.Span)99 TextField (edu.uci.ics.texera.api.field.TextField)90 StringField (edu.uci.ics.texera.api.field.StringField)83 IntegerField (edu.uci.ics.texera.api.field.IntegerField)80 Attribute (edu.uci.ics.texera.api.schema.Attribute)75 DoubleField (edu.uci.ics.texera.api.field.DoubleField)59 DateField (edu.uci.ics.texera.api.field.DateField)55 SimpleDateFormat (java.text.SimpleDateFormat)53 DataWriter (edu.uci.ics.texera.storage.DataWriter)32 Dictionary (edu.uci.ics.texera.dataflow.dictionarymatcher.Dictionary)30 ListField (edu.uci.ics.texera.api.field.ListField)27 ScanBasedSourceOperator (edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator)21 ScanSourcePredicate (edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate)21 KeywordMatcherSourceOperator (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)20 RelationManager (edu.uci.ics.texera.storage.RelationManager)19