xingtanzjr commented on code in PR #9818:
URL: https://github.com/apache/iotdb/pull/9818#discussion_r1190008192


##########
server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileResourceList.java:
##########
@@ -143,43 +143,43 @@ public boolean keepOrderInsert(TsFileResource newNode) 
throws IOException {
       return false;
     }
     if (tail == null) {
+      // empty list
       header = newNode;
       tail = newNode;
       count++;
     } else {
-      // find the position to insert of this node
-      // the list should be ordered by file timestamp
-      long versionOfNewNode =
-          
TsFileNameGenerator.getTsFileName(newNode.getTsFile().getName()).getVersion();
-
-      if 
(TsFileNameGenerator.getTsFileName(header.getTsFile().getName()).getVersion()
-          > versionOfNewNode) {
-        // the timestamp of head node is greater than the new node
-        // insert it before the head
-        insertBefore(header, newNode);
-      } else if 
(TsFileNameGenerator.getTsFileName(tail.getTsFile().getName()).getVersion()
-          < versionOfNewNode) {
-        // the timestamp of new node is greater than the tail node
-        // insert it after the tail
+      TsFileNameGenerator.TsFileName newTsFileName =
+          TsFileNameGenerator.getTsFileName(newNode.getTsFile().getName());
+      long timestampOfNewNode = newTsFileName.getTime();
+      long versionOfNewNode = newTsFileName.getVersion();
+
+      // find the position to insert, the list should be ordered by file 
timestamp. If timestamp is
+      // equal to each other, then list should be ordered by file version.
+      boolean isNewNodeAtTail = true;

Review Comment:
   Actually this var is unnecessary. We can use curNode's null value to infer 
whether the new node should be inserted at tail or not



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