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 2022/09/22 09:38:16 UTC

[GitHub] [ignite-3] SammyVimes commented on a diff in pull request #1078: IGNITE-17320 Implement B+Tree based sorted index storage

SammyVimes commented on code in PR #1078:
URL: https://github.com/apache/ignite-3/pull/1078#discussion_r976402417


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/sorted/PageMemorySortedIndexStorage.java:
##########
@@ -0,0 +1,138 @@
+/*
+ * 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.storage.pagememory.index.sorted;
+
+import org.apache.ignite.internal.pagememory.metric.IoStatisticsHolderNoOp;
+import org.apache.ignite.internal.schema.BinaryTuple;
+import org.apache.ignite.internal.schema.BinaryTuplePrefix;
+import org.apache.ignite.internal.storage.RowId;
+import org.apache.ignite.internal.storage.StorageException;
+import org.apache.ignite.internal.storage.index.IndexRow;
+import org.apache.ignite.internal.storage.index.SortedIndexDescriptor;
+import org.apache.ignite.internal.storage.index.SortedIndexStorage;
+import org.apache.ignite.internal.storage.pagememory.index.freelist.IndexColumns;
+import org.apache.ignite.internal.storage.pagememory.index.freelist.IndexColumnsFreeList;
+import org.apache.ignite.internal.storage.pagememory.util.TreeCursorAdapter;
+import org.apache.ignite.internal.util.Cursor;
+import org.apache.ignite.internal.util.IgniteCursor;
+import org.apache.ignite.lang.IgniteInternalCheckedException;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Sorted index storage implementation.
+ */
+public class PageMemorySortedIndexStorage implements SortedIndexStorage {
+    /** Index descriptor. */
+    private final SortedIndexDescriptor descriptor;
+
+    /** Free list to store index columns. */
+    private final IndexColumnsFreeList freeList;
+
+    /** Sorted index tree instance. */
+    private final SortedIndexTree sortedIndexTree;
+
+    /** Partition id. */
+    private final int partitionId;
+
+    /**
+     * Constructor.
+     *
+     * @param descriptor Sorted index descriptor.
+     * @param freeList Free list to store index columns.
+     * @param sortedIndexTree Sorted index tree instance.
+     */
+    public PageMemorySortedIndexStorage(SortedIndexDescriptor descriptor, IndexColumnsFreeList freeList, SortedIndexTree sortedIndexTree) {
+        this.descriptor = descriptor;
+        this.freeList = freeList;
+        this.sortedIndexTree = sortedIndexTree;
+
+        partitionId = sortedIndexTree.partitionId();
+    }
+
+    @Override
+    public SortedIndexDescriptor indexDescriptor() {
+        return descriptor;
+    }
+
+    @Override
+    public void put(IndexRow row) {
+        IndexColumns indexColumns = new IndexColumns(partitionId, row.indexColumns().byteBuffer());
+
+        try {
+            SortedIndexRow sortedIndexRow = new SortedIndexRow(indexColumns, row.rowId());
+
+            var insert = new InsertSortedIndexRowInvokeClosure(sortedIndexRow, freeList, IoStatisticsHolderNoOp.INSTANCE);

Review Comment:
   Should this statistics holder be a field of this class? 
   
   Something like
   
   `private IoStatisticsHolder statHolder = IoStatisticsHolderNoOp.INSTANCE;`



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