You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/01/11 17:27:42 UTC
[13/22] ignite git commit: ignite-gg-11414 simplify iterator wrapper
for cursor
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 <dg...@gridgain.com>
Authored: Mon Jan 9 18:37:44 2017 +0300
Committer: Dmitriy Govorukhin <dg...@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);
}
}