Search in sources :

Example 16 with ScanBasedSourceOperator

use of edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class SamplerTest method containedInSamplerTable.

/*
     * To test if all the sampled tuples are in the sampler table.
     */
public static boolean containedInSamplerTable(List<Tuple> sampleList) throws TexeraException {
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(SAMPLER_TABLE));
    scanSource.open();
    Tuple nextTuple = null;
    List<Tuple> returnedTuples = new ArrayList<Tuple>();
    while ((nextTuple = scanSource.getNextTuple()) != null) {
        returnedTuples.add(nextTuple);
    }
    scanSource.close();
    boolean contains = TestUtils.containsAll(returnedTuples, sampleList);
    return contains;
}
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)

Example 17 with ScanBasedSourceOperator

use of edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class NlpExtractorPerformanceTest method matchNLP.

/*
     * This function does match based on tokenType
     */
public static void matchNLP(String tableName, NlpEntityType tokenType) throws Exception {
    List<String> attributeNames = Arrays.asList(MedlineIndexWriter.ABSTRACT);
    ISourceOperator sourceOperator = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(tokenType, attributeNames, SchemaConstants.SPAN_LIST);
    NlpEntityOperator nlpEntityOperator = new NlpEntityOperator(nlpEntityPredicate);
    nlpEntityOperator.setInputOperator(sourceOperator);
    long startMatchTime = System.currentTimeMillis();
    nlpEntityOperator.open();
    Tuple nextTuple = null;
    int counter = 0;
    while ((nextTuple = nlpEntityOperator.getNextTuple()) != null) {
        ListField<Span> spanListField = nextTuple.getField(SchemaConstants.SPAN_LIST);
        List<Span> spanList = spanListField.getValue();
        counter += spanList.size();
    }
    nlpEntityOperator.close();
    long endMatchTime = System.currentTimeMillis();
    double matchTime = (endMatchTime - startMatchTime) / 1000.0;
    totalMatchingTime += matchTime;
    totalResults += counter;
}
Also used : NlpEntityPredicate(edu.uci.ics.texera.dataflow.nlp.entity.NlpEntityPredicate) Span(edu.uci.ics.texera.api.span.Span) ScanBasedSourceOperator(edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator) ISourceOperator(edu.uci.ics.texera.api.dataflow.ISourceOperator) NlpEntityOperator(edu.uci.ics.texera.dataflow.nlp.entity.NlpEntityOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.texera.api.tuple.Tuple)

Example 18 with ScanBasedSourceOperator

use of edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class KeywordTestHelper method getScanSourceResults.

public static List<Tuple> getScanSourceResults(String tableName, String keywordQuery, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    KeywordPredicate keywordPredicate = new KeywordPredicate(keywordQuery, attributeNames, relationManager.getTableAnalyzerString(tableName), matchingType, RESULTS);
    KeywordMatcher keywordMatcher = new KeywordMatcher(keywordPredicate);
    keywordMatcher.setLimit(limit);
    keywordMatcher.setOffset(offset);
    keywordMatcher.setInputOperator(scanSource);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    keywordMatcher.open();
    while ((tuple = keywordMatcher.getNextTuple()) != null) {
        results.add(tuple);
    }
    keywordMatcher.close();
    return results;
}
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) RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 19 with ScanBasedSourceOperator

use of edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class NlpEntityTest method getQueryResults.

public List<Tuple> getQueryResults(String tableName, List<String> attributeNames, NlpEntityType nlpEntityType, int limit, int offset) throws Exception {
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    NlpEntityPredicate nlpEntityPredicate = new NlpEntityPredicate(nlpEntityType, attributeNames, RESULTS);
    NlpEntityOperator nlpEntityOperator = new NlpEntityOperator(nlpEntityPredicate);
    nlpEntityOperator.setInputOperator(scanSource);
    nlpEntityOperator.setLimit(limit);
    nlpEntityOperator.setOffset(offset);
    Tuple nextTuple = null;
    List<Tuple> results = new ArrayList<Tuple>();
    nlpEntityOperator.open();
    while ((nextTuple = nlpEntityOperator.getNextTuple()) != null) {
        results.add(nextTuple);
    }
    nlpEntityOperator.close();
    return results;
}
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)

Example 20 with ScanBasedSourceOperator

use of edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator in project textdb by TextDB.

the class ProjectionOperatorTest method testProjection2.

@Test
public void testProjection2() throws Exception {
    List<String> projectionFields = Arrays.asList(TestConstants.FIRST_NAME, TestConstants.DESCRIPTION);
    Schema projectionSchema = new Schema(TestConstants.FIRST_NAME_ATTR, TestConstants.DESCRIPTION_ATTR);
    IField[] fields1 = { new StringField("bruce"), new TextField("Tall Angry") };
    IField[] fields2 = { new StringField("tom hanks"), new TextField("Short Brown") };
    IField[] fields3 = { new StringField("brad lie angelina"), new TextField("White Angry") };
    IField[] fields4 = { new StringField("george lin lin"), new TextField("Lin Clooney is Short and lin clooney is Angry") };
    IField[] fields5 = { new StringField("christian john wayne"), new TextField("Tall Fair") };
    IField[] fields6 = { new StringField("Mary brown"), 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);
    List<Tuple> returnedResults = getProjectionResults(new ScanBasedSourceOperator(new ScanSourcePredicate(PEOPLE_TABLE)), projectionFields);
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Schema(edu.uci.ics.texera.api.schema.Schema) StringField(edu.uci.ics.texera.api.field.StringField) TextField(edu.uci.ics.texera.api.field.TextField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple) ScanBasedSourceOperator(edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Test(org.junit.Test)

Aggregations

ScanBasedSourceOperator (edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator)24 ScanSourcePredicate (edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate)24 Tuple (edu.uci.ics.texera.api.tuple.Tuple)21 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)8 IField (edu.uci.ics.texera.api.field.IField)3 TextField (edu.uci.ics.texera.api.field.TextField)3 Schema (edu.uci.ics.texera.api.schema.Schema)3 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)2 RelationManager (edu.uci.ics.texera.storage.RelationManager)2 ISourceOperator (edu.uci.ics.texera.api.dataflow.ISourceOperator)1 DataflowException (edu.uci.ics.texera.api.exception.DataflowException)1 StringField (edu.uci.ics.texera.api.field.StringField)1 Span (edu.uci.ics.texera.api.span.Span)1 DictionaryPredicate (edu.uci.ics.texera.dataflow.dictionarymatcher.DictionaryPredicate)1 FuzzyTokenPredicate (edu.uci.ics.texera.dataflow.fuzzytokenmatcher.FuzzyTokenPredicate)1 KeywordMatcherSourceOperator (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)1 KeywordSourcePredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordSourcePredicate)1 NlpEntityOperator (edu.uci.ics.texera.dataflow.nlp.entity.NlpEntityOperator)1 NlpEntityPredicate (edu.uci.ics.texera.dataflow.nlp.entity.NlpEntityPredicate)1