Search in sources :

Example 21 with RelationManager

use of edu.uci.ics.texera.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 TexeraException
 */
public static List<Tuple> getDictionarySourceResults(String tableName, Dictionary dictionary, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    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.texera.api.tuple.Tuple) RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 22 with RelationManager

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

the class DictionaryMatcherTestHelper method getScanSourceResults.

/**
 * Get the results from a DictionaryMatcher with a ScanSource Operator
 *   (which scans the table first and then feeds the data into the dictionary matcher)
 *
 * @param tableName
 * @param dictionary
 * @param attributeNames
 * @param matchingType
 * @param limit
 * @param offset
 * @return
 * @throws TexeraException
 */
public static List<Tuple> getScanSourceResults(String tableName, Dictionary dictionary, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TexeraException {
    RelationManager relationManager = RelationManager.getInstance();
    String luceneAnalyzerStr = relationManager.getTableAnalyzerString(tableName);
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    DictionaryPredicate dictiaonryPredicate = new DictionaryPredicate(dictionary, attributeNames, luceneAnalyzerStr, matchingType, RESULTS);
    DictionaryMatcher dictionaryMatcher = new DictionaryMatcher(dictiaonryPredicate);
    dictionaryMatcher.setLimit(limit);
    dictionaryMatcher.setOffset(offset);
    dictionaryMatcher.setInputOperator(scanSource);
    Tuple tuple;
    List<Tuple> results = new ArrayList<>();
    dictionaryMatcher.open();
    while ((tuple = dictionaryMatcher.getNextTuple()) != null) {
        results.add(tuple);
    }
    dictionaryMatcher.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) DictionaryPredicate(edu.uci.ics.texera.dataflow.dictionarymatcher.DictionaryPredicate) ScanBasedSourceOperator(edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator) ScanSourcePredicate(edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate) Tuple(edu.uci.ics.texera.api.tuple.Tuple) RelationManager(edu.uci.ics.texera.storage.RelationManager)

Example 23 with RelationManager

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

the class FuzzyTokenMatcherTestHelper method writeTestTables.

/*
     * Creates the test table(s) and writes data into it(them).
     */
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();
}
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 24 with RelationManager

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

the class FuzzyTokenMatcherTestHelper method deleteTestTables.

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

Example 25 with RelationManager

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

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