ignite-sql - api changes

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

Branch: refs/heads/ignite-sql
Commit: 58d01eba6c1da34db340ceec2a9085abc44948b1
Parents: 5b37fdd
Author: S.Vladykin <svlady...@gridgain.com>
Authored: Tue Feb 3 09:50:07 2015 +0300
Committer: S.Vladykin <svlady...@gridgain.com>
Committed: Tue Feb 3 09:50:07 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     |  56 ++++++-
 .../cache/query/QueryAffinityPredicate.java     | 132 ----------------
 .../ignite/cache/query/QueryConfiguration.java  |  21 +++
 .../cache/query/QueryContinuousPredicate.java   |  11 +-
 .../ignite/cache/query/QueryPredicate.java      |   8 +-
 .../apache/ignite/cache/query/QueryReducer.java |  41 -----
 .../ignite/cache/query/QueryScanPredicate.java  |  30 ++++
 .../ignite/cache/query/QuerySpiPredicate.java   |  62 ++++++++
 .../ignite/cache/query/QuerySqlPredicate.java   |  45 +++---
 .../ignite/cache/query/QueryTextPredicate.java  |  59 ++++---
 .../processors/cache/IgniteCacheProxy.java      | 153 +++++++++++++------
 .../processors/query/h2/QueryCursorImpl.java    |  10 +-
 12 files changed, 336 insertions(+), 292 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java 
b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index c0e800a..bf7fd40 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -201,18 +201,62 @@ public interface IgniteCache<K, V> extends 
javax.cache.Cache<K, V>, IgniteAsyncS
      */
     public boolean isLocalLocked(K key, boolean byCurrThread);
 
-    public QueryCursor<Entry<K, V>> query(QueryPredicate<K, V> filter);
+    /**
+     * Queries cache with given predicate.
+     *
+     * @param filter Filter.
+     * @return Cursor.
+     */
+    public QueryCursor<Entry<K, V>> query(QueryPredicate filter);
 
-    public <R> QueryCursor<R> query(QueryReducer<Entry<K, V>, R> rmtRdc, 
QueryPredicate<K, V> filter);
+    /**
+     * Queries configured indexing SPI with given predicate.
+     *
+     * @param filter Filter.
+     * @return Cursor.
+     */
+    public <Z> QueryCursor<Z> querySpi(QuerySpiPredicate filter);
 
-    public QueryCursor<List<?>> queryFields(QuerySqlPredicate<K, V> filter);
+    /**
+     * Queries cache with given predicate with remote reducer.
+     *
+     * @param rmtRdc Remote reducer.
+     * @param filter Filter.
+     * @return Cursor.
+     */
+    public <R> QueryCursor<R> query(IgniteReducer<Entry<K, V>, R> rmtRdc, 
QueryPredicate filter);
 
-    public <R> QueryCursor<R> queryFields(QueryReducer<List<?>, R> rmtRdc, 
QuerySqlPredicate<K, V> filter);
+    /**
+     * Queries separate entry fields with given SQL predicate.
+     *
+     * @param filter SQL Filter.
+     * @return Cursor.
+     */
+    public QueryCursor<List<?>> queryFields(QuerySqlPredicate filter);
 
-    public QueryCursor<Entry<K, V>> localQuery(QueryPredicate<K, V> filter);
+    /**
+     * Queries cache with given predicate only locally.
+     *
+     * @param filter Filter.
+     * @return Cursor.
+     */
+    public QueryCursor<Entry<K, V>> localQuery(QueryPredicate filter);
 
-    public QueryCursor<List<?>> localQueryFields(QuerySqlPredicate<K, V> 
filter);
+    /**
+     * Queries separate entry fields with given SQL predicate only locally.
+     *
+     * @param filter Filter.
+     * @return Cursor.
+     */
+    public QueryCursor<List<?>> localQueryFields(QuerySqlPredicate filter);
 
+    /**
+     * Allows for iteration over local cache entries.
+     *
+     * @param peekModes Peek modes.
+     * @return Iterable over local cache entries.
+     * @throws CacheException If failed.
+     */
     public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) 
