You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/07/21 13:48:24 UTC
[1/2] ignite git commit: ignite-1232 - fix for NPE in subquery
Repository: ignite
Updated Branches:
refs/heads/ignite-1232-1 4838f0e26 -> d0c1821e4
ignite-1232 - fix for NPE in subquery
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/028858fb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/028858fb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/028858fb
Branch: refs/heads/ignite-1232-1
Commit: 028858fb96750c9cbeb3a181f845835a75f5f977
Parents: a205d42
Author: Sergi Vladykin <se...@gmail.com>
Authored: Thu Jul 21 10:39:48 2016 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Thu Jul 21 10:39:48 2016 +0300
----------------------------------------------------------------------
.../query/h2/opt/GridH2IndexBase.java | 54 +++++++++++++-------
1 file changed, 35 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/028858fb/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 42a51a0..01065c3 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
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.query.h2.opt;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -927,13 +928,13 @@ public abstract class GridH2IndexBase extends BaseIndex {
int batchLookupId;
/** */
- Map<ClusterNode, RangeStream> rangeStreams;
+ Map<ClusterNode, RangeStream> rangeStreams = Collections.emptyMap();
/** */
List<ClusterNode> broadcastNodes;
/** */
- final List<Future<Cursor>> res = new ArrayList<>();
+ List<Future<Cursor>> res = Collections.emptyList();
/** */
boolean batchFull;
@@ -1005,16 +1006,28 @@ public abstract class GridH2IndexBase extends BaseIndex {
/** {@inheritDoc} */
@SuppressWarnings("ForLoopReplaceableByForEach")
@Override public boolean addSearchRows(SearchRow firstRow, SearchRow lastRow) {
- if (findCalled) {
- findCalled = false;
+ if (qctx == null || findCalled) {
+ if (qctx == null) {
+ // It is the first call after query begin (may be after reuse),
+ // reinitialize query context and result.
+ qctx = GridH2QueryContext.get();
+ res = new ArrayList<>();
+
+ assert qctx != null;
+ assert !findCalled;
+ }
+ else {
+ // Cleanup after the previous lookup phase.
+ assert batchLookupId != 0;
- // Cleanup after the previous phase.
- qctx.putStreams(batchLookupId, null);
+ findCalled = false;
+ qctx.putStreams(batchLookupId, null);
+ res.clear();
+ }
// Reinitialize for the next lookup phase.
batchLookupId = qctx.nextBatchLookupId();
rangeStreams = new HashMap<>();
- res.clear();
}
Object affKey = affColId == -1 ? null : getAffinityKey(firstRow, lastRow);
@@ -1118,18 +1131,21 @@ public abstract class GridH2IndexBase extends BaseIndex {
/** {@inheritDoc} */
@Override public void reset(boolean beforeQry) {
- if (beforeQry) {
- qctx = GridH2QueryContext.get();
- batchLookupId = qctx.nextBatchLookupId();
- rangeStreams = new HashMap<>();
- }
- else {
- rangeStreams = null;
- broadcastNodes = null;
- batchFull = false;
- findCalled = false;
- res.clear();
- }
+ if (beforeQry || qctx == null) // Query context can be null if addSearchRows was never called.
+ return;
+
+ assert batchLookupId != 0;
+
+ // Do cleanup after the query run.
+ qctx.putStreams(batchLookupId, null);
+ qctx = null; // The same query can be reused multiple times for different query contexts.
+ batchLookupId = 0;
+
+ rangeStreams = Collections.emptyMap();
+ broadcastNodes = null;
+ batchFull = false;
+ findCalled = false;
+ res = Collections.emptyList();
}
/** {@inheritDoc} */
[2/2] ignite git commit: Merge branch 'ignite-1232' into ignite-1232-1
Posted by sb...@apache.org.
Merge branch 'ignite-1232' into ignite-1232-1
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d0c1821e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d0c1821e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d0c1821e
Branch: refs/heads/ignite-1232-1
Commit: d0c1821e46c1ad49f9368fa6f67416c6e4b73281
Parents: 4838f0e 028858f
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jul 21 16:47:53 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jul 21 16:47:53 2016 +0300
----------------------------------------------------------------------
.../query/h2/opt/GridH2IndexBase.java | 54 +++++++++++++-------
1 file changed, 35 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0c1821e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------