Search in sources :

Example 1 with Attribute

use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.

the class ComparableMatcherTest method testDoubleMatching4.

/**
 * Verifies the behavior of ComparableMatcher<Double> with matching type GREATER_THAN_OR_EQAUL_TO
 *
 * @throws Exception
 */
@Test
public void testDoubleMatching4() throws Exception {
    // Prepare the query
    double threshold = 5.95;
    Attribute attribute = TestConstants.HEIGHT_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(1));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(2));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(3));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(4));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(5));
    // 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 2 with Attribute

use of edu.uci.ics.texera.api.schema.Attribute in project textdb by TextDB.

the class ComparableMatcherTest method testDoubleMatching6.

/**
 * Verifies the behavior of ComparableMatcher<Double> with matching type NOT_EQAUL_TO
 *
 * @throws Exception
 */
@Test
public void testDoubleMatching6() throws Exception {
    // Prepare the query
    double threshold = 6.10;
    Attribute attribute = TestConstants.HEIGHT_ATTR;
    String attributeName = attribute.getName();
    ComparisonType matchingType = ComparisonType.NOT_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));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(3));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(4));
    expectedResults.add(TestConstants.getSamplePeopleTuples().get(5));
    // 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 3 with Attribute

use of edu.uci.ics.texera.api.schema.Attribute 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 4 with Attribute

use of edu.uci.ics.texera.api.schema.Attribute 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 5 with Attribute

use of edu.uci.ics.texera.api.schema.Attribute 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

Attribute (edu.uci.ics.texera.api.schema.Attribute)98 Test (org.junit.Test)81 Tuple (edu.uci.ics.texera.api.tuple.Tuple)78 ArrayList (java.util.ArrayList)76 Schema (edu.uci.ics.texera.api.schema.Schema)75 IField (edu.uci.ics.texera.api.field.IField)60 StringField (edu.uci.ics.texera.api.field.StringField)56 TextField (edu.uci.ics.texera.api.field.TextField)56 IntegerField (edu.uci.ics.texera.api.field.IntegerField)54 DoubleField (edu.uci.ics.texera.api.field.DoubleField)53 Span (edu.uci.ics.texera.api.span.Span)51 DateField (edu.uci.ics.texera.api.field.DateField)50 SimpleDateFormat (java.text.SimpleDateFormat)47 Dictionary (edu.uci.ics.texera.dataflow.dictionarymatcher.Dictionary)28 AttributeType (edu.uci.ics.texera.api.schema.AttributeType)9 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)8 DataflowException (edu.uci.ics.texera.api.exception.DataflowException)6 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)5