Search in sources :

Example 6 with TwitterSampleInput

use of org.apache.apex.malhar.contrib.twitter.TwitterSampleInput in project apex-malhar by apache.

the class TwitterTopWordsApplication method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    TwitterSampleInput twitterFeed = new TwitterSampleInput();
    twitterFeed = dag.addOperator("TweetSampler", twitterFeed);
    TwitterStatusWordExtractor wordExtractor = dag.addOperator("WordExtractor", TwitterStatusWordExtractor.class);
    UniqueCounter<String> uniqueCounter = dag.addOperator("UniqueWordCounter", new UniqueCounter<String>());
    WindowedTopCounter<String> topCounts = dag.addOperator("TopCounter", new WindowedTopCounter<String>());
    topCounts.setSlidingWindowWidth(120);
    topCounts.setDagWindowWidth(1);
    dag.addStream("TweetStream", twitterFeed.text, wordExtractor.input);
    dag.addStream("TwittedWords", wordExtractor.output, uniqueCounter.data);
    dag.addStream("UniqueWordCounts", uniqueCounter.count, topCounts.input).setLocality(Locality.CONTAINER_LOCAL);
    TwitterTopCounterApplication.consoleOutput(dag, "topWords", topCounts.output, SNAPSHOT_SCHEMA, "word");
}
Also used : TwitterSampleInput(org.apache.apex.malhar.contrib.twitter.TwitterSampleInput)

Example 7 with TwitterSampleInput

use of org.apache.apex.malhar.contrib.twitter.TwitterSampleInput 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

TwitterSampleInput (org.apache.apex.malhar.contrib.twitter.TwitterSampleInput)7 LinkedList (java.util.LinkedList)1 List (java.util.List)1 KinesisStringInputOperator (org.apache.apex.malhar.contrib.kinesis.KinesisStringInputOperator)1 KinesisStringOutputOperator (org.apache.apex.malhar.contrib.kinesis.KinesisStringOutputOperator)1 ShardManager (org.apache.apex.malhar.contrib.kinesis.ShardManager)1 TriggerOption (org.apache.apex.malhar.lib.window.TriggerOption)1 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)1