Search in sources :

Example 1 with WordCountOperatorPredicate

use of edu.uci.ics.texera.dataflow.wordcount.WordCountOperatorPredicate in project textdb by TextDB.

the class PredicateBaseTest method testWordCountOperator.

@Test
public void testWordCountOperator() throws Exception {
    WordCountOperatorPredicate wordCountPredicate = new WordCountOperatorPredicate("attr1", "standard");
    testPredicate(wordCountPredicate);
}
Also used : WordCountOperatorPredicate(edu.uci.ics.texera.dataflow.wordcount.WordCountOperatorPredicate) Test(org.junit.Test)

Example 2 with WordCountOperatorPredicate

use of edu.uci.ics.texera.dataflow.wordcount.WordCountOperatorPredicate in project textdb by TextDB.

the class WordCountTest method computePayLoadWordCount.

// Compute result by tuple's PayLoad.
public static HashMap<String, Integer> computePayLoadWordCount(String tableName, String attribute) throws TexeraException {
    ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
    WordCountOperator wordCount = null;
    HashMap<String, Integer> result = new HashMap<String, Integer>();
    if (tableName.equals(COUNT_TABLE)) {
        wordCount = new WordCountOperator(new WordCountOperatorPredicate(TestConstants.DESCRIPTION, LuceneAnalyzerConstants.standardAnalyzerString()));
    } else if (tableName.equals(COUNT_CHINESE_TABLE)) {
        wordCount = new WordCountOperator(new WordCountOperatorPredicate(TestConstantsChineseWordCount.DESCRIPTION, LuceneAnalyzerConstants.chineseAnalyzerString()));
    }
    wordCount.setInputOperator(scanSource);
    wordCount.open();
    Tuple tuple;
    while ((tuple = wordCount.getNextTuple()) != null) {
        result.put((String) tuple.getField(WordCountOperator.WORD).getValue(), (Integer) tuple.getField(WordCountOperator.COUNT).getValue());
    }
    wordCount.close();
    return result;
}
Also used : HashMap(java.util.HashMap) WordCountOperator(edu.uci.ics.texera.dataflow.wordcount.WordCountOperator) WordCountOperatorPredicate(edu.uci.ics.texera.dataflow.wordcount.WordCountOperatorPredicate) 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)

Aggregations

WordCountOperatorPredicate (edu.uci.ics.texera.dataflow.wordcount.WordCountOperatorPredicate)2 Tuple (edu.uci.ics.texera.api.tuple.Tuple)1 ScanBasedSourceOperator (edu.uci.ics.texera.dataflow.source.scan.ScanBasedSourceOperator)1 ScanSourcePredicate (edu.uci.ics.texera.dataflow.source.scan.ScanSourcePredicate)1 WordCountOperator (edu.uci.ics.texera.dataflow.wordcount.WordCountOperator)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1