Search in sources :

Example 31 with RelationManager

use of edu.uci.ics.texera.storage.RelationManager 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 32 with RelationManager

use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.

the class NlpEntityTest method setUp.

@BeforeClass
public static void setUp() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    relationManager.createTable(ONE_SENTENCE_TABLE, TestUtils.getDefaultTestIndex().resolve(ONE_SENTENCE_TABLE), NlpEntityTestConstants.SCHEMA_ONE_SENTENCE, LuceneAnalyzerConstants.standardAnalyzerString());
    relationManager.createTable(TWO_SENTENCE_TABLE, TestUtils.getDefaultTestIndex().resolve(TWO_SENTENCE_TABLE), NlpEntityTestConstants.SCHEMA_TWO_SENTENCE, LuceneAnalyzerConstants.standardAnalyzerString());
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager) BeforeClass(org.junit.BeforeClass)

Example 33 with RelationManager

use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.

the class NlpEntityTest method cleanUp.

@AfterClass
public static void cleanUp() throws Exception {
    RelationManager relationManager = RelationManager.getInstance();
    relationManager.deleteTable(ONE_SENTENCE_TABLE);
    relationManager.deleteTable(TWO_SENTENCE_TABLE);
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager) AfterClass(org.junit.AfterClass)

Example 34 with RelationManager

use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.

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

Example 35 with RelationManager

use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.

the class RegexSplitOperatorTest method setUp.

@BeforeClass
public static void setUp() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    RelationManager.getInstance().deleteTable(REGEX_TABLE);
    relationManager = RelationManager.getInstance();
    relationManager.createTable(REGEX_TABLE, TestUtils.getDefaultTestIndex().resolve(REGEX_TABLE), TestConstantsRegexSplit.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
    DataWriter regexDataWriter = relationManager.getTableDataWriter(REGEX_TABLE);
    regexDataWriter.open();
    for (Tuple tuple : TestConstantsRegexSplit.constructSamplePeopleTuples()) {
        regexDataWriter.insertTuple(tuple);
    }
    regexDataWriter.close();
    // create the people table and write tuples in Chinese
    relationManager.createTable(CHINESE_TABLE, TestUtils.getDefaultTestIndex().resolve(CHINESE_TABLE), TestConstantsChinese.SCHEMA_PEOPLE, LuceneAnalyzerConstants.chineseAnalyzerString());
    DataWriter chineseDataWriter = relationManager.getTableDataWriter(CHINESE_TABLE);
    chineseDataWriter.open();
    for (Tuple tuple : TestConstantsChinese.getSamplePeopleTuples()) {
        chineseDataWriter.insertTuple(tuple);
    }
    chineseDataWriter.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) BeforeClass(org.junit.BeforeClass)

Aggregations

RelationManager (edu.uci.ics.texera.storage.RelationManager)35 Tuple (edu.uci.ics.texera.api.tuple.Tuple)19 DataWriter (edu.uci.ics.texera.storage.DataWriter)18 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)5 AfterClass (org.junit.AfterClass)5 ScanBasedSourceOperator (edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator)2 ScanSourcePredicate (edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate)2 File (java.io.File)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 StorageException (edu.uci.ics.texera.api.exception.StorageException)1 IntegerField (edu.uci.ics.texera.api.field.IntegerField)1 StringField (edu.uci.ics.texera.api.field.StringField)1 TextField (edu.uci.ics.texera.api.field.TextField)1 DictionaryPredicate (edu.uci.ics.texera.dataflow.dictionarymatcher.DictionaryPredicate)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Scanner (java.util.Scanner)1