korlov42 commented on a change in pull request #213:
URL: https://github.com/apache/ignite-3/pull/213#discussion_r670196334



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/IgniteTableImpl.java
##########
@@ -0,0 +1,205 @@
+/*
+ * 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.schema;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.calcite.plan.Convention;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelReferentialConstraint;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.schema.Statistic;
+import org.apache.calcite.schema.impl.AbstractTable;
+import org.apache.calcite.util.ImmutableBitSet;
+import 
org.apache.ignite.internal.processors.query.calcite.exec.ExecutionContext;
+import 
org.apache.ignite.internal.processors.query.calcite.metadata.ColocationGroup;
+import 
org.apache.ignite.internal.processors.query.calcite.prepare.PlanningContext;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.logical.IgniteLogicalIndexScan;
+import 
org.apache.ignite.internal.processors.query.calcite.rel.logical.IgniteLogicalTableScan;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistribution;
+import 
org.apache.ignite.internal.processors.query.calcite.trait.RewindabilityTrait;
+import 
org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory;
+import org.jetbrains.annotations.Nullable;
+
+import static 
org.apache.ignite.internal.processors.query.calcite.Stubs.resultSetGenerator;
+
+/**
+ * Ignite table implementation.
+ */
+public class IgniteTableImpl extends AbstractTable implements IgniteTable {
+    /** */
+    private final TableDescriptor desc;
+
+    /** */
+    private final Statistic statistic;
+
+    /** */
+    private volatile Collection<Object[]> rows;
+
+    /** */
+    private final Map<String, IgniteIndex> indexes = new ConcurrentHashMap<>();
+
+    /**
+     * @param desc Table descriptor.
+     */
+    public IgniteTableImpl(TableDescriptor desc) {
+        this.desc = desc;
+        statistic = new StatisticsImpl();
+    }
+
+    /** {@inheritDoc} */
+    @Override public RelDataType getRowType(RelDataTypeFactory typeFactory, 
ImmutableBitSet requiredColumns) {
+        return desc.rowType((IgniteTypeFactory)typeFactory, requiredColumns);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Statistic getStatistic() {
+        return statistic;
+    }
+
+
+    /** {@inheritDoc} */
+    @Override public TableDescriptor descriptor() {
+        return desc;
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteLogicalTableScan toRel(RelOptCluster cluster, 
RelOptTable relOptTbl) {
+        RelTraitSet traitSet = cluster.traitSetOf(distribution())
+            .replace(RewindabilityTrait.REWINDABLE);
+
+        return IgniteLogicalTableScan.create(cluster, traitSet, relOptTbl, 
null, null, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteLogicalIndexScan toRel(RelOptCluster cluster, 
RelOptTable relOptTbl, String idxName) {
+        RelTraitSet traitSet = cluster.traitSetOf(Convention.Impl.NONE)
+            .replace(distribution())
+            .replace(RewindabilityTrait.REWINDABLE)
+            .replace(getIndex(idxName).collation());
+
+        return IgniteLogicalIndexScan.create(cluster, traitSet, relOptTbl, 
idxName, null, null, null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <Row> Iterable<Row> scan(
+        ExecutionContext<Row> execCtx,
+        ColocationGroup group,
+        Predicate<Row> filter,
+        Function<Row, Row> rowTransformer,
+        @Nullable ImmutableBitSet usedColumns) {
+        String locNodeId = execCtx.planningContext().localNodeId();
+        if (group.nodeIds().contains(locNodeId))

Review comment:
       fixed




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to