use of datamodel.Tweet in project hazelcast-jet-reference-manual by hazelcast.
the class BuildComputation method s14.
static void s14() {
// tag::s14[]
Pipeline p = Pipeline.create();
p.<Tweet>drawFrom(Sources.mapJournal("tweets", mapPutEvents(), mapEventNewValue(), START_FROM_CURRENT)).flatMap(tweet -> traverseArray(tweet.text().toLowerCase().split("\\W+")).map(word -> new TweetWord(tweet.timestamp(), word))).filter(tweetWord -> !tweetWord.word().isEmpty()).addTimestamps(TweetWord::timestamp, TimeUnit.SECONDS.toMillis(5)).window(sliding(MINUTES.toMillis(1), SECONDS.toMillis(1))).groupingKey(TweetWord::word).aggregate(counting()).drainTo(Sinks.list("result"));
// end::s14[]
}
use of datamodel.Tweet in project hazelcast-jet-reference-manual by hazelcast.
the class BuildComputation method s15.
static void s15() {
// tag::s15[]
Pipeline p = Pipeline.create();
p.<Tweet>drawFrom(Sources.mapJournal("tweets", mapPutEvents(), mapEventNewValue(), START_FROM_CURRENT)).addTimestamps(Tweet::timestamp, TimeUnit.SECONDS.toMillis(5)).flatMap(tweet -> traverseArray(tweet.text().toLowerCase().split("\\W+"))).filter(word -> !word.isEmpty()).window(sliding(MINUTES.toMillis(1), SECONDS.toMillis(1))).groupingKey(wholeItem()).aggregate(counting()).drainTo(Sinks.list("result"));
// end::s15[]
}
Aggregations