You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/09/25 18:41:41 UTC

[2/3] git commit: Code to ensure query limit is satisfied despite stale entries, but commented out because of insufficient testing.

Code to ensure query limit is satisfied despite stale entries, but commented out because of insufficient testing.


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

Branch: refs/heads/two-dot-o
Commit: d2833110b7a493a94da197c5e680c023991059c1
Parents: b01b2a7
Author: Dave Johnson <dm...@apigee.com>
Authored: Thu Sep 25 10:50:00 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Thu Sep 25 10:50:00 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      | 44 ++++++++++++++++++++
 1 file changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d2833110/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index a7cb0d4..c2f4a09 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -970,6 +970,50 @@ public class CpRelationManager implements RelationManager {
         CandidateResults crs = ei.search( query );
 
         return buildResults( query, crs, collName );
+
+//        // Because of possible stale entities, which are filtered out by buildResults(), 
+//        // we loop until the we've got enough results to satisfy the query limit. 
+//
+//        int maxQueries = 10; // max re-queries to satisfy query limit
+//
+//        Results results = null;
+//        int queryCount = 0;
+//        int originalLimit = query.getLimit();
+//        boolean satisfied = false;
+//
+//        while ( !satisfied && queryCount++ < maxQueries ) {
+//
+//            CandidateResults crs = ei.search( query );
+//
+//            if ( results == null ) {
+//                results = buildResults( query, crs, collName );
+//
+//            } else {
+//                Results newResults = buildResults( query, crs, collName );
+//                results.merge( newResults );
+//            }
+//
+//            if ( crs.isEmpty() ) { // no more results
+//                satisfied = true;
+//
+//            } else if ( results.size() == query.getLimit() )  { // got what we need
+//                satisfied = true;
+//
+//            } else if ( crs.hasCursor() ) {
+//                satisfied = false;
+//
+//                // need to query for more
+//                // ask for just what we need to satisfy, don't want to exceed limit
+//                query.setCursor( results.getCursor() );
+//                query.setLimit( originalLimit - results.size() );
+//
+//                logger.warn("Satisfy query limit {}, new limit {} query count {}", new Object[] {
+//                    originalLimit, query.getLimit(), queryCount 
+//                });
+//            }
+//        }
+//
+//        return results;
     }