Skip to content

Instantly share code, notes, and snippets.

@forcemax
Created July 21, 2015 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forcemax/72b6b8a4cccd5681de1c to your computer and use it in GitHub Desktop.
Save forcemax/72b6b8a4cccd5681de1c to your computer and use it in GitHub Desktop.
public void execute(Tuple input) {
Object obj = input.getValueByField("tweet");
if (obj instanceof Status) {
try {
final Status status = (Status) obj;
LOGGER.debug("input tweet : {}", status);
final HashtagEntity[] hashtags = status.getHashtagEntities();
if (hashtags != null) {
for(HashtagEntity hashtag : hashtags) {
if (hashtag != null) {
final String strHashtag = hashtag.getText();
collector.emit(new Values(strHashtag));
LOGGER.debug("emit hashtag text : {}", strHashtag);
}
}
}
} catch (Exception e) {
LOGGER.error("Exception occurred. {}", e);
}
}
collector.ack(input);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment