Search in sources :

Example 26 with RelationManager

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

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

the class JoinTestHelper method createTestTables.

public static void createTestTables() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    // create the book table
    relationManager.createTable(BOOK_TABLE, TestUtils.getDefaultTestIndex().resolve(BOOK_TABLE), JoinTestConstants.BOOK_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
    // data for the book table are written in each test cases
    // create the news table
    relationManager.createTable(NEWS_TABLE_OUTER, TestUtils.getDefaultTestIndex().resolve(NEWS_TABLE_OUTER), JoinTestConstants.NEWS_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
    relationManager.createTable(NEWS_TABLE_INNER, TestUtils.getDefaultTestIndex().resolve(NEWS_TABLE_INNER), JoinTestConstants.NEWS_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 28 with RelationManager

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

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

the class WordCountTest method setUp.

@BeforeClass
public static void setUp() throws TexeraException {
    cleanUp();
    RelationManager relationManager = RelationManager.getInstance();
    // Create the people table and write tuples
    relationManager.createTable(COUNT_TABLE, TestUtils.getDefaultTestIndex().resolve(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, TestUtils.getDefaultTestIndex().resolve(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.texera.api.tuple.Tuple) RelationManager(edu.uci.ics.texera.storage.RelationManager) DataWriter(edu.uci.ics.texera.storage.DataWriter) BeforeClass(org.junit.BeforeClass)

Example 30 with RelationManager

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

the class PerfTestUtils method writeIndex.

/**
 * Writes a data file into an index
 *
 * @param fileName,
 *            data file
 * @param luceneAnalyzer
 * @param indexType,
 *            indicates the types of index, trigram or standard
 * @throws Exception
 */
public static void writeIndex(String fileName, Analyzer luceneAnalyzer, String indexType) throws Exception {
    RelationManager relationManager = RelationManager.getInstance();
    String tableName = fileName.replace(".txt", "");
    if (indexType.equalsIgnoreCase("trigram")) {
        tableName = tableName + "_trigram";
        relationManager.deleteTable(tableName);
        relationManager.createTable(tableName, getTrigramIndexPath(tableName), MedlineIndexWriter.SCHEMA_MEDLINE, LuceneAnalyzerConstants.nGramAnalyzerString(3));
        MedlineIndexWriter.writeMedlineIndex(Paths.get(fileFolder, fileName), tableName);
    } else if (indexType.equalsIgnoreCase("standard")) {
        relationManager.deleteTable(tableName);
        relationManager.createTable(tableName, getIndexPath(tableName), MedlineIndexWriter.SCHEMA_MEDLINE, LuceneAnalyzerConstants.standardAnalyzerString());
        MedlineIndexWriter.writeMedlineIndex(Paths.get(fileFolder, fileName), tableName);
    } else {
        System.out.println("Index is not successfully written.");
        System.out.println("IndexType has to be either \"standard\" or \"trigram\"  ");
    }
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager)

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