You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/08/14 10:30:55 UTC
[45/50] ignite git commit: Minors.
Minors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d7f42d6a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d7f42d6a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d7f42d6a
Branch: refs/heads/ignite-5991-6019
Commit: d7f42d6afb71fb5e445f9b985d017ce5c8822618
Parents: 125dd07
Author: devozerov <vo...@gridgain.com>
Authored: Mon Aug 14 13:11:49 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Aug 14 13:11:49 2017 +0300
----------------------------------------------------------------------
.../h2/twostep/GridMergeIndexeIterator.java | 155 ++++++++++++++++++
.../h2/twostep/GridMergeIndexesIterator.java | 161 -------------------
.../h2/twostep/GridReduceQueryExecutor.java | 2 +-
3 files changed, 156 insertions(+), 162 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d7f42d6a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexeIterator.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexeIterator.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexeIterator.java
new file mode 100644
index 0000000..16499b1
--- /dev/null
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexeIterator.java
@@ -0,0 +1,155 @@
+/*
+ * 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.ignite.internal.processors.query.h2.twostep;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.GridCloseableIteratorAdapterEx;
+import org.h2.index.Cursor;
+import org.h2.result.Row;
+
+/**
+ * Iterator that transparently and sequentially traverses a bunch of {@link GridMergeIndex} objects.
+ */
+class GridMergeIndexeIterator extends GridCloseableIteratorAdapterEx<List<?>> {
+ /** Reduce query executor. */
+ private final GridReduceQueryExecutor rdcExec;
+
+ /** Participating nodes. */
+ private final Collection<ClusterNode> nodes;
+
+ /** Query run. */
+ private final ReduceQueryRun run;
+
+ /** Query request ID. */
+ private final long qryReqId;
+
+ /** Distributed joins. */
+ private final boolean distributedJoins;
+
+ /** Iterator over indexes. */
+ private final Iterator<GridMergeIndex> idxs;
+
+ /** Current cursor. */
+ private Cursor cur;
+
+ /** Next row to return. */
+ private List<Object> next;
+
+ /** Whether remote resources were released. */
+ private boolean released;
+
+ /**
+ * Constructor.
+ *
+ * @param rdcExec Reduce query executor.
+ * @param nodes Participating nodes.
+ * @param run Query run.
+ * @param qryReqId Query request ID.
+ * @param distributedJoins Distributed joins.
+ * @throws IgniteCheckedException if failed.
+ */
+ GridMergeIndexeIterator(GridReduceQueryExecutor rdcExec, Collection<ClusterNode> nodes, ReduceQueryRun run,
+ long qryReqId, boolean distributedJoins)
+ throws IgniteCheckedException {
+ this.rdcExec = rdcExec;
+ this.nodes = nodes;
+ this.run = run;
+ this.qryReqId = qryReqId;
+ this.distributedJoins = distributedJoins;
+
+ this.idxs = run.indexes().iterator();
+
+ advance();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onHasNext() throws IgniteCheckedException {
+ return next != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public List<?> onNext() throws IgniteCheckedException {
+ final List<?> res = next;
+
+ if (res == null)
+ throw new NoSuchElementException();
+
+ advance();
+
+ return res;
+ }
+
+ /**
+ * Advance iterator.
+ *
+ * @throws IgniteCheckedException if failed.
+ */
+ private void advance() throws IgniteCheckedException {
+ next = null;
+
+ try {
+ boolean hasNext = false;
+
+ while (cur == null || !(hasNext = cur.next())) {
+ if (idxs.hasNext())
+ cur = idxs.next().findInStream(null, null);
+ else {
+ close0();
+
+ break;
+ }
+ }
+
+ if (hasNext) {
+ Row row = cur.get();
+
+ int cols = row.getColumnCount();
+
+ List<Object> res = new ArrayList<>(cols);
+
+ for (int c = 0; c < cols; c++)
+ res.add(row.getValue(c).getObject());
+
+ next = res;
+ }
+ }
+ catch (Exception e) {
+ close0();
+
+ throw e;
+ }
+ }
+
+ /**
+ * Close routine.
+ */
+ private void close0() {
+ if (!released) {
+ rdcExec.releaseRemoteResources(nodes, run, qryReqId, distributedJoins);
+
+ released = true;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d7f42d6a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexesIterator.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexesIterator.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexesIterator.java
deleted file mode 100644
index 1bb97ed..0000000
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexesIterator.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.ignite.internal.processors.query.h2.twostep;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.util.GridCloseableIteratorAdapterEx;
-import org.h2.index.Cursor;
-import org.h2.result.Row;
-
-/**
- * Iterator that transparently and sequentially traverses a bunch of {@link GridMergeIndex}es.
- */
-class GridMergeIndexesIterator extends GridCloseableIteratorAdapterEx<List<?>> {
- /** Reduce query executor. */
- private final GridReduceQueryExecutor rdcExec;
-
- /** Participating nodes. */
- private final Collection<ClusterNode> nodes;
-
- /** Query run. */
- private final ReduceQueryRun run;
-
- /** Query request ID. */
- private final long qryReqId;
-
- /** Distributed joins. */
- private final boolean distributedJoins;
-
- /** Iterator over indexes. */
- private final Iterator<GridMergeIndex> idxs;
-
- /** Current cursor. */
- private Cursor cur;
-
- /** Next row to return. */
- private List<Object> next;
-
- /** Close flag. */
- private boolean closed;
-
- /**
- * Constructor.
- *
- * @param rdcExec Reduce query executor.
- * @param nodes Participating nodes.
- * @param run Query run.
- * @param qryReqId Query request ID.
- * @param distributedJoins Distributed joins.
- * @throws IgniteCheckedException if failed.
- */
- GridMergeIndexesIterator(GridReduceQueryExecutor rdcExec, Collection<ClusterNode> nodes, ReduceQueryRun run,
- long qryReqId, boolean distributedJoins)
- throws IgniteCheckedException {
- this.rdcExec = rdcExec;
- this.nodes = nodes;
- this.run = run;
- this.qryReqId = qryReqId;
- this.distributedJoins = distributedJoins;
-
- this.idxs = run.indexes().iterator();
-
- next0();
- }
-
- /** {@inheritDoc} */
- @Override public boolean onHasNext() throws IgniteCheckedException {
- return next != null;
- }
-
- /** {@inheritDoc} */
- @Override public List<?> onNext() throws IgniteCheckedException {
- final List<?> res = next;
-
- if (res == null)
- throw new NoSuchElementException();
-
- next0();
-
- return res;
- }
-
- /**
- * Retrieve next row.
- * @throws IgniteCheckedException if failed.
- */
- private void next0() throws IgniteCheckedException {
- next = null;
-
- try {
- boolean hasNext = false;
-
- while (cur == null || !(hasNext = cur.next())) {
- if (idxs.hasNext())
- cur = idxs.next().findInStream(null, null);
- else {
- close0();
-
- break;
- }
- }
-
- if (hasNext) {
- Row row = cur.get();
-
- int cols = row.getColumnCount();
-
- List<Object> res = new ArrayList<>(cols);
-
- for (int c = 0; c < cols; c++)
- res.add(row.getValue(c).getObject());
-
- next = res;
- }
- }
- catch (Throwable e) {
- close0();
-
- throw new IgniteCheckedException(e);
- }
- }
-
- /**
- * Close routine.
- */
- private void close0() {
- if (!closed) {
- rdcExec.releaseRemoteResources(nodes, run, qryReqId, distributedJoins);
-
- closed = true;
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void onClose() throws IgniteCheckedException {
- close0();
-
- super.onClose();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d7f42d6a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index a572906..51ea7a4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -758,7 +758,7 @@ public class GridReduceQueryExecutor {
if (!retry) {
if (skipMergeTbl) {
- resIter = new GridMergeIndexesIterator(this, finalNodes, r, qryReqId, qry.distributedJoins());
+ resIter = new GridMergeIndexeIterator(this, finalNodes, r, qryReqId, qry.distributedJoins());
release = false;
}