use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class KeywordMatcherPerformanceTest method match.
/*
* This function does match for a list of queries
*/
public static void match(ArrayList<String> queryList, KeywordMatchingType opType, String luceneAnalyzerStr, String tableName) throws TexeraException, IOException {
String[] attributeNames = new String[] { MedlineIndexWriter.ABSTRACT };
for (String query : queryList) {
KeywordSourcePredicate predicate = new KeywordSourcePredicate(query, Arrays.asList(attributeNames), luceneAnalyzerStr, opType, tableName, SchemaConstants.SPAN_LIST);
KeywordMatcherSourceOperator keywordSource = new KeywordMatcherSourceOperator(predicate);
long startMatchTime = System.currentTimeMillis();
keywordSource.open();
int counter = 0;
Tuple nextTuple = null;
while ((nextTuple = keywordSource.getNextTuple()) != null) {
ListField<Span> spanListField = nextTuple.getField(SchemaConstants.SPAN_LIST);
List<Span> spanList = spanListField.getValue();
counter += spanList.size();
}
keywordSource.close();
long endMatchTime = System.currentTimeMillis();
double matchTime = (endMatchTime - startMatchTime) / 1000.0;
timeResults.add(Double.parseDouble(String.format("%.4f", matchTime)));
totalResultCount += counter;
}
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class LineChartSinkTestConstants method getResultTuples.
public static List<Tuple> getResultTuples() {
IField[] fields1 = { new StringField("Tom"), new IntegerField(90) };
IField[] fields2 = { new StringField("Jerry"), new IntegerField(80) };
IField[] fields3 = { new StringField("Bob"), new IntegerField(70) };
Tuple tuple1 = new Tuple(BAR_RESULT_SCHEMA, fields1);
Tuple tuple2 = new Tuple(BAR_RESULT_SCHEMA, fields2);
Tuple tuple3 = new Tuple(BAR_RESULT_SCHEMA, fields3);
return Arrays.asList(tuple1, tuple2, tuple3);
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class TupleSinkTest method testGetNextTuple.
@Test
public void testGetNextTuple() throws Exception {
TupleSink tupleSink = new TupleSink();
tupleSink.setInputOperator(inputOperator);
tupleSink.open();
Tuple tuple = tupleSink.getNextTuple();
Assert.assertEquals("test1", tuple.getField("content").getValue());
tupleSink.close();
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class PlanStoreTest method assertCorrectPlanExists.
/**
* This is a helper function that checks whether the plan corresponding to the plan name corresponds to the
* logical plan JSON string that is fed to this function
* @param planName - Name of the plan name to check with
* @param logicalPlanJson - Expected LogicalPlan JSON string
* @throws TexeraException
*/
public static void assertCorrectPlanExists(String planName, String logicalPlanJson) throws TexeraException {
Tuple res = planStore.getPlan(planName);
Assert.assertNotNull(res);
try {
String returnedPlan = res.getField(PlanStoreConstants.LOGICAL_PLAN_JSON).getValue().toString();
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readValue(logicalPlanJson, JsonNode.class);
JsonNode returnedJsonNode = objectMapper.readValue(returnedPlan, JsonNode.class);
Assert.assertEquals(jsonNode, returnedJsonNode);
} catch (IOException e) {
throw new StorageException(e);
}
}
use of edu.uci.ics.texera.api.tuple.Tuple in project textdb by TextDB.
the class RegexMatcherTestHelper method writeTestTables.
public static void writeTestTables() throws TexeraException {
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();
// create the corporation table and write tuples
relationManager.createTable(CORP_TABLE, TestUtils.getDefaultTestIndex().resolve(CORP_TABLE), RegexTestConstantsCorp.SCHEMA_CORP, LuceneAnalyzerConstants.nGramAnalyzerString(3));
DataWriter corpDataWriter = relationManager.getTableDataWriter(CORP_TABLE);
corpDataWriter.open();
for (Tuple tuple : RegexTestConstantsCorp.getSampleCorpTuples()) {
corpDataWriter.insertTuple(tuple);
}
corpDataWriter.close();
// create the staff table
relationManager.createTable(STAFF_TABLE, TestUtils.getDefaultTestIndex().resolve(STAFF_TABLE), RegexTestConstantStaff.SCHEMA_STAFF, LuceneAnalyzerConstants.nGramAnalyzerString(3));
DataWriter staffDataWriter = relationManager.getTableDataWriter(STAFF_TABLE);
staffDataWriter.open();
for (Tuple tuple : RegexTestConstantStaff.getSampleStaffTuples()) {
staffDataWriter.insertTuple(tuple);
}
staffDataWriter.close();
// create the text table
relationManager.createTable(TEXT_TABLE, TestUtils.getDefaultTestIndex().resolve(TEXT_TABLE), RegexTestConstantsText.SCHEMA_TEXT, LuceneAnalyzerConstants.nGramAnalyzerString(3));
DataWriter textDataWriter = relationManager.getTableDataWriter(TEXT_TABLE);
textDataWriter.open();
for (Tuple tuple : RegexTestConstantsText.getSampleTextTuples()) {
textDataWriter.insertTuple(tuple);
}
textDataWriter.close();
}
Aggregations