Search in sources :

Example 6 with DataWriter

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

the class PlanStore method deletePlan.

/**
     * Removess a plan by given name from plan store.
     *
     * @param planName, the name of the plan.
     * @throws TextDBException
     */
public void deletePlan(String planName) throws TextDBException {
    Tuple plan = getPlan(planName);
    if (plan == null) {
        return;
    }
    IDField idField = (IDField) plan.getField(SchemaConstants._ID);
    DataWriter dataWriter = relationManager.getTableDataWriter(PlanStoreConstants.TABLE_NAME);
    dataWriter.open();
    dataWriter.deleteTupleByID(idField);
    dataWriter.close();
}
Also used : IDField(edu.uci.ics.textdb.api.field.IDField) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) DataWriter(edu.uci.ics.textdb.storage.DataWriter)

Example 7 with DataWriter

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

the class WordCountTest method setUp.

@BeforeClass
public static void setUp() throws TextDBException {
    cleanUp();
    RelationManager relationManager = RelationManager.getRelationManager();
    // Create the people table and write tuples
    relationManager.createTable(COUNT_TABLE, "../index/test_tables/" + COUNT_TABLE, TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
    DataWriter dataWriter = relationManager.getTableDataWriter(COUNT_TABLE);
    dataWriter.open();
    for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
        dataWriter.insertTuple(tuple);
    }
    dataWriter.close();
    expectedResult = computeExpectedResult(TestConstants.getSamplePeopleTuples(), TestConstants.DESCRIPTION, LuceneAnalyzerConstants.getStandardAnalyzer());
    relationManager.createTable(COUNT_CHINESE_TABLE, "../index/test_tables/" + COUNT_CHINESE_TABLE, TestConstantsChineseWordCount.SCHEMA_PEOPLE, LuceneAnalyzerConstants.chineseAnalyzerString());
    DataWriter dataWriterChinese = relationManager.getTableDataWriter(COUNT_CHINESE_TABLE);
    dataWriterChinese.open();
    for (Tuple tuple : TestConstantsChineseWordCount.getSamplePeopleTuples()) {
        dataWriterChinese.insertTuple(tuple);
    }
    dataWriterChinese.close();
    expectedResultChinese = computeExpectedResult(TestConstantsChineseWordCount.getSamplePeopleTuples(), TestConstantsChineseWordCount.DESCRIPTION, LuceneAnalyzerConstants.getLuceneAnalyzer(LuceneAnalyzerConstants.chineseAnalyzerString()));
}
Also used : Tuple(edu.uci.ics.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager) DataWriter(edu.uci.ics.textdb.storage.DataWriter) BeforeClass(org.junit.BeforeClass)

Example 8 with DataWriter

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

the class RegexSplitOperatorTest method setUp.

@BeforeClass
public static void setUp() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    RelationManager.getRelationManager().deleteTable(REGEX_TABLE);
    relationManager = RelationManager.getRelationManager();
    relationManager.createTable(REGEX_TABLE, "../index/test_tables/" + 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, "../index/test_tables/" + 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.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager) DataWriter(edu.uci.ics.textdb.storage.DataWriter) BeforeClass(org.junit.BeforeClass)

Example 9 with DataWriter

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

the class SamplerTest method setUp.

@BeforeClass
public static void setUp() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    // Create the people table and write tuples
    RelationManager.getRelationManager().deleteTable(SAMPLER_TABLE);
    relationManager.createTable(SAMPLER_TABLE, "../index/test_tables/" + 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.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager) DataWriter(edu.uci.ics.textdb.storage.DataWriter) BeforeClass(org.junit.BeforeClass)

Example 10 with DataWriter

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

the class ScanBasedSourceOperatorTest method setUp.

@BeforeClass
public static void setUp() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    // create the people table and write tuples
    relationManager.createTable(PEOPLE_TABLE, "../index/test_tables/" + 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.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager) DataWriter(edu.uci.ics.textdb.storage.DataWriter) BeforeClass(org.junit.BeforeClass)

Aggregations

DataWriter (edu.uci.ics.textdb.storage.DataWriter)34 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)31 RelationManager (edu.uci.ics.textdb.storage.RelationManager)18 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 BeforeClass (org.junit.BeforeClass)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 StorageException (edu.uci.ics.textdb.api.exception.StorageException)3 IDField (edu.uci.ics.textdb.api.field.IDField)3 StringField (edu.uci.ics.textdb.api.field.StringField)3 IOException (java.io.IOException)3 File (java.io.File)2 TextDBException (edu.uci.ics.textdb.api.exception.TextDBException)1 IField (edu.uci.ics.textdb.api.field.IField)1 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)1 TextField (edu.uci.ics.textdb.api.field.TextField)1 BufferedReader (java.io.BufferedReader)1 ParseException (java.text.ParseException)1 Scanner (java.util.Scanner)1