Search in sources :

Example 1 with WindowOption

use of org.apache.apex.malhar.lib.window.WindowOption in project apex-malhar by apache.

the class AutoComplete method populateDAG.

/**
 * Populate the dag with High-Level API.
 * @param dag
 * @param conf
 */
@Override
public void populateDAG(DAG dag, Configuration conf) {
    TweetsInput input = new TweetsInput();
    Collector collector = new Collector();
    WindowOption windowOption = new WindowOption.GlobalWindow();
    ApexStream<String> tags = StreamFactory.fromInput(input, input.output, name("tweetSampler")).flatMap(new ExtractHashtags());
    tags.window(windowOption, new TriggerOption().accumulatingFiredPanes().withEarlyFiringsAtEvery(1)).addCompositeStreams(ComputeTopCompletions.top(10, true)).print(name("console")).endWith(collector, collector.input, name("collector")).populateDag(dag);
}
Also used : TriggerOption(org.apache.apex.malhar.lib.window.TriggerOption) WindowOption(org.apache.apex.malhar.lib.window.WindowOption)

Example 2 with WindowOption

use of org.apache.apex.malhar.lib.window.WindowOption in project apex-malhar by apache.

the class TwitterAutoComplete method populateDAG.

/**
 * Populate the dag with High-Level API.
 * @param dag
 * @param conf
 */
@Override
public void populateDAG(DAG dag, Configuration conf) {
    TwitterSampleInput input = new TwitterSampleInput();
    WindowOption windowOption = new WindowOption.GlobalWindow();
    ApexStream<String> tags = StreamFactory.fromInput(input, input.text, name("tweetSampler")).filter(new ASCIIFilter(), name("ACSII Filter")).flatMap(new ExtractHashtags(), name("Extract Hashtags"));
    ApexStream<Tuple.WindowedTuple<KeyValPair<String, List<CompletionCandidate>>>> s = tags.window(windowOption, new TriggerOption().accumulatingFiredPanes().withEarlyFiringsAtEvery(Duration.standardSeconds(10))).addCompositeStreams(ComputeTopCompletions.top(10, true)).print();
    s.populateDag(dag);
}
Also used : TriggerOption(org.apache.apex.malhar.lib.window.TriggerOption) WindowOption(org.apache.apex.malhar.lib.window.WindowOption) TwitterSampleInput(org.apache.apex.malhar.contrib.twitter.TwitterSampleInput) List(java.util.List) LinkedList(java.util.LinkedList)

Aggregations

TriggerOption (org.apache.apex.malhar.lib.window.TriggerOption)2 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TwitterSampleInput (org.apache.apex.malhar.contrib.twitter.TwitterSampleInput)1