ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [63/67] [abbrv] incubator-ignite git commit: ignite-gg9499 - wip
Date Fri, 16 Jan 2015 16:45:18 GMT
ignite-gg9499 - wip


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

Branch: refs/heads/ignite-gg9499
Commit: 7298090b6b32b4def69a67c2cab12f2db76af8ea
Parents: b18d6fb
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Fri Jan 16 12:43:42 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Fri Jan 16 12:43:42 2015 +0300

----------------------------------------------------------------------
 .../query/h2/sql/GridSqlQuerySplitter.java      | 35 +++++++++-----------
 1 file changed, 16 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7298090b/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
b/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
index deeeae0..2348bc9 100644
--- a/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
+++ b/modules/indexing/src/main/java/org/gridgain/grid/kernal/processors/query/h2/sql/GridSqlQuerySplitter.java
@@ -39,7 +39,7 @@ public class GridSqlQuerySplitter {
      * @param idx Index of column.
      * @return Generated by index column alias.
      */
-    private static String columnAlias(int idx) {
+    private static String columnName(int idx) {
         return COLUMN_PREFIX + idx;
     }
 
@@ -62,11 +62,7 @@ public class GridSqlQuerySplitter {
             return res;
         }
 
-        // Map query.
-        GridSqlSelect mapQry = srcQry.clone();
-
-        mapQry.clearSelect();
-
+        // Split all select expressions into map-reduce parts.
         List<GridSqlElement> mapExps = new ArrayList<>(srcQry.allExpressions());
 
         GridSqlElement[] rdcExps = new GridSqlElement[srcQry.select().size()];
@@ -74,18 +70,14 @@ public class GridSqlQuerySplitter {
         for (int i = 0, len = mapExps.size(); i < len; i++)
             splitSelectExpression(mapExps, rdcExps, i);
 
-        List<GridSqlAlias> aliases = new ArrayList<>(srcQry.allExpressions().size());
+        // Build map query.
+        GridSqlSelect mapQry = srcQry.clone();
+
+        mapQry.clearSelect();
 
         int idx = 0;
 
         for (GridSqlElement exp : mapExps) { // Add all expressions to select clause.
-            if (exp instanceof GridSqlColumn)
-                exp = alias(((GridSqlColumn)exp).columnName(), exp);
-            else if (!(exp instanceof GridSqlAlias))
-                exp = alias(columnAlias(idx), exp);
-
-            aliases.add((GridSqlAlias)exp);
-
             mapQry.addSelectExpression(exp);
 
             idx++;
@@ -128,7 +120,7 @@ public class GridSqlQuerySplitter {
         if (exp instanceof GridSqlAlias)
             return ((GridSqlAlias)exp).alias();
 
-        return columnAlias(idx);
+        return columnName(idx);
     }
 
     /**
@@ -158,7 +150,7 @@ public class GridSqlQuerySplitter {
 
                     // Add generated alias to COUNT(x).
                     // Using size as index since COUNT will be added as the last select element
to the map query.
-                    cntMap = alias(columnAlias(mapSelect.size()), cntMap);
+                    cntMap = alias(columnName(mapSelect.size()), cntMap);
 
                     mapSelect.add(cntMap);
 
@@ -166,7 +158,7 @@ public class GridSqlQuerySplitter {
                     GridSqlElement avgMap = aggregate(agg.distinct(), AVG).addChild(agg.child());
// Add function argument.
 
                     // Add generated alias to AVG(x).
-                    avgMap = alias(columnAlias(idx), avgMap);
+                    avgMap = alias(columnName(idx), avgMap);
 
                     mapSelect.set(idx, avgMap);
 
@@ -193,13 +185,18 @@ public class GridSqlQuerySplitter {
                 case MAX:
                 case MIN:
                 case SUM:
-                case GROUP_CONCAT:
                 default:
                     throw new IgniteException("Unsupported aggregate: " + agg.type());
             }
         }
-        else if (alias == null) {
+        else {
+            if (alias == null) { // Generate alias if none.
+                alias = alias(columnName(idx), mapSelect.get(idx));
+
+                mapSelect.set(idx, alias);
+            }
 
+            rdcSelect[idx] = column(alias.alias());
         }
     }
 


Mime
View raw message