usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [03/10] git commit: adding an iterator interface to look for extra pages
Date Wed, 30 Jul 2014 22:00:19 GMT
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/acdfcd76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/acdfcd76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/acdfcd76

Branch: refs/heads/master
Commit: acdfcd76d44f3f9508034dc14b69ab7de3975817
Parents: 6c8416d
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Tue Jul 29 11:30:55 2014 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Tue Jul 29 11:30:55 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/acdfcd76/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 9bdb7be..b1ffc6e 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
@@ -25,7 +25,7 @@ import java.util.UUID;
  * For each in a set of source UUIDs, 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<UUID> source;
@@ -71,6 +71,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/acdfcd76/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 faa0abb..2ec96a8 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
@@ -22,7 +22,7 @@ import java.util.List;
 
 
 /** 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;
@@ -58,6 +58,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/acdfcd76/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();
+}


Mime
View raw message