@Override public boolean isKeep(TridentTuple tuple) { Status status = (Status) tuple.get(0); return !(null == status.getPlace() || null == status.getPlace().getCountryCode()); } }
@Override public void execute(TridentTuple tuple, TridentCollector collector) { Status status = (Status) tuple.get(0); Content content = (Content) tuple.get(1); collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName())); } }
private String searchWithTwitter(String location) throws EnforcedWaitException { while(true){ try { twitterLastCall.enforce(); ResponseList<Place> res = this.twitter.searchPlaces(new GeoQuery(location)); if(res.size() > 0) return res.get(0).getCountryCode(); else return null; } catch (TwitterException e) { this.twitterLastCall.currentWait = Twitter4jUtil.handleTwitterException(e, TWITTER_DEFAULT_ERROR_BUT_NO_WAIT_TIME); throw new EnforcedWaitException(this.twitterLastCall); } } }
private String searchWithTwitter(String location) throws EnforcedWaitException { while(true){ try { twitterLastCall.enforce(); ResponseList<Place> res = this.twitter.searchPlaces(new GeoQuery(location)); if(res.size() > 0) return res.get(0).getCountryCode(); else return null; } catch (TwitterException e) { this.twitterLastCall.currentWait = Twitter4jUtil.handleTwitterException(e, TWITTER_DEFAULT_ERROR_BUT_NO_WAIT_TIME); throw new EnforcedWaitException(this.twitterLastCall); } } }
public static void convert(Place place, Struct struct) { if (null == place) { return; } struct.put("Name", place.getName()) .put("StreetAddress", place.getStreetAddress()) .put("CountryCode", place.getCountryCode()) .put("Id", place.getId()) .put("Country", place.getCountry()) .put("PlaceType", place.getPlaceType()) .put("URL", place.getURL()) .put("FullName", place.getFullName()); }
place.setContentName(tweet.getPlace().getCountryCode()); place.setContentType("place_country-code"); contents.add(place);
if (place != null) { status.location = place.getName(); status.country_code = place.getCountryCode();
if (place != null) { status.location = place.getName(); status.country_code = place.getCountryCode();