You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/04/16 12:10:32 UTC

[GitHub] [ignite] rkondakov commented on a change in pull request #7673: IGNITE-12864: Calcite integration. UNION support.

rkondakov commented on a change in pull request #7673: IGNITE-12864: Calcite integration. UNION support.
URL: https://github.com/apache/ignite/pull/7673#discussion_r409505004
 
 

 ##########
 File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/trait/DistributionTrait.java
 ##########
 @@ -139,14 +139,34 @@
 
     /** {@inheritDoc} */
     @Override public IgniteDistribution apply(Mappings.TargetMapping mapping) {
-        if (keys.isEmpty())
+        if (getType() != HASH_DISTRIBUTED)
             return this;
 
-        assert getType() == HASH_DISTRIBUTED;
+        if (mapping.getTargetCount() < keys.size())
+            IgniteDistributions.random();
 
-        ImmutableIntList newKeys = IgniteDistributions.projectDistributionKeys(mapping, keys);
+        int[] map = new int[mapping.getSourceCount()];
+        int[] res = new int[keys.size()];
 
-        return newKeys.isEmpty() ? IgniteDistributions.random() : IgniteDistributions.hash(newKeys, function);
+        for (int i = 0; i < keys.size(); i++)
+            map[keys.getInt(i)] = i + 1;
+
+        for (int i = 0, found = 0; i < mapping.getTargetCount(); i++) {
+            int source = mapping.getSourceOpt(i);
+            int keyPos = map[source] - 1;
+
+            if (keyPos == -1)
+                continue;
+
+            res[keyPos] = i;
+
+            if (++found == keys.size())
+                return IgniteDistributions.hash(ImmutableIntList.of(res), function);
 
 Review comment:
   isn't it the same as `Mappings.apply2`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services