throws CacheException;
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryAffinityPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryAffinityPredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryAffinityPredicate.java
deleted file mode 100644
index 32c8911..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryAffinityPredicate.java
+++ /dev/null
@@ -1,132 +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.cache.query;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import javax.cache.*;
-
-/**
- * TODO: Add class description.
- *
- * @author @java.author
- * @version @java.version
- */
-public final class QueryAffinityPredicate<K, V> extends QueryPredicate<K, V> {
-    /** Predicate. */
-    private QueryPredicate<K, V> p;
-
-    /** Keys. */
-    private K[] keys;
-
-    /** Partitions. */
-    private int[] parts;
-
-    /**
-     * Empty constructor.
-     */
-    public QueryAffinityPredicate() {
-        // No-op.
-    }
-
-    /**
-     * Constructs affinity predicate with specified affinity keys.
-     *
-     * @param p Predicate.
-     * @param keys Affinity keys.
-     */
-    public QueryAffinityPredicate(QueryPredicate<K, V> p, K... keys) {
-        this.p = p;
-        this.keys = keys;
-    }
-
-    /**
-     * Constructs affinity predicate with specified affinity partitions.
-     *
-     * @param p Predicate.
-     * @param parts Affinity partitions.
-     */
-    public QueryAffinityPredicate(QueryPredicate<K, V> p, int[] parts) {
-        this.p = p;
-        this.parts = parts;
-    }
-
-    /**
-     * Gets wrapped predicate.
-     *
-     * @return Wrapped predicate.
-     */
-    public QueryPredicate<K, V> getPredicate() {
-        return p;
-    }
-
-    /**
-     * Sets wrapped predicate.
-     *
-     * @param p Wrapped predicate.
-     */
-    public void setPredicate(QueryPredicate<K, V> p) {
-        this.p = p;
-    }
-
-    /**
-     * Gets affinity keys.
-     *
-     * @return Affinity keys.
-     */
-    public K[] getKeys() {
-        return keys;
-    }
-
-    /**
-     * Sets affinity keys.
-     *
-     * @param keys Affinity keys.
-     */
-    public void setKeys(K... keys) {
-        this.keys = keys;
-    }
-
-    /**
-     * Gets affinity partitions.
-     *
-     * @return Affinity partitions.
-     */
-    public int[] getPartitions() {
-        return parts;
-    }
-
-    /**
-     * Sets affinity partitions.
-     *
-     * @param parts Affinity partitions.
-     */
-    public void setPartitions(int... parts) {
-        this.parts = parts;
-    }
-
-    /** {@inheritDoc} */
-    @Override public final boolean apply(Cache.Entry<K, V> entry) {
-        return p.apply(entry);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(QueryAffinityPredicate.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryConfiguration.java
index 960c729..442c2a2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryConfiguration.java
@@ -45,6 +45,9 @@ public class QueryConfiguration implements Serializable {
     /** */
     private boolean escapeAll;
 
+    /** */
+    private int pageSize = 1000;
+
     /**
      * Default constructor.
      */
@@ -200,4 +203,22 @@ public class QueryConfiguration implements Serializable {
     public void setEscapeAll(boolean escapeAll) {
         this.escapeAll = escapeAll;
     }
+
+    /**
+     * Gets default query result page size.
+     *
+     * @return Page size.
+     */
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    /**
+     * Sets default query result page size.
+     *
+     * @param pageSize Page size.
+     */
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java
index ad96b35..070fe2d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryContinuousPredicate.java
@@ -19,7 +19,6 @@ package org.apache.ignite.cache.query;
 
 import org.apache.ignite.*;
 
-import javax.cache.*;
 import javax.cache.event.*;
 
 /**
@@ -107,8 +106,7 @@ import javax.cache.event.*;
  * If you need to repeat execution, use {@link 
org.apache.ignite.internal.processors.cache.query.CacheQueries#createContinuousQuery()}
 method to create
  * new query.
  */
-// TODO: make class.
-public final class QueryContinuousPredicate<K, V> extends QueryPredicate<K, V> 
implements AutoCloseable {
+public final class QueryContinuousPredicate<K, V> extends QueryPredicate 
implements AutoCloseable {
     /**
      * Default buffer size. Size of {@code 1} means that all entries
      * will be sent to master node immediately (buffering is disabled).
@@ -124,7 +122,7 @@ public final class QueryContinuousPredicate<K, V> extends 
QueryPredicate<K, V> i
      */
     public static final boolean DFLT_AUTO_UNSUBSCRIBE = true;
 
-    public void setInitialPredicate(QueryPredicate<K, V> filter) {
+    public void setInitialPredicate(QueryPredicate filter) {
         // TODO: implement.
     }
 
@@ -204,9 +202,4 @@ public final class QueryContinuousPredicate<K, V> extends 
QueryPredicate<K, V> i
     @Override public void close() throws IgniteCheckedException {
         // TODO: implement.
     }
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(Cache.Entry<K, V> entry) {
-        return false; // TODO: CODE: implement.
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
index b221674..15ceb2e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryPredicate.java
@@ -17,20 +17,16 @@
 
 package org.apache.ignite.cache.query;
 
-import org.apache.ignite.lang.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 
-import javax.cache.*;
+import java.io.*;
 
 /**
  * Query predicate to pass into any of {@code Cache.query(...)} methods.
  * Use {@link QuerySqlPredicate} and {@link QueryTextPredicate} for SQL and
  * text queries accordingly.
- *
- * @author @java.author
- * @version @java.version
  */
-public abstract class QueryPredicate<K, V> implements 
IgnitePredicate<Cache.Entry<K, V>> {
+public abstract class QueryPredicate implements Serializable {
     /** Page size. */
     private int pageSize;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryReducer.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryReducer.java 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryReducer.java
deleted file mode 100644
index 376cd77..0000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryReducer.java
+++ /dev/null
@@ -1,41 +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.cache.query;
-
-/**
- * Remote query result reducer. Collects data entries and can produce multiple
- * results.
- */
-public interface QueryReducer<T, R> {
-    /**
-     * Collect next data entry.
-     *
-     * @param entry Data entry.
-     * @return {@code -1} If iteration over data set must be stopped and no 
result must be asked from the reducer,
-     *  {@code 0} if one of intermediate result is ready but iteration must 
continue if more data available,
-     *  {@code 1} if result is not ready and iteration must continue if more 
data available.
-     */
-    public int collect(T entry);
-
-    /**
-     * Get reduce result (possibly intermediate).
-     *
-     * @return Result of reduction.
-     */
-    public R reduce();
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
new file mode 100644
index 0000000..3aa6536
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryScanPredicate.java
@@ -0,0 +1,30 @@
+/*
+ * 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.cache.query;
+
+import org.apache.ignite.lang.*;
+
+/**
+ * Scan predicate over cache entries.
+ */
+public class QueryScanPredicate<K, V> extends QueryPredicate implements 
IgniteBiPredicate<K, V> {
+    /** {@inheritDoc} */
+    @Override public boolean apply(K k, V v) {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
new file mode 100644
index 0000000..d3439d7
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySpiPredicate.java
@@ -0,0 +1,62 @@
+/*
+ * 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.cache.query;
+
+import org.apache.ignite.spi.indexing.*;
+
+/**
+ * Predicate to be used by {@link GridIndexingSpi} implementations.
+ */
+public class QuerySpiPredicate extends QueryPredicate {
+    /** Arguments. */
+    private Object[] args;
+
+    /**
+     * Constructs SPI predicate.
+     */
+    public QuerySpiPredicate() {
+        // No-op.
+    }
+
+    /**
+     * Constructs SPI predicate with given arguments.
+     *
+     * @param args Arguments.
+     */
+    public QuerySpiPredicate(Object... args) {
+        this.args = args;
+    }
+
+    /**
+     * Gets SQL arguments.
+     *
+     * @return SQL arguments.
+     */
+    public Object[] getArgs() {
+        return args;
+    }
+
+    /**
+     * Sets SQL arguments.
+     *
+     * @param args SQL arguments.
+     */
+    public void setArgs(Object... args) {
+        this.args = args;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
index 264659f..921f384 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QuerySqlPredicate.java
@@ -19,16 +19,14 @@ package org.apache.ignite.cache.query;
 
 import org.apache.ignite.internal.util.typedef.internal.*;
 
-import javax.cache.*;
-
 /**
  * Query SQL predicate to use with any of the {@code JCache.query(...)} and
  * {@code JCache.queryFields(...)} methods.
- *
- * @author @java.author
- * @version @java.version
  */
-public final class QuerySqlPredicate<K, V> extends QueryPredicate<K, V> {
+public final class QuerySqlPredicate extends QueryPredicate {
+    /** */
+    private Class<?> type;
+
     /** SQL clause. */
     private String sql;
 
@@ -43,28 +41,26 @@ public final class QuerySqlPredicate<K, V> extends 
QueryPredicate<K, V> {
     }
 
     /**
-     * Constructs SQL predicate with given SQL clause and arguments.
+     * Constructs SQL predicate with given type, SQL clause and arguments.
      *
+     * @param type Class.
      * @param sql SQL clause.
      * @param args Arguments.
      */
-    public QuerySqlPredicate(String sql, Object... args) {
+    public QuerySqlPredicate(Class<?> type, String sql, Object... args) {
+        this.type = type;
         this.sql = sql;
         this.args = args;
     }
 
     /**
-     * Constructs SQL predicate with given SQL clause, page size, and 
arguments.
+     * Constructs SQL predicate with given SQL clause and arguments.
      *
      * @param sql SQL clause.
-     * @param pageSize Optional page size, if {@code 0}, then {@link 
QueryConfiguration#getPageSize()} is used.
      * @param args Arguments.
      */
-    public QuerySqlPredicate(String sql, int pageSize, Object[] args) {
-        super(pageSize);
-
-        this.sql = sql;
-        this.args = args;
+    public QuerySqlPredicate(String sql, Object... args) {
+        this(null, sql, args);
     }
 
     /**
@@ -103,9 +99,22 @@ public final class QuerySqlPredicate<K, V> extends 
QueryPredicate<K, V> {
         this.args = args;
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean apply(Cache.Entry<K, V> entry) {
-        return false; // Not used.
+    /**
+     * Gets type for query.
+     *
+     * @return Type.
+     */
+    public Class<?> getType() {
+        return type;
+    }
+
+    /**
+     * Sets type for query.
+     *
+     * @param type Type.
+     */
+    public void setType(Class<?> type) {
+        this.type = type;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
index d93d32c..c7614ba 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/cache/query/QueryTextPredicate.java
@@ -19,65 +19,58 @@ package org.apache.ignite.cache.query;
 
 import org.apache.ignite.internal.util.typedef.internal.*;
 
-import javax.cache.*;
-
 /**
- * TODO: Add class description.
- *
- * @author @java.author
- * @version @java.version
+ * Predicate for Lucene based fulltext search.
  */
-public final class QueryTextPredicate<K, V> extends QueryPredicate<K, V> {
+public final class QueryTextPredicate extends QueryPredicate {
+    /** */
+    private Class<?> type;
+
     /** SQL clause. */
     private String txt;
 
-    /** Arguments. */
-    private Object[] args;
-
-    public QueryTextPredicate(String txt, Object... args) {
+    /**
+     * @param txt Search string.
+     */
+    public QueryTextPredicate(Class<?> type, String txt) {
+        this.type = type;
         this.txt = txt;
-        this.args = args;
     }
 
     /**
-     * Gets text search string.
+     * Gets type for query.
      *
-     * @return Text search string.
+     * @return Type.
      */
-    public String getText() {
-        return txt;
+    public Class<?> getType() {
+        return type;
     }
 
     /**
-     * Sets text search string.
+     * Sets type for query.
      *
-     * @param txt Text search string.
+     * @param type Type.
      */
-    public void setText(String txt) {
-        this.txt = txt;
+    public void setType(Class<?> type) {
+        this.type = type;
     }
 
     /**
-     * Gets text search arguments.
+     * Gets text search string.
      *
-     * @return Text search arguments.
+     * @return Text search string.
      */
-    public Object[] getArgs() {
-        return args;
+    public String getText() {
+        return txt;
     }
 
     /**
-     * Sets text search arguments.
+     * Sets text search string.
      *
-     * @param args Text search arguments.
+     * @param txt Text search string.
      */
-    public void setArgs(Object... args) {
-        this.args = args;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean apply(Cache.Entry<K, V> entry) {
-        return false; // Not used.
+    public void setText(String txt) {
+        this.txt = txt;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 95da898..445c120 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.mxbean.*;
 import org.apache.ignite.internal.util.tostring.*;
@@ -232,9 +233,115 @@ public class IgniteCacheProxy<K, V> extends 
IgniteAsyncSupportAdapter<IgniteCach
     }
 
     /** {@inheritDoc} */
+    @Override public QueryCursor<Entry<K,V>> query(QueryPredicate filter) {
+        A.notNull(filter, "filter");
+
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            if (filter instanceof QuerySqlPredicate) {
+                // TODO query over entries on indexing
+
+                return null;
+            }
+
+            if (filter instanceof QueryScanPredicate) {
+                CacheQuery<Map.Entry<K,V>> res = 
delegate.queries().createScanQuery((IgniteBiPredicate<K,V>)filter);
+
+                // TODO convert to QueryCursor.
+                return null;
+            }
+
+            if (filter instanceof QueryTextPredicate) {
+                QueryTextPredicate p = (QueryTextPredicate)filter;
+
+                CacheQueryFuture<Map.Entry<K,V>> res = 
delegate.queries().createFullTextQuery(p.getType(), p.getText()).execute();
+
+                // TODO convert to QueryCursor.
+                return null;
+            }
+
+            throw new IgniteException("Unsupported query predicate: " + 
filter);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <Z> QueryCursor<Z> querySpi(QuerySpiPredicate filter) {
+        A.notNull(filter, "filter");
+
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            CacheQueryFuture<Object> res = 
((GridCacheQueriesEx)delegate.queries()).createSpiQuery()
+                .execute(filter.getArgs());
+
+            // TODO convert to QueryCursor.
+            return null;
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> QueryCursor<R> query(IgniteReducer<Entry<K,V>,R> 
rmtRdc, QueryPredicate filter) {
+        A.notNull(filter, "filter");
+        A.notNull(rmtRdc, "rmtRdc");
+
+        // TODO implement
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<List<?>> queryFields(QuerySqlPredicate 
filter) {
+        A.notNull(filter, "filter");
+
+        // TODO implement
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<Entry<K,V>> localQuery(QueryPredicate filter) 
{
+        A.notNull(filter, "filter");
+
+        // TODO implement
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<List<?>> localQueryFields(QuerySqlPredicate 
filter) {
+        A.notNull(filter, "filter");
+
+        // TODO implement
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... 
peekModes) throws CacheException {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            // TODO IGNITE-1.
+            throw new UnsupportedOperationException();
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryMetrics queryMetrics() {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return delegate.queries().metrics();
+        }
+        finally {
+            gate.leave(prev);
+        }
     }
 
     /** {@inheritDoc} */
@@ -951,48 +1058,6 @@ public class IgniteCacheProxy<K, V> extends 
IgniteAsyncSupportAdapter<IgniteCach
     }
 
     /** {@inheritDoc} */
-    @Override public QueryCursor<Entry<K, V>> query(QueryPredicate<K, V> 
filter) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public <R> QueryCursor<R> query(QueryReducer<Entry<K, V>, R> 
rmtRdc, QueryPredicate<K, V> filter) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public QueryCursor<List<?>> queryFields(QuerySqlPredicate<K, V> 
filter) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public <R> QueryCursor<R> queryFields(QueryReducer<List<?>, R> 
rmtRdc, QuerySqlPredicate<K, V> filter) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public QueryCursor<Entry<K, V>> localQuery(QueryPredicate<K, V> 
filter) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public QueryCursor<List<?>> 
localQueryFields(QuerySqlPredicate<K, V> filter) {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
-    @Override public QueryMetrics queryMetrics() {
-        // TODO IGNITE-1.
-        throw new UnsupportedOperationException();
-    }
-
-    /** {@inheritDoc} */
     @Override protected IgniteCache<K, V> createAsyncInstance() {
         return new IgniteCacheProxy<>(ctx, delegate, prj, true);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/58d01eba/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryCursorImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryCursorImpl.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryCursorImpl.java
index a871130..ca51d6f 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryCursorImpl.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryCursorImpl.java
@@ -56,9 +56,13 @@ public class QueryCursorImpl<T> implements QueryCursor<T> {
     @Override public List<T> getAll() {
         ArrayList<T> all = new ArrayList<>();
 
-        for (T t : this) all.add(t); // Implicitly calls iterator() to do all 
checks.
-
-        close();
+        try {
+            for (T t : this) // Implicitly calls iterator() to do all checks.
+                all.add(t);
+        }
+        finally {
+            close();
+        }
 
         return all;
     }

Reply via email to