usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [1/5] incubator-usergrid git commit: Fix cursor problem that was causing multiple tests to fail.
Date Mon, 06 Apr 2015 13:53:34 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev 79e2fe31d -> 602a0a9ec


Fix cursor problem that was causing multiple tests to fail.


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

Branch: refs/heads/two-dot-o-dev
Commit: 4d7571619756fbd347ffc1e3963a7018c81c2b13
Parents: c1643a7
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Wed Apr 1 07:51:39 2015 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Wed Apr 1 07:51:39 2015 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4d757161/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..d4bfe19 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/4d757161/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..13a46cc 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
@@ -61,7 +61,7 @@ import static org.apache.usergrid.persistence.index.impl.IndexingUtils.SPLITTER;
 /**
  * Classy class class.
  */
-public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
+public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex {
 
     private static final Logger logger = LoggerFactory.getLogger(EsApplicationEntityIndexImpl.class);
 
@@ -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, query.getLimit() );
     }
 
 
-    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,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
         final CandidateResults candidateResults = new CandidateResults(candidates);
         final String esScrollCursor = searchResponse.getScrollId();
 
-        if(esScrollCursor != null) {
+        if ( esScrollCursor != null && hits.length >= expectedSize ) {
             candidateResults.initializeCursor();
 
             //now set this into our map module

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4d757161/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..63d465c 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,9 @@ 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, query.getLimit() );
 
             assertTrue( results.hasCursor() );
 


Mime
View raw message