Hello!

I am trying to customize the Twitter Example TD did by only printing
messages that have a GeoLocation.

I am getting a NullPointerException:

java.lang.NullPointerException
        at Twitter$$anonfun$1.apply(Twitter.scala:64)
        at Twitter$$anonfun$1.apply(Twitter.scala:64)
        at scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:390)
        at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
        at
com.datastax.spark.connector.util.CountingIterator.hasNext(CountingIterator.scala:12)
        at
com.datastax.spark.connector.writer.GroupingBatchBuilder.hasNext(GroupingBatchBuilder.scala:101)


Twitter.scala:64 is this line of code:
//every GeoLocation should contain a ","

val filtering = stream.filter(status =>
status.getGeoLocation().toString().contains(","))

Relevant code:

//every GeoLocation should contain a ","
 val filtering = stream.filter(status =>
status.getGeoLocation().toString().contains(","))

//this code works if I do stream.map
        val hashTags = filtering.map(status =>
TweetC(classifyTweet(status.getText()), status.getGeoLocation(),
status.getUser().getFollowersCount(),status.getText())).saveToCassandra("demo",
"twitter")

 I'm thinking this might be due to the free public Twitter API not letting
me get access to GeoTagged tweets so val hashtags is always null and hence
the NullPointerException. Has anyone else used the free API and seen
GeoLocations?

Reply via email to