# GG-9858: Minors.

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

Branch: refs/heads/ignite-sql-tests
Commit: 59dac1e87ced77ec987c3f25ca71a55baca1194d
Parents: 6862ba9
Author: vozerov-gridgain <voze...@gridgain.com>
Authored: Mon Mar 16 15:57:46 2015 +0300
Committer: vozerov-gridgain <voze...@gridgain.com>
Committed: Mon Mar 16 15:57:46 2015 +0300

----------------------------------------------------------------------
 .../ignite/cache/query/SqlFieldsQuery.java      |  7 +++
 .../org/apache/ignite/cache/query/SqlQuery.java |  7 +++
 .../apache/ignite/cache/query/TextQuery.java    |  7 +++
 .../processors/cache/query/QueryCursorEx.java   | 46 ++++++++++++++++++++
 .../processors/cache/query/QueryCursorImpl.java | 14 +++++-
 5 files changed, 79 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59dac1e8/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java 
b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
index c0733e6..65e7a29 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
@@ -39,6 +39,13 @@ public final class SqlFieldsQuery extends 
Query<SqlFieldsQuery>{
     private Object[] args;
 
     /**
+     * Default constructor.
+     */
+    public SqlFieldsQuery() {
+        // No-op.
+    }
+
+    /**
      * Constructs sql fields query.
      *
      * @param sql SQL Query.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59dac1e8/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java 
b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
index 3cb767d..559db5f 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
@@ -43,6 +43,13 @@ public final class SqlQuery extends Query<SqlQuery> {
     private Object[] args;
 
     /**
+     * Default constructor.
+     */
+    public SqlQuery() {
+        // No-op.
+    }
+
+    /**
      * Constructs query for the given SQL query.
      *
      * @param sql SQL Query.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59dac1e8/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java 
b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
index 3de90a0..dbb9183 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/TextQuery.java
@@ -38,6 +38,13 @@ public final class TextQuery extends Query<TextQuery> {
     private String txt;
 
     /**
+     * Default constructor.
+     */
+    public TextQuery() {
+        // No-op.
+    }
+
+    /**
      * Constructs query for the given search string.
      *
      * @param txt Search string.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59dac1e8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorEx.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorEx.java
new file mode 100644
index 0000000..bf1d4ea
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorEx.java
@@ -0,0 +1,46 @@
+/*
+ * 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.cache.query;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.query.*;
+
+/**
+ * Extended query cursor interface allowing for "getAll" to output data into 
destination other than Collection.
+ */
+public interface QueryCursorEx<T> extends QueryCursor<T> {
+    /**
+     * Get all values passing them through passed consumer.
+     *
+     * @param c Consumer.
+     */
+    public void getAll(Consumer<T> c) throws IgniteCheckedException;
+
+    /**
+     * Query value consumer.
+     */
+    public static interface Consumer<T> {
+        /**
+         * Consume value.
+         *
+         * @param val Value.
+         * @throws IgniteCheckedException If failed.
+         */
+        public void consume(T val) throws IgniteCheckedException;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59dac1e8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorImpl.java
index d7691e6..e462c94 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/QueryCursorImpl.java
@@ -18,14 +18,13 @@
 package org.apache.ignite.internal.processors.cache.query;
 
 import org.apache.ignite.*;
-import org.apache.ignite.cache.query.*;
 
 import java.util.*;
 
 /**
  * Query cursor implementation.
  */
-public class QueryCursorImpl<T> implements QueryCursor<T> {
+public class QueryCursorImpl<T> implements QueryCursorEx<T> {
     /** */
     private Iterator<T> iter;
 
@@ -68,6 +67,17 @@ public class QueryCursorImpl<T> implements QueryCursor<T> {
     }
 
     /** {@inheritDoc} */
+    @Override public void getAll(QueryCursorEx.Consumer<T> clo) throws 
IgniteCheckedException {
+        try {
+            for (T t : this)
+                clo.consume(t);
+        }
+        finally {
+            close();
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public void close() {
         Iterator<T> i;
 

Reply via email to