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

invalid reference
distributed_tweetoscope.HashtagExtractor
. Downstream component (
invalid reference
distributed_tweetoscope.Visualiazor
) is notified of the new leader board data via Java Flow.
Author:
Virginie Galtier
  • Field Details

    • subscribers

      protected List<Flow.Subscriber<? super Map<String,Integer>>> subscribers
      List of objects to notify when the map is updated (downstream component = Visualizor)
    • nbLeaders

      protected int nbLeaders
      Number of lines to include on the leader board
    • hashtagOccurrenceMap

      protected Map<String,Integer> hashtagOccurrenceMap
      Map invalid input: '<'Hashtag text - number of occurrences>
    • previousLeaderMap

      protected Map<String,Integer> 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