usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [22/25] incubator-usergrid git commit: Fixes but with cursor generation
Date Wed, 01 Apr 2015 20:44:57 GMT
Fixes but with cursor generation


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8315aee7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8315aee7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8315aee7

Branch: refs/heads/two-dot-o-dev
Commit: 8315aee79d4479ef09f179e85bf6df59c3505b66
Parents: ed114b4
Author: Todd Nine <tnine@apigee.com>
Authored: Tue Mar 31 17:07:01 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Tue Mar 31 17:07:01 2015 -0600

----------------------------------------------------------------------
 .../persistence/index/ApplicationEntityIndex.java     |  2 +-
 .../index/impl/EsApplicationEntityIndexImpl.java      | 14 ++++++++------
 .../persistence/index/impl/EntityIndexTest.java       |  2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8315aee7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
index 86e97c5..c78d6b6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
@@ -47,7 +47,7 @@ public interface ApplicationEntityIndex {
      * @param cursor
      * @return
      */
-    public CandidateResults getNextPage(final String cursor);
+    public CandidateResults getNextPage(final String cursor, final int limit);
 
     /**
      * delete all application records

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8315aee7/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
index eceff90..0cd6fb1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -130,7 +130,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
     public CandidateResults search(final IndexScope indexScope, final SearchTypes searchTypes,
final Query query, final int limit){
 
         if(query.getCursor()!=null){
-            return getNextPage(query.getCursor());
+            return getNextPage(query.getCursor(), query.getLimit());
         }
 
         SearchResponse searchResponse;
@@ -155,11 +155,11 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
         }
         failureMonitor.success();
 
-        return parseResults(searchResponse);
+        return parseResults(searchResponse, limit);
     }
 
 
-    public CandidateResults getNextPage(final String cursor){
+    public CandidateResults getNextPage(final String cursor, final int limit){
         SearchResponse searchResponse;
 
         String userCursorString = cursor;
@@ -197,7 +197,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
 
 
         failureMonitor.success();
-        return parseResults(searchResponse);
+        return parseResults(searchResponse, limit);
     }
 
     /**
@@ -260,7 +260,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
 
 
 
-    private CandidateResults parseResults( final SearchResponse searchResponse) {
+    private CandidateResults parseResults( final SearchResponse searchResponse, final int
expectedSize) {
 
         final SearchHits searchHits = searchResponse.getHits();
         final SearchHit[] hits = searchHits.getHits();
@@ -285,7 +285,9 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
         final CandidateResults candidateResults = new CandidateResults(candidates);
         final String esScrollCursor = searchResponse.getScrollId();
 
-        if(esScrollCursor != null) {
+        // >= seems odd.  However if our user reduces expectedSize (limit) on subsequent
requests, we can't do that
+        //therefor we need to account for the overflow
+        if(esScrollCursor != null && length >= expectedSize) {
             candidateResults.initializeCursor();
 
             //now set this into our map module

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8315aee7/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 27f0b9d..1fc9237 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -656,7 +656,7 @@ public class EntityIndexTest extends BaseIT {
             //**
             Query query = Query.fromQL( "select * order by created" );
 
-            final CandidateResults results = cursor == null ?  entityIndex.search( indexScope,
SearchTypes.allTypes(), query , limit) : entityIndex.getNextPage(cursor);
+            final CandidateResults results = cursor == null ?  entityIndex.search( indexScope,
SearchTypes.allTypes(), query , limit) : entityIndex.getNextPage(cursor, limit);
 
             assertTrue( results.hasCursor() );
 


Mime
View raw message