Package tweetoscope
Class HashtagCounter
java.lang.Object
tweetoscope.HashtagCounter
- All Implemented Interfaces:
Flow.Publisher<Map<String,
,Integer>> Flow.Subscriber<String>
public class HashtagCounter
extends Object
implements Flow.Subscriber<String>, Flow.Publisher<Map<String,Integer>>
Reacts to the reception of a new hashtag by updating how many times it has
been seen so far, and sending to its subscribers the updated list of the most
popular ones.
Hashtags are received via Java Flow from the upstream component
. Downstream component
(
invalid reference
distributed_tweetoscope.HashtagExtractor
) is notified of the new leader
board data via Java Flow.invalid reference
distributed_tweetoscope.Visualiazor
- Author:
- Virginie Galtier
-
Field Summary
Modifier and TypeFieldDescriptionMap invalid input: '<'Hashtag text - number of occurrences>protected int
Number of lines to include on the leader boardList of most popular hashtags, used to checked if the list is changed after a new hashtag is receivedprotected List
<Flow.Subscriber<? super Map<String, Integer>>> List of objects to notify when the map is updated (downstream component = Visualizor) -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
Triggered by the reception of a new hashtag from a TweetFilter via Java Flow.void
onSubscribe
(Flow.Subscription subscription) void
subscribe
(Flow.Subscriber<? super Map<String, Integer>> subscriber)
-
Field Details
-
subscribers
List of objects to notify when the map is updated (downstream component = Visualizor) -
nbLeaders
protected int nbLeadersNumber of lines to include on the leader board -
hashtagOccurrenceMap
Map invalid input: '<'Hashtag text - number of occurrences> -
previousLeaderMap
List of most popular hashtags, used to checked if the list is changed after a new hashtag is received
-
-
Constructor Details
-
HashtagCounter
public HashtagCounter(int nbLeader) - Parameters:
nbLeaders
- number of hashtags to include on the leader board
-
-
Method Details
-
subscribe
- Specified by:
subscribe
in interfaceFlow.Publisher<Map<String,
Integer>>
-
onNext
Triggered by the reception of a new hashtag from a TweetFilter via Java Flow.- Specified by:
onNext
in interfaceFlow.Subscriber<String>
-
onSubscribe
- Specified by:
onSubscribe
in interfaceFlow.Subscriber<String>
-
onError
- Specified by:
onError
in interfaceFlow.Subscriber<String>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceFlow.Subscriber<String>
-