You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/11/25 19:40:11 UTC

[8/8] ignite git commit: ignite-sql-opt-2 - minor review fixes

ignite-sql-opt-2 - minor review fixes


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

Branch: refs/heads/ignite-sql-opt-2
Commit: 123b9db8f4f4dc415aa397954128a2ad268fcc66
Parents: 91e1960
Author: S.Vladykin <sv...@gridgain.com>
Authored: Wed Nov 25 21:39:40 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Wed Nov 25 21:39:40 2015 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProperty.java     |  2 +-
 .../processors/query/h2/IgniteH2Indexing.java   | 35 +++++++++++---------
 .../processors/query/h2/sql/GridSqlSelect.java  | 18 +++-------
 .../h2/twostep/GridReduceQueryExecutor.java     | 22 ++++++------
 4 files changed, 37 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/123b9db8/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProperty.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProperty.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProperty.java
index 1b484c1..d623d25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProperty.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProperty.java
@@ -20,7 +20,7 @@ package org.apache.ignite.internal.processors.query;
 import org.apache.ignite.IgniteCheckedException;
 
 /**
- *
+ * Description and access method for query entity field.
  */
 public abstract class GridQueryProperty {
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/123b9db8/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 7c137d2..cc452c1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -183,7 +183,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     private static final int PREPARED_STMT_CACHE_SIZE = 256;
 
     /** */
-    private static final int TWO_STEP_QRY_CACHE_SIZE = 256;
+    private static final int TWO_STEP_QRY_CACHE_SIZE = 1024;
 
     /** Field name for key. */
     public static final String KEY_FIELD_NAME = "_key";
@@ -1003,27 +1003,32 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             PreparedStatement stmt;
 
             try {
-                stmt = prepareStatement(c, sqlQry, true);
+                // Do not cache this statement because the whole two step query object will be cached later on.
+                stmt = prepareStatement(c, sqlQry, false);
             }
             catch (SQLException e) {
                 throw new CacheException("Failed to parse query: " + sqlQry, e);
             }
-
             try {
-                bindParameters(stmt, F.asList(qry.getArgs()));
-            }
-            catch (IgniteCheckedException e) {
-                throw new CacheException("Failed to bind parameters: [qry=" + sqlQry + ", params=" +
-                    Arrays.deepToString(qry.getArgs()) + "]", e);
-            }
+                try {
+                    bindParameters(stmt, F.asList(qry.getArgs()));
+                }
+                catch (IgniteCheckedException e) {
+                    throw new CacheException("Failed to bind parameters: [qry=" + sqlQry + ", params=" +
+                        Arrays.deepToString(qry.getArgs()) + "]", e);
+                }
 
-            try {
-                twoStepQry = GridSqlQuerySplitter.split((JdbcPreparedStatement)stmt, qry.getArgs(), qry.isCollocated());
+                try {
+                    twoStepQry = GridSqlQuerySplitter.split((JdbcPreparedStatement)stmt, qry.getArgs(), qry.isCollocated());
 
-                meta = meta(stmt.getMetaData());
+                    meta = meta(stmt.getMetaData());
+                }
+                catch (SQLException e) {
+                    throw new CacheException(e);
+                }
             }
-            catch (SQLException e) {
-                throw new CacheException(e);
+            finally {
+                U.close(stmt, log);
             }
         }
 
@@ -2419,7 +2424,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
     }
 
     /**
-     *
+     * Statement cache.
      */
     private static class StatementCache extends LinkedHashMap<String, PreparedStatement> {
         /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/123b9db8/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
index ae522da..e190c87 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/sql/GridSqlSelect.java
@@ -118,21 +118,11 @@ public class GridSqlSelect extends GridSqlQuery {
 
         if (simple) {
             for (GridSqlElement expression : columns(true)) {
-                if (expression instanceof GridSqlColumn)
-                    continue;
+                if (expression instanceof GridSqlAlias)
+                    expression = expression.child();
 
-                if (expression instanceof GridSqlAlias) {
-                    if (expression.size() == 1) {
-                        GridSqlElement child = expression.child();
-
-                        if (child instanceof GridSqlColumn)
-                            continue;
-                    }
-                }
-
-                simple = false;
-
-                break;
+                if (!(expression instanceof GridSqlColumn))
+                    return false;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/123b9db8/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 cf54a4a..1d4fa30 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
@@ -605,21 +605,23 @@ public class GridReduceQueryExecutor {
                     if (skipMergeTbl) {
                         List<List<?>> res = new ArrayList<>();
 
-                        for (GridMergeIndex idx : r.idxs) {
-                            Cursor cur = idx.findInStream(null, null);
+                        assert r.idxs.size() == 1 : r.idxs;
 
-                            while (cur.next()) {
-                                Row row = cur.get();
+                        GridMergeIndex idx = r.idxs.get(0);
 
-                                int cols = row.getColumnCount();
+                        Cursor cur = idx.findInStream(null, null);
 
-                                List<Object> resRow  = new ArrayList<>(cols);
+                        while (cur.next()) {
+                            Row row = cur.get();
 
-                                for (int c = 0; c < cols; c++)
-                                    resRow .add(row.getValue(c).getObject());
+                            int cols = row.getColumnCount();
 
-                                res.add(resRow);
-                            }
+                            List<Object> resRow  = new ArrayList<>(cols);
+
+                            for (int c = 0; c < cols; c++)
+                                resRow.add(row.getValue(c).getObject());
+
+                            res.add(resRow);
                         }
 
                         resIter = res.iterator();