AMashenkov commented on a change in pull request #518:
URL: https://github.com/apache/ignite-3/pull/518#discussion_r775486216



##########
File path: 
modules/index/src/main/java/org/apache/ignite/internal/idx/InternalSortedIndexImpl.java
##########
@@ -0,0 +1,270 @@
+/*
+ * 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.idx;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.schema.BinaryRow;
+import org.apache.ignite.internal.schema.Column;
+import org.apache.ignite.internal.storage.index.IndexBinaryRow;
+import org.apache.ignite.internal.storage.index.IndexRow;
+import org.apache.ignite.internal.storage.index.SortedIndexColumnDescriptor;
+import org.apache.ignite.internal.storage.index.SortedIndexStorage;
+import org.apache.ignite.internal.table.StorageRowListener;
+import org.apache.ignite.internal.table.TableImpl;
+import org.apache.ignite.internal.table.TableRow;
+import org.apache.ignite.internal.util.Cursor;
+import org.apache.ignite.lang.IgniteInternalException;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.table.Tuple;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Internal index manager facade provides low-level methods for indexes 
operations.
+ */
+public class InternalSortedIndexImpl implements InternalSortedIndex, 
StorageRowListener {
+    private final IgniteUuid id;
+
+    private final String name;
+
+    private final TableImpl tbl;
+
+    private final SortedIndexStorage store;
+
+    /**
+     * Create sorted index.
+     */
+    public InternalSortedIndexImpl(IgniteUuid id, String name, 
SortedIndexStorage store, TableImpl tbl) {
+        this.id = id;
+        this.name = name;
+        this.store = store;
+        this.tbl = tbl;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public IgniteUuid id() {
+        return id;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String name() {
+        return name;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String tableName() {
+        return tbl.name();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List<Column> columns() {
+        return store.indexDescriptor().columns().stream()
+                .map(SortedIndexColumnDescriptor::column)
+                .collect(Collectors.toList());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Cursor<Tuple> scan(Tuple low, Tuple up, byte scanBoundMask, BitSet 
proj) {
+        Cursor<IndexRow> cur = store.range(
+                low != null ? new IndexSearchRow(low) : null,
+                up != null ? new IndexSearchRow(up) : null,
+                r -> true
+        );
+
+        List<String> tblColIds = new 
ArrayList<>(tbl.schemaView().schema().columnNames());
+        Set<String> idxColIds = 
columns().stream().map(Column::name).collect(Collectors.toSet());

Review comment:
       Column names can be cached in the class fields.




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