Search in sources :

Example 1 with RelationManager

use of edu.uci.ics.textdb.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.getRelationManager();
    DataWriter outerDataWriter = relationManager.getTableDataWriter(tableName);
    outerDataWriter.open();
    for (Tuple tuple : tuples) {
        outerDataWriter.insertTuple(tuple);
    }
    outerDataWriter.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)

Example 2 with RelationManager

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

the class DictionaryMatcherTestHelper method writeTestTables.

public static void writeTestTables() 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();
    // 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)

Example 3 with RelationManager

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

the class DictionaryMatcherTestHelper method getDictionarySourceResults.

/**
     * Get the results from the DictionarySourceOperator 
     *   (which performs a index-based lookup for each keyword in the dictionary)
     * 
     * @param tableName
     * @param dictionary
     * @param attributeNames
     * @param matchingType
     * @param limit
     * @param offset
     * @return
     * @throws TextDBException
     */
public static List<Tuple> getDictionarySourceResults(String tableName, Dictionary dictionary, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    String luceneAnalyzerStr = relationManager.getTableAnalyzerString(tableName);
    DictionarySourcePredicate dictiaonrySourcePredicate = new DictionarySourcePredicate(dictionary, attributeNames, luceneAnalyzerStr, matchingType, tableName, RESULTS);
    DictionaryMatcherSourceOperator dictionarySource = new DictionaryMatcherSourceOperator(dictiaonrySourcePredicate);
    dictionarySource.setLimit(limit);
    dictionarySource.setOffset(offset);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    dictionarySource.open();
    while ((tuple = dictionarySource.getNextTuple()) != null) {
        results.add(tuple);
    }
    dictionarySource.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) Tuple(edu.uci.ics.textdb.api.tuple.Tuple) RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Example 4 with RelationManager

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

the class FuzzyTokenMatcherTestHelper method deleteTestTables.

/*
     * Deletes the test table(s)
     */
public static void deleteTestTables() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    relationManager.deleteTable(PEOPLE_TABLE);
}
Also used : RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Example 5 with RelationManager

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

the class JoinTestHelper method createTestTables.

public static void createTestTables() throws TextDBException {
    RelationManager relationManager = RelationManager.getRelationManager();
    // create the book table
    relationManager.createTable(BOOK_TABLE, "../index/test_tables/" + 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, "../index/test_tables/" + NEWS_TABLE_OUTER, JoinTestConstants.NEWS_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
    relationManager.createTable(NEWS_TABLE_INNER, "../index/test_tables/" + NEWS_TABLE_INNER, JoinTestConstants.NEWS_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
}
Also used : RelationManager(edu.uci.ics.textdb.storage.RelationManager)

Aggregations

RelationManager (edu.uci.ics.textdb.storage.RelationManager)35 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)19 DataWriter (edu.uci.ics.textdb.storage.DataWriter)18 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)5 AfterClass (org.junit.AfterClass)5 ScanBasedSourceOperator (edu.uci.ics.textdb.exp.source.scan.ScanBasedSourceOperator)2 ScanSourcePredicate (edu.uci.ics.textdb.exp.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.textdb.api.exception.StorageException)1 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)1 StringField (edu.uci.ics.textdb.api.field.StringField)1 TextField (edu.uci.ics.textdb.api.field.TextField)1 DictionaryPredicate (edu.uci.ics.textdb.exp.dictionarymatcher.DictionaryPredicate)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Scanner (java.util.Scanner)1