You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/24 14:51:09 UTC

[GitHub] [iotdb] MarcosZyk commented on a diff in pull request #5976: [IOTDB-3216]Refactor Segments in SchemaFile to B+ Tree structure from list structure

MarcosZyk commented on code in PR #5976:
URL: https://github.com/apache/iotdb/pull/5976#discussion_r880612951


##########
server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/ISchemaPage.java:
##########
@@ -122,4 +119,21 @@ long transplantSegment(ISchemaPage srcPage, short segId, short newSegSize)
   long getPrevSegAddress(short segId) throws SegmentNotFoundException;
 
   String inspect() throws SegmentNotFoundException;
+
+  // TODO: methods below should belong to ISegment interface after abstraction refactor
+  //  along with methods that insert/remove/get records, seg/get segment address
+
+  String splitLeafSegment(String key, ByteBuffer recBuf, ISchemaPage dstPage, boolean inclineSplit)
+      throws MetadataException;
+
+  String splitInternalSegment(String key, int ptr, ISchemaPage dstPage, boolean inclineSplit)
+      throws MetadataException;

Review Comment:
   The behavior of different segment should be split to specific interface, rather than gather in one basic interface.



##########
server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/SchemaPage.java:
##########
@@ -289,15 +293,45 @@ public short allocNewSegment(short size) throws IOException, SchemaPageOverflowE
     return thisIndex;
   }
 
+  /**
+   * Allocate all space of the page to construct an {@link InternalSegment}. <br>
+   * This method will modify nearly all status of the page, making a poor encapsulation.
+   */
+  @Override
+  public synchronized short allocInternalSegment(int ptr) throws SchemaPageOverflowException {
+    // any segment left (even internal) will stop allocating InternalSegment
+    for (Short off : segOffsetLst) {

Review Comment:
   Suggest refactor abstraction since this encapsulation may cause exceptions with incautious call



##########
server/src/main/java/org/apache/iotdb/db/metadata/mtree/store/disk/schemafile/SPage.java:
##########
@@ -0,0 +1,21 @@
+/*
+ * 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.iotdb.db.metadata.mtree.store.disk.schemafile;
+
+public abstract class SPage {}

Review Comment:
   What is this empty abstract class for?



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org