Search in sources :

Example 76 with Tuple

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;
    }
}
Also used : KeywordSourcePredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordSourcePredicate) Span(edu.uci.ics.texera.api.span.Span) Tuple(edu.uci.ics.texera.api.tuple.Tuple) KeywordMatcherSourceOperator(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)

Example 77 with Tuple

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);
}
Also used : StringField(edu.uci.ics.texera.api.field.StringField) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple)

Example 78 with Tuple

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();
}
Also used : TupleSink(edu.uci.ics.texera.dataflow.sink.tuple.TupleSink) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Example 79 with Tuple

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);
    }
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) StorageException(edu.uci.ics.texera.api.exception.StorageException) Tuple(edu.uci.ics.texera.api.tuple.Tuple) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 80 with Tuple

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();
}
Also used : Tuple(edu.uci.ics.texera.api.tuple.Tuple) RelationManager(edu.uci.ics.texera.storage.RelationManager) DataWriter(edu.uci.ics.texera.storage.DataWriter)

Aggregations

Tuple (edu.uci.ics.texera.api.tuple.Tuple)332 ArrayList (java.util.ArrayList)191 Test (org.junit.Test)178 IField (edu.uci.ics.texera.api.field.IField)130 Schema (edu.uci.ics.texera.api.schema.Schema)126 Span (edu.uci.ics.texera.api.span.Span)100 StringField (edu.uci.ics.texera.api.field.StringField)96 Attribute (edu.uci.ics.texera.api.schema.Attribute)95 IntegerField (edu.uci.ics.texera.api.field.IntegerField)92 TextField (edu.uci.ics.texera.api.field.TextField)90 DoubleField (edu.uci.ics.texera.api.field.DoubleField)65 DateField (edu.uci.ics.texera.api.field.DateField)60 SimpleDateFormat (java.text.SimpleDateFormat)58 DataWriter (edu.uci.ics.texera.storage.DataWriter)33 Dictionary (edu.uci.ics.texera.dataflow.dictionarymatcher.Dictionary)30 ListField (edu.uci.ics.texera.api.field.ListField)28 TupleSourceOperator (edu.uci.ics.texera.dataflow.source.tuple.TupleSourceOperator)24 DataflowException (edu.uci.ics.texera.api.exception.DataflowException)23 ScanBasedSourceOperator (edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator)21 ScanSourcePredicate (edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate)21