Created
November 19, 2012 14:05
-
-
Save itaifrenkel/4110821 to your computer and use it in GitHub Desktop.
Tokenizing unprocessed tweets in-memory
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 class TweetParser { | |
SQLQuery<SpaceDocument> getTemplate() { | |
return new SQLQuery<SpaceDocument>("Tweet", "Processed = ?", false); | |
} | |
public SpaceDocument eventListener(SpaceDocument tweet) { | |
Long id = (Long) tweet.getProperty("Id"); | |
String text = tweet.getProperty("Text"); | |
if (text != null) { | |
//tokenize tweet in memory | |
gigaSpace.write(new TokenizedTweet(id, tokenize(text))); | |
} | |
//mark tweet as processed in memory | |
tweet.setProperty("Processed", true); | |
return tweet; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment