Search in sources :

Example 26 with DataWriter

use of edu.uci.ics.texera.storage.DataWriter 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)

Example 27 with DataWriter

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

the class SamplerTest method setUp.

@BeforeClass
public static void setUp() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    // Create the people table and write tuples
    RelationManager.getInstance().deleteTable(SAMPLER_TABLE);
    relationManager.createTable(SAMPLER_TABLE, TestUtils.getDefaultTestIndex().resolve(SAMPLER_TABLE), TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
    DataWriter dataWriter = relationManager.getTableDataWriter(SAMPLER_TABLE);
    dataWriter.open();
    indexSize = 0;
    for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
        dataWriter.insertTuple(tuple);
        indexSize++;
    }
    dataWriter.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 28 with DataWriter

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

the class JoinTestHelper method insertToTable.

public static void insertToTable(String tableName, List<Tuple> tuples) throws StorageException {
    RelationManager relationManager = RelationManager.getInstance();
    DataWriter outerDataWriter = relationManager.getTableDataWriter(tableName);
    outerDataWriter.open();
    for (Tuple tuple : tuples) {
        outerDataWriter.insertTuple(tuple);
    }
    outerDataWriter.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)

Example 29 with DataWriter

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

the class JoinTestHelper method clearTestTables.

/**
 * Clears the data of the inner and outer test tables.
 * @throws TexeraException
 */
public static void clearTestTables() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    DataWriter bookDataWriter = relationManager.getTableDataWriter(BOOK_TABLE);
    bookDataWriter.open();
    bookDataWriter.clearData();
    bookDataWriter.close();
    DataWriter innerNewsDataWriter = relationManager.getTableDataWriter(NEWS_TABLE_INNER);
    innerNewsDataWriter.open();
    innerNewsDataWriter.clearData();
    innerNewsDataWriter.close();
    DataWriter outerNewsDataWriter = relationManager.getTableDataWriter(NEWS_TABLE_OUTER);
    outerNewsDataWriter.open();
    outerNewsDataWriter.clearData();
    outerNewsDataWriter.close();
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager) DataWriter(edu.uci.ics.texera.storage.DataWriter)

Example 30 with DataWriter

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

the class NlpEntityTest method getNextTupleTest4.

/**
 * Scenario 4:Test getNextTuple with more than one span in the return list
 * and with different recognized classes and more than one fields in the
 * source tuple.
 * <p>
 * Sentence1: Microsoft, Google and Facebook are organizations. Sentence2:
 * Donald Trump and Barack Obama are persons. Search for all NE_ALL entity
 * types
 */
@Test
public void getNextTupleTest4() throws Exception {
    List<Tuple> data = NlpEntityTestConstants.getTest4Tuple();
    DataWriter twoSentenceDataWriter = RelationManager.getInstance().getTableDataWriter(TWO_SENTENCE_TABLE);
    twoSentenceDataWriter.open();
    for (Tuple tuple : data) {
        twoSentenceDataWriter.insertTuple(tuple);
    }
    twoSentenceDataWriter.close();
    String attribute1 = NlpEntityTestConstants.SENTENCE_ONE;
    String attribute2 = NlpEntityTestConstants.SENTENCE_TWO;
    List<String> attributeNames = new ArrayList<>();
    attributeNames.add(attribute1);
    attributeNames.add(attribute2);
    List<Tuple> returnedResults = getQueryResults(TWO_SENTENCE_TABLE, attributeNames, NlpEntityType.NE_ALL);
    List<Tuple> expectedResults = NlpEntityTestConstants.getTest4ResultTuples();
    boolean contains = TestUtils.equals(expectedResults, returnedResults);
    Assert.assertTrue(contains);
}
Also used : ArrayList(java.util.ArrayList) Tuple(edu.uci.ics.texera.api.tuple.Tuple) DataWriter(edu.uci.ics.texera.storage.DataWriter) Test(org.junit.Test)

Aggregations

DataWriter (edu.uci.ics.texera.storage.DataWriter)37 Tuple (edu.uci.ics.texera.api.tuple.Tuple)33 RelationManager (edu.uci.ics.texera.storage.RelationManager)19 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 BeforeClass (org.junit.BeforeClass)8 StorageException (edu.uci.ics.texera.api.exception.StorageException)3 IDField (edu.uci.ics.texera.api.field.IDField)3 StringField (edu.uci.ics.texera.api.field.StringField)3 IOException (java.io.IOException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Term (org.apache.lucene.index.Term)2 TermQuery (org.apache.lucene.search.TermQuery)2 TexeraException (edu.uci.ics.texera.api.exception.TexeraException)1 IField (edu.uci.ics.texera.api.field.IField)1 TupleSink (edu.uci.ics.texera.dataflow.sink.tuple.TupleSink)1 TupleSinkPredicate (edu.uci.ics.texera.dataflow.sink.tuple.TupleSinkPredicate)1 TwitterJsonConverter (edu.uci.ics.texera.dataflow.twitter.TwitterJsonConverter)1 TwitterJsonConverterPredicate (edu.uci.ics.texera.dataflow.twitter.TwitterJsonConverterPredicate)1