You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/08/18 23:06:25 UTC
[5/8] git commit: adding an iterator interface to look for extra pages
adding an iterator interface to look for extra pages
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0a61101d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0a61101d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0a61101d
Branch: refs/heads/two-dot-o-push-notifications
Commit: 0a61101dafc1ab5e719fe3a8662714ab32b89b19
Parents: 99c80fa
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Jul 29 11:30:55 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Aug 18 14:37:19 2014 -0600
----------------------------------------------------------------------
.../persistence/MultiQueryIterator.java | 6 +++-
.../persistence/PagingResultsIterator.java | 7 ++++-
.../usergrid/persistence/ResultsIterator.java | 30 ++++++++++++++++++++
3 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a61101d/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java b/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
index 6135524..5b64d0b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/MultiQueryIterator.java
@@ -27,7 +27,7 @@ import org.apache.usergrid.persistence.index.query.Query.Level;
* For each in a set of source refs executes a sub-query and provides a unified iterator over
* the union of all results. Honors page sizes for the Query to ensure memory isn't blown out.
*/
-public class MultiQueryIterator implements Iterator {
+public class MultiQueryIterator implements ResultsIterator {
private EntityManager entityManager;
private Iterator<EntityRef> source;
@@ -74,6 +74,10 @@ public class MultiQueryIterator implements Iterator {
return false;
}
+ @Override
+ public boolean hasPages(){
+ return currentIterator != null && currentIterator instanceof ResultsIterator && ((ResultsIterator)currentIterator).hasPages();
+ }
@Override
public Object next() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a61101d/stack/core/src/main/java/org/apache/usergrid/persistence/PagingResultsIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/PagingResultsIterator.java b/stack/core/src/main/java/org/apache/usergrid/persistence/PagingResultsIterator.java
index eab6c37..183cc30 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/PagingResultsIterator.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/PagingResultsIterator.java
@@ -25,7 +25,7 @@ import static org.apache.usergrid.persistence.index.query.Query.Level.REFS;
/** iterates over a Results object, crossing page boundaries automatically */
-public class PagingResultsIterator implements Iterator, Iterable {
+public class PagingResultsIterator implements ResultsIterator, Iterable {
private Results results;
private Iterator currentPageIterator;
@@ -61,6 +61,11 @@ public class PagingResultsIterator implements Iterator, Iterable {
return false;
}
+ @Override
+ public boolean hasPages(){
+ return results != null && results.hasCursor();
+ }
+
/** @return the next object (type varies according the Results.Level) */
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a61101d/stack/core/src/main/java/org/apache/usergrid/persistence/ResultsIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/ResultsIterator.java b/stack/core/src/main/java/org/apache/usergrid/persistence/ResultsIterator.java
new file mode 100644
index 0000000..6ed2bad
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/ResultsIterator.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.persistence;
+
+import java.util.Iterator;
+
+/**
+ * Iterator to know if we have more records in cursor.
+ */
+public interface ResultsIterator extends Iterator {
+ /**
+ * is there a cursor
+ * @return
+ */
+ boolean hasPages();
+}