You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "alex-plekhanov (via GitHub)" <gi...@apache.org> on 2023/08/03 12:54:14 UTC

[GitHub] [ignite] alex-plekhanov commented on a diff in pull request #10870: IGNITE-19998 SQL Calcite: Add support of setting partitions in SqlFieldsQuery

alex-plekhanov commented on code in PR #10870:
URL: https://github.com/apache/ignite/pull/10870#discussion_r1283130727


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java:
##########
@@ -466,12 +467,12 @@ protected AffinityTopologyVersion topologyVersion() {
     }
 
     /** */
-    private BaseQueryContext createQueryContext(Context parent, @Nullable String schema) {
+    private BaseQueryContext createQueryContext(Context parent, QueryStartRequest msg) {

Review Comment:
   Looks like now this change is redundant



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java:
##########
@@ -228,6 +228,27 @@ public ColocationGroup finalaze() {
         return forNodes0(nodeIds);
     }
 
+    /** */
+    public ColocationGroup filterForPartitions(int[] parts) {
+        if (assignments != null) {
+            List<List<UUID>> assignments = new ArrayList<>(this.assignments.size());
+            Set<UUID> nodes = new HashSet<>();
+
+            for (int i = 0; i < this.assignments.size(); ++i) {
+                UUID first = F.isEmpty(parts) || Arrays.binarySearch(parts, i) >= 0 ? F.first(this.assignments.get(i)) : null;
+
+                if (first != null)
+                    nodes.add(first);
+
+                assignments.add(first != null ? Collections.singletonList(first) : Collections.emptyList());

Review Comment:
   Assignment should already be finilized and can contain only 1 value in the list. We can use original `assignments.get(i)` instead of building new singleton list (reduce GC pressure a little bit).



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java:
##########
@@ -228,6 +228,27 @@ public ColocationGroup finalaze() {
         return forNodes0(nodeIds);
     }
 
+    /** */
+    public ColocationGroup filterForPartitions(int[] parts) {

Review Comment:
   Why can't we use the same naming for ColocationGroup, Fragment and FragmentMapping? (`filterForPartitions`, `filterByPartitions`)



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryWithPartitionsIntegrationTest.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * 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.query.calcite.integration;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import com.google.common.collect.ImmutableList;
+import org.apache.calcite.util.Pair;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.calcite.CalciteQueryEngineConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.query.QueryContext;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ *
+ */
+@RunWith(Parameterized.class)
+public class QueryWithPartitionsIntegrationTest extends AbstractBasicIntegrationTest {
+    /**
+     *

Review Comment:
   Let's use `/** */` style comments if we don't add any text (in the whole file) 



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java:
##########
@@ -228,6 +228,27 @@ public ColocationGroup finalaze() {
         return forNodes0(nodeIds);
     }
 
+    /** */
+    public ColocationGroup filterForPartitions(int[] parts) {
+        if (assignments != null) {
+            List<List<UUID>> assignments = new ArrayList<>(this.assignments.size());
+            Set<UUID> nodes = new HashSet<>();
+
+            for (int i = 0; i < this.assignments.size(); ++i) {
+                UUID first = F.isEmpty(parts) || Arrays.binarySearch(parts, i) >= 0 ? F.first(this.assignments.get(i)) : null;

Review Comment:
   1. `F.isEmpty(parts)` can be checked once (together with assignment check)
   2. We can't be sure that `parts` is sorted, this variable is passed by user. Perhaps it's better to build BitSet and use it to filter partitions. 



##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/BaseQueryContext.java:
##########
@@ -335,13 +353,23 @@ public Builder local(boolean isLocal) {
             return this;
         }
 
+        /**
+         *

Review Comment:
   Let's use `/** */` style comments if we don't add any text.



##########
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/QueryWithPartitionsIntegrationTest.java:
##########
@@ -0,0 +1,302 @@
+/*
+ * 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.query.calcite.integration;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+import com.google.common.collect.ImmutableList;
+import org.apache.calcite.util.Pair;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.calcite.CalciteQueryEngineConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.query.QueryContext;
+import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
+import org.apache.ignite.internal.util.typedef.F;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ *
+ */
+@RunWith(Parameterized.class)
+public class QueryWithPartitionsIntegrationTest extends AbstractBasicIntegrationTest {
+    /**
+     *
+     */
+    private static final int ENTRIES_COUNT = 10000;
+
+    /** */
+    private final int[] parts = IntStream.range(0, 128).toArray();

Review Comment:
   Can we add at least one test with different parts values?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org