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/11/18 06:44:30 UTC

[GitHub] [ignite] Berkof commented on a change in pull request #8421: IGNITE-13541 Calcite integration. Support of Date/Time types

Berkof commented on a change in pull request #8421:
URL: https://github.com/apache/ignite/pull/8421#discussion_r525847575



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/metadata/ColocationGroup.java
##########
@@ -0,0 +1,342 @@
+/*
+ * 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.metadata;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.internal.GridDirectCollection;
+import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
+import org.apache.ignite.internal.processors.query.calcite.message.MarshalableMessage;
+import org.apache.ignite.internal.processors.query.calcite.message.MarshallingContext;
+import org.apache.ignite.internal.processors.query.calcite.message.MessageType;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
+import org.apache.ignite.internal.processors.query.calcite.util.Commons;
+import org.apache.ignite.internal.util.GridIntList;
+import org.apache.ignite.internal.util.UUIDCollectionMessage;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.jetbrains.annotations.NotNull;
+
+/** */
+public class ColocationGroup implements MarshalableMessage {
+    /** */
+    private static final int SYNTHETIC_PARTITIONS_COUNT = IgniteSystemProperties.getInteger("IGNITE_CALCITE_SYNTHETIC_PARTITIONS_COUNT", 512);
+
+    /** */
+    @GridDirectCollection(Long.class)
+    private List<Long> sourceIds;
+
+    /** */
+    @GridDirectCollection(UUID.class)
+    private List<UUID> nodeIds;
+
+    /** */
+    @GridDirectTransient
+    private List<List<UUID>> assignments;
+
+    /** */
+    @GridDirectCollection(Message.class)
+    private List<UUIDCollectionMessage> assignments0;
+
+    public static ColocationGroup forNodes(List<UUID> nodeIds) {
+        return new ColocationGroup(null, nodeIds, null);
+    }
+
+    public static ColocationGroup forAssignments(List<List<UUID>> assignments) {
+        return new ColocationGroup(null, null, assignments);
+    }
+
+    public static ColocationGroup forSourceId(long sourceId) {
+        return new ColocationGroup(Collections.singletonList(sourceId), null, null);
+    }
+
+    /** */
+    public ColocationGroup() {
+    }
+
+    /** */
+    private ColocationGroup(List<Long> sourceIds, List<UUID> nodeIds, List<List<UUID>> assignments) {
+        this.sourceIds = sourceIds;
+        this.nodeIds = nodeIds;
+        this.assignments = assignments;
+    }
+
+    /**
+     * @return Lists of colocation group sources.
+     */
+    public List<Long> sourceIds() {
+        return sourceIds == null ? Collections.emptyList() : sourceIds;
+    }
+
+    /**
+     * @return Lists of nodes capable to execute a query fragment for what the mapping is calculated.
+     */
+    public List<UUID> nodeIds() {
+        return nodeIds == null ? Collections.emptyList() : nodeIds;
+    }
+
+    /**
+     * @return List of partitions (index) and nodes (items) having an appropriate partition in
+     * {@link GridDhtPartitionState#OWNING} state, calculated for distributed tables, involved in query execution.
+     */
+    public List<List<UUID>> assignments() {
+        return assignments == null ? Collections.emptyList() : assignments;
+    }
+
+    /**
+     * Prunes involved partitions (hence nodes, involved in query execution) on the basis of filter,
+     * its distribution, query parameters and original nodes mapping.
+     * @param rel Filter.
+     * @return Resulting nodes mapping.
+     */
+    public ColocationGroup prune(IgniteRel rel) {
+        return this; // TODO https://issues.apache.org/jira/browse/IGNITE-12455
+    }
+
+    public boolean belongs(long sourceId) {
+        return sourceIds != null && sourceIds.contains(sourceId);
+    }
+
+    /**
+     * Merges this mapping with given one.
+     * @param other Mapping to merge with.
+     * @return Merged nodes mapping.
+     * @throws ColocationMappingException If involved nodes intersection is empty, hence there is no nodes capable to execute
+     * being calculated fragment.
+     */
+    public ColocationGroup colocate(ColocationGroup other) throws ColocationMappingException {
+        List<Long> sourceIds;
+        if (this.sourceIds == null || other.sourceIds == null)
+            sourceIds = U.firstNotNull(this.sourceIds, other.sourceIds);
+        else
+            sourceIds = Commons.combine(this.sourceIds, other.sourceIds);
+
+        List<UUID> nodeIds;
+        if (this.nodeIds == null || other.nodeIds == null)
+            nodeIds = U.firstNotNull(this.nodeIds, other.nodeIds);
+        else
+            nodeIds = Commons.intersect(other.nodeIds, this.nodeIds);
+
+        if (nodeIds!= null && nodeIds.isEmpty())

Review comment:
       Space before !=




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