Search in sources :

Example 6 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, Tuple... tuples) throws StorageException {
    RelationManager relationManager = RelationManager.getInstance();
    DataWriter tableDataWriter = relationManager.getTableDataWriter(tableName);
    tableDataWriter.open();
    for (Tuple tuple : Arrays.asList(tuples)) {
        tableDataWriter.insertTuple(tuple);
    }
    tableDataWriter.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 7 with RelationManager

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

the class JoinTestHelper method deleteTestTables.

/**
 * Deletes all test tables
 * @throws TexeraException
 */
public static void deleteTestTables() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    relationManager.deleteTable(BOOK_TABLE);
    relationManager.deleteTable(NEWS_TABLE_OUTER);
    relationManager.deleteTable(NEWS_TABLE_INNER);
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 8 with RelationManager

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

the class KeywordTestHelper method deleteTestTables.

public static void deleteTestTables() throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    relationManager.deleteTable(PEOPLE_TABLE);
    relationManager.deleteTable(MEDLINE_TABLE);
    relationManager.deleteTable(CHINESE_TABLE);
}
Also used : RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 9 with RelationManager

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

the class KeywordTestHelper method getKeywordSourceResults.

public static List<Tuple> getKeywordSourceResults(String tableName, String keywordQuery, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    KeywordSourcePredicate keywordSourcePredicate = new KeywordSourcePredicate(keywordQuery, attributeNames, relationManager.getTableAnalyzerString(tableName), matchingType, tableName, RESULTS);
    KeywordMatcherSourceOperator keywordSource = new KeywordMatcherSourceOperator(keywordSourcePredicate);
    keywordSource.setLimit(limit);
    keywordSource.setOffset(offset);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    keywordSource.open();
    while ((tuple = keywordSource.getNextTuple()) != null) {
        results.add(tuple);
    }
    keywordSource.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) Tuple(edu.uci.ics.texera.api.tuple.Tuple) RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 10 with RelationManager

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

the class KeywordTestHelper method writeTestTables.

public static void writeTestTables() throws TexeraException {
    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();
    // create the medline table and write tuples
    relationManager.createTable(MEDLINE_TABLE, TestUtils.getDefaultTestIndex().resolve(MEDLINE_TABLE), keywordTestConstants.SCHEMA_MEDLINE, LuceneAnalyzerConstants.standardAnalyzerString());
    DataWriter medDataWriter = relationManager.getTableDataWriter(MEDLINE_TABLE);
    medDataWriter.open();
    for (Tuple tuple : keywordTestConstants.getSampleMedlineRecord()) {
        medDataWriter.insertTuple(tuple);
    }
    medDataWriter.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)

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