Created
July 21, 2015 07:56
-
-
Save forcemax/72b6b8a4cccd5681de1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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