ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [13/22] ignite git commit: ignite-gg-11414 simplify iterator wrapper for cursor
Date Wed, 11 Jan 2017 17:27:42 GMT
ignite-gg-11414 simplify iterator wrapper for cursor


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

Branch: refs/heads/ignite-3477
Commit: c7f1cce266c30676ad8781072362161fc7a50718
Parents: c1c15a6
Author: Dmitriy Govorukhin <dgovorukhin@gridgain.com>
Authored: Mon Jan 9 18:37:44 2017 +0300
Committer: Dmitriy Govorukhin <dgovorukhin@gridgain.com>
Committed: Mon Jan 9 18:37:44 2017 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2IndexBase.java           | 55 ++++++--------------
 1 file changed, 17 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c7f1cce2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index c5e836a..b1a594c 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -1569,11 +1569,8 @@ public abstract class GridH2IndexBase extends BaseIndex {
         /** */
         private final GridCursor<GridH2Row> cursor;
 
-        /** First next. */
-        private GridH2Row firstNext;
-
-        /** Second next. */
-        private GridH2Row secondNext;
+        /** Next element. */
+        private GridH2Row next;
 
         /**
          * @param cursor Cursor.
@@ -1581,52 +1578,34 @@ public abstract class GridH2IndexBase extends BaseIndex {
         private CursorIteratorWrapper(GridCursor<GridH2Row> cursor) {
             this.cursor = cursor;
 
-            fetch();
+            try {
+                if (cursor.next())
+                    next = cursor.get();
+            }
+            catch (IgniteCheckedException e) {
+                throw U.convertException(e);
+            }
         }
 
         /** {@inheritDoc} */
         @Override public boolean hasNext() {
-            return firstNext != null;
+            return next != null;
         }
 
         /** {@inheritDoc} */
         @Override public GridH2Row next() {
             try {
-                if (firstNext != null) {
-                    GridH2Row res = firstNext;
+                GridH2Row res = next;
 
-                    firstNext = secondNext;
-
-                    if (cursor.next())
-                        secondNext = cursor.get();
-                    else
-                        secondNext = null;
-                    return res;
-                }
+                if (cursor.next())
+                    next = cursor.get();
                 else
-                    return null;
-            }
-            catch (Exception e) {
-                return null;
-            }
-        }
-
-        /**
-         *
-         */
-        private void fetch() {
-            try {
-                if (firstNext == null && secondNext == null) {
-                    if (cursor.next()) {
-                        firstNext = cursor.get();
+                    next = null;
 
-                        if (cursor.next())
-                            secondNext = cursor.get();
-                    }
-                }
+                return res;
             }
-            catch (IgniteCheckedException ignored) {
-
+            catch (IgniteCheckedException e) {
+                throw U.convertException(e);
             }
         }
 


Mime
View raw message