use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching6.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type NOT_EQAUL_TO
*
* @throws Exception
*/
@Test
public void testIntegerMatching6() throws Exception {
// Prepare the query
int threshold = 43;
Attribute attribute = TestConstants.AGE_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(2));
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));
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching4.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type LESS_THAN_OR_EQAUL_TO
*
* @throws Exception
*/
@Test
public void testIntegerMatching4() throws Exception {
// Prepare the query
int threshold = 43;
Attribute attribute = TestConstants.AGE_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(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));
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching5.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type LESS_THAN
*
* @throws Exception
*/
@Test
public void testIntegerMatching5() throws Exception {
// Prepare the query
int threshold = 43;
Attribute attribute = TestConstants.AGE_ATTR;
String attributeName = attribute.getName();
ComparisonType matchingType = ComparisonType.LESS_THAN;
// Perform the query
List<Tuple> returnedResults = getQueryResults(attributeName, matchingType, threshold);
List<Tuple> expectedResults = new ArrayList<>();
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));
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class OneToNBroadcastConnectorTest method testTwoOutputsWithProjection.
/*
* This test connects Connector with Projection
*/
@Test
public void testTwoOutputsWithProjection() throws TexeraException {
IOperator sourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(PEOPLE_TABLE));
List<String> projectionFields = Arrays.asList(TestConstants.DESCRIPTION);
Schema projectionSchema = new Schema(TestConstants.DESCRIPTION_ATTR);
IField[] fields1 = { new TextField("Tall Angry") };
IField[] fields2 = { new TextField("Short Brown") };
IField[] fields3 = { new TextField("White Angry") };
IField[] fields4 = { new TextField("Lin Clooney is Short and lin clooney is Angry") };
IField[] fields5 = { new TextField("Tall Fair") };
IField[] fields6 = { new TextField("Short angry") };
Tuple tuple1 = new Tuple(projectionSchema, fields1);
Tuple tuple2 = new Tuple(projectionSchema, fields2);
Tuple tuple3 = new Tuple(projectionSchema, fields3);
Tuple tuple4 = new Tuple(projectionSchema, fields4);
Tuple tuple5 = new Tuple(projectionSchema, fields5);
Tuple tuple6 = new Tuple(projectionSchema, fields6);
List<Tuple> expectedResults = Arrays.asList(tuple1, tuple2, tuple3, tuple4, tuple5, tuple6);
ProjectionPredicate projectionPredicate = new ProjectionPredicate(projectionFields);
ProjectionOperator projection1 = new ProjectionOperator(projectionPredicate);
ProjectionOperator projection2 = new ProjectionOperator(projectionPredicate);
OneToNBroadcastConnector connector = new OneToNBroadcastConnector(2);
connector.setInputOperator(sourceOperator);
projection1.setInputOperator(connector.getOutputOperator(0));
projection2.setInputOperator(connector.getOutputOperator(1));
projection1.open();
List<Tuple> projection1Results = new ArrayList<>();
Tuple nextTuple = null;
while ((nextTuple = projection1.getNextTuple()) != null) {
projection1Results.add(nextTuple);
}
projection1.close();
projection2.open();
List<Tuple> projection2Results = new ArrayList<>();
nextTuple = null;
while ((nextTuple = projection2.getNextTuple()) != null) {
projection2Results.add(nextTuple);
}
projection2.close();
Assert.assertTrue(TestUtils.equals(expectedResults, projection1Results));
Assert.assertTrue(TestUtils.equals(expectedResults, projection2Results));
Assert.assertTrue(TestUtils.equals(projection1Results, projection2Results));
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class OneToNBroadcastConnectorTest method setUp.
@BeforeClass
public static void setUp() throws Exception {
RelationManager relationManager = RelationManager.getInstance();
// create the people table and write tuples
relationManager.createTable(PEOPLE_TABLE, TestUtils.getDefaultTestIndex().resolve(PEOPLE_TABLE), TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter peopleDataWriter = relationManager.getTableDataWriter(PEOPLE_TABLE);
peopleDataWriter.open();
for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
peopleDataWriter.insertTuple(tuple);
}
peopleDataWriter.close();
}
Aggregations