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/08/17 10:54:37 UTC

[GitHub] [ignite-3] SammyVimes commented on a diff in pull request #1015: IGNITE-17533 Implement a meta B+Tree of indexes

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


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/meta/io/IndexMetaInnerIo.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.meta.io;
+
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.tree.BplusTree;
+import org.apache.ignite.internal.pagememory.tree.io.BplusInnerIo;
+import org.apache.ignite.internal.pagememory.tree.io.BplusIo;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMeta;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMetaTree;
+
+/**
+ * IO routines for {@link IndexMetaTree} inner pages.
+ */
+public class IndexMetaInnerIo extends BplusInnerIo<IndexMeta> implements IndexMetaIo {
+    /** Page IO type. */
+    public static final short T_INDEX_META_INNER_IO = 15;
+
+    /** I/O versions. */
+    public static final IoVersions<IndexMetaInnerIo> VERSIONS = new IoVersions<>(new IndexMetaInnerIo(1));
+
+    /**
+     * Constructor.
+     *
+     * @param ver Page format version.
+     */
+    private IndexMetaInnerIo(int ver) {
+        super(T_INDEX_META_INNER_IO, ver, true, SIZE_IN_BYTES);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void store(long dstPageAddr, int dstIdx, BplusIo<IndexMeta> srcIo, long srcPageAddr, int srcIdx) {

Review Comment:
   why override if we call a default method from the interface?



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/meta/io/IndexMetaLeafIo.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.meta.io;
+
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.tree.BplusTree;
+import org.apache.ignite.internal.pagememory.tree.io.BplusIo;
+import org.apache.ignite.internal.pagememory.tree.io.BplusLeafIo;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMeta;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMetaTree;
+
+/**
+ * IO routines for {@link IndexMetaTree} leaf pages.
+ */
+public class IndexMetaLeafIo extends BplusLeafIo<IndexMeta> implements IndexMetaIo {
+    /** Page IO type. */
+    public static final short T_INDEX_META_LEAF_IO = 14;
+
+    /** I/O versions. */
+    public static final IoVersions<IndexMetaLeafIo> VERSIONS = new IoVersions<>(new IndexMetaLeafIo(1));
+
+    /**
+     * Constructor.
+     *
+     * @param ver Page format version.
+     */
+    private IndexMetaLeafIo(int ver) {
+        super(T_INDEX_META_LEAF_IO, ver, SIZE_IN_BYTES);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void store(long dstPageAddr, int dstIdx, BplusIo<IndexMeta> srcIo, long srcPageAddr, int srcIdx) {
+        IndexMetaIo.super.store(dstPageAddr, dstIdx, srcPageAddr, srcIdx);

Review Comment:
   Same question about override



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/meta/io/IndexMetaInnerIo.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.meta.io;
+
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.tree.BplusTree;
+import org.apache.ignite.internal.pagememory.tree.io.BplusInnerIo;
+import org.apache.ignite.internal.pagememory.tree.io.BplusIo;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMeta;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMetaTree;
+
+/**
+ * IO routines for {@link IndexMetaTree} inner pages.
+ */
+public class IndexMetaInnerIo extends BplusInnerIo<IndexMeta> implements IndexMetaIo {
+    /** Page IO type. */
+    public static final short T_INDEX_META_INNER_IO = 15;
+
+    /** I/O versions. */
+    public static final IoVersions<IndexMetaInnerIo> VERSIONS = new IoVersions<>(new IndexMetaInnerIo(1));
+
+    /**
+     * Constructor.
+     *
+     * @param ver Page format version.
+     */
+    private IndexMetaInnerIo(int ver) {
+        super(T_INDEX_META_INNER_IO, ver, true, SIZE_IN_BYTES);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void store(long dstPageAddr, int dstIdx, BplusIo<IndexMeta> srcIo, long srcPageAddr, int srcIdx) {
+        IndexMetaIo.super.store(dstPageAddr, dstIdx, srcPageAddr, srcIdx);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void storeByOffset(long pageAddr, int off, IndexMeta row) {
+        IndexMetaIo.super.storeByOffset(pageAddr, off, row);

Review Comment:
   Same question about override



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/meta/io/IndexMetaIo.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * 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.meta.io;
+
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
+
+import java.util.UUID;
+import org.apache.ignite.internal.pagememory.tree.io.BplusIo;
+import org.apache.ignite.internal.pagememory.util.PageUtils;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMeta;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMetaTree;
+
+/**
+ * Interface for {@link IndexMeta} B+Tree-related IO.
+ *
+ * <p>Defines a following data layout:
+ * <ul>
+ *     <li>Index ID - {@link UUID} (16 bytes);</li>
+ *     <li>Index root page ID - long (8 bytes).</li>
+ * </ul>
+ */
+public interface IndexMetaIo {
+    /** Offset of the {@link UUID#getMostSignificantBits() most significant bits} of the index ID (8 bytes). */
+    int INDEX_ID_MSB_OFFSET = 0;
+
+    /** Offset of the {@link UUID#getLeastSignificantBits() least significant bits} of the index ID (8 bytes). */
+    int INDEX_ID_LSB_OFFSET = INDEX_ID_MSB_OFFSET + Long.BYTES;
+
+    /** Index root page ID offset - long (8 bytes). */
+    int INDEX_ROOT_PAGE_ID_OFFSET = INDEX_ID_LSB_OFFSET + Long.BYTES;
+
+    /** Payload size in bytes. */
+    int SIZE_IN_BYTES = INDEX_ROOT_PAGE_ID_OFFSET + Long.BYTES;

Review Comment:
   It's a matter of taste, but I don't really like that size is calculated from offset. But I'll leave it up to you



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/meta/io/IndexMetaLeafIo.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.meta.io;
+
+import org.apache.ignite.internal.pagememory.io.IoVersions;
+import org.apache.ignite.internal.pagememory.tree.BplusTree;
+import org.apache.ignite.internal.pagememory.tree.io.BplusIo;
+import org.apache.ignite.internal.pagememory.tree.io.BplusLeafIo;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMeta;
+import org.apache.ignite.internal.storage.pagememory.index.meta.IndexMetaTree;
+
+/**
+ * IO routines for {@link IndexMetaTree} leaf pages.
+ */
+public class IndexMetaLeafIo extends BplusLeafIo<IndexMeta> implements IndexMetaIo {
+    /** Page IO type. */
+    public static final short T_INDEX_META_LEAF_IO = 14;
+
+    /** I/O versions. */
+    public static final IoVersions<IndexMetaLeafIo> VERSIONS = new IoVersions<>(new IndexMetaLeafIo(1));
+
+    /**
+     * Constructor.
+     *
+     * @param ver Page format version.
+     */
+    private IndexMetaLeafIo(int ver) {
+        super(T_INDEX_META_LEAF_IO, ver, SIZE_IN_BYTES);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void store(long dstPageAddr, int dstIdx, BplusIo<IndexMeta> srcIo, long srcPageAddr, int srcIdx) {
+        IndexMetaIo.super.store(dstPageAddr, dstIdx, srcPageAddr, srcIdx);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void storeByOffset(long pageAddr, int off, IndexMeta row) {
+        IndexMetaIo.super.storeByOffset(pageAddr, off, row);

Review Comment:
   Same question about override



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/meta/IndexMeta.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.meta;
+
+import java.util.UUID;
+import org.apache.ignite.internal.tostring.IgniteToStringInclude;
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Index tree meta information.
+ */
+public class IndexMeta {
+    @IgniteToStringInclude
+    private final UUID id;
+
+    private final long rootPageId;

Review Comment:
   Why not add root page id for logging purposes?



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