Revision: 18328
          http://sourceforge.net/p/gate/code/18328
Author:   adamfunk
Date:     2014-09-12 15:34:42 +0000 (Fri, 12 Sep 2014)
Log Message:
-----------
Fixed logic error in iterator tests.

Modified Paths:
--------------
    
gate/branches/twitter-pop-dev/plugins/Twitter/src/gate/corpora/twitter/TweetStreamIterator.java

Modified: 
gate/branches/twitter-pop-dev/plugins/Twitter/src/gate/corpora/twitter/TweetStreamIterator.java
===================================================================
--- 
gate/branches/twitter-pop-dev/plugins/Twitter/src/gate/corpora/twitter/TweetStreamIterator.java
     2014-09-12 14:43:33 UTC (rev 18327)
+++ 
gate/branches/twitter-pop-dev/plugins/Twitter/src/gate/corpora/twitter/TweetStreamIterator.java
     2014-09-12 15:34:42 UTC (rev 18328)
@@ -16,13 +16,10 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.zip.GZIPInputStream;
-
 import org.apache.log4j.Logger;
-
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonParser.Feature;
-import com.fasterxml.jackson.core.JsonPointer;
 import com.fasterxml.jackson.core.JsonToken;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.MappingIterator;
@@ -33,7 +30,6 @@
 public class TweetStreamIterator implements Iterator<Tweet> {
 
   // Borrowed from gcp IOConstants
-  public static final String ID_POINTER = "/id_str";
   public static final String SEARCH_KEY = "search_metadata";
   public static final String STATUS_KEY = "statuses";
   
@@ -43,7 +39,6 @@
   private JsonParser jsonParser;
   private MappingIterator<JsonNode> iterator;
   private List<String> contentKeys, featureKeys;
-  protected JsonPointer idPointer;
   private boolean nested;
   private Iterator<JsonNode> nestedStatuses;
 
@@ -55,7 +50,6 @@
     InputStream workingInput;
     
     // Following borrowed from gcp JSONStreamingInputHandler
-    idPointer = JsonPointer.compile(ID_POINTER);
     objectMapper = new ObjectMapper();
 
     if (gzip) {
@@ -67,12 +61,9 @@
     
     jsonParser = 
objectMapper.getFactory().createParser(workingInput).enable(Feature.AUTO_CLOSE_SOURCE);
     // If the first token in the stream is the start of an array ("[")
-    // then
-    // assume the stream as a whole is an array of objects, one per
-    // document.
+    // then assume the stream as a whole is an array of objects
     // To handle this, simply clear the token - The MappingIterator
-    // returned
-    // by readValues will cope with the rest in either form.
+    // returned by readValues will cope with the rest in either form.
     if(jsonParser.nextToken() == JsonToken.START_ARRAY) {
       jsonParser.clearCurrentToken();
     }
@@ -84,7 +75,8 @@
   
   @Override
   public boolean hasNext() {
-    return this.iterator.hasNext() || this.nestedStatuses.hasNext();
+    return this.iterator.hasNext() || 
+            ( (this.nestedStatuses != null) && this.nestedStatuses.hasNext());
     // should that be iterator.hasNextValue() ?
   }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
GATE-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to