HeimingZ commented on code in PR #12271:
URL: https://github.com/apache/iotdb/pull/12271#discussion_r1582147106


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java:
##########
@@ -1105,18 +1103,15 @@ private void 
tryToUpdateInsertTabletLastCache(InsertTabletNode node) {
             latestFlushedTime);
   }
 
-  private void insertToTsFileProcessor(
-      InsertRowNode insertRowNode,
-      boolean sequence,
-      long timePartitionId,
-      Map<TsFileProcessor, Boolean> tsFileProcessorMapForFlushing)
+  private TsFileProcessor insertToTsFileProcessor(
+      InsertRowNode insertRowNode, boolean sequence, long timePartitionId)
       throws WriteProcessException {
     if (insertRowNode.allMeasurementFailed()) {
-      return;
+      return null;
     }
     TsFileProcessor tsFileProcessor = 
getOrCreateTsFileProcessor(timePartitionId, sequence);
     if (tsFileProcessor == null) {
-      return;
+      return null;
     }

Review Comment:
   Maybe we can use `if (tsFileProcessor == null || 
insertRowNode.allMeasurementFailed())` to join two if clauses.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/recover/WALNodeRecoverTask.java:
##########
@@ -155,7 +155,8 @@ private long[] recoverLastFile() {
         WALEntry walEntry = walReader.next();
         long searchIndex = DEFAULT_SEARCH_INDEX;
         if (walEntry.getType() == WALEntryType.INSERT_TABLET_NODE
-            || walEntry.getType() == WALEntryType.INSERT_ROW_NODE) {
+            || walEntry.getType() == WALEntryType.INSERT_ROW_NODE
+            || walEntry.getType() == WALEntryType.INSERT_ROWS_NODE) {

Review Comment:
   There is a bug here, I forgot consider DeleteDataNode here. To fix this, 
please use WALEntryType.needSearch and consider the search index of 
DeleteDataNode.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java:
##########
@@ -885,16 +885,14 @@ public void insert(InsertRowNode insertRowNode) throws 
WriteProcessException {
               && insertRowNode.getTime()
                   > lastFlushTimeMap.getFlushedTime(timePartitionId, 
insertRowNode.getDeviceID());
 
-      Map<TsFileProcessor, Boolean> tsFileProcessorMapForFlushing = new 
HashMap<>();
-
       // insert to sequence or unSequence file
-      insertToTsFileProcessor(
-          insertRowNode, isSequence, timePartitionId, 
tsFileProcessorMapForFlushing);
+      TsFileProcessor tsFileProcessor =
+          insertToTsFileProcessor(insertRowNode, isSequence, timePartitionId);
 
       // check memtable size and may asyncTryToFlush the work memtable
-      for (Map.Entry<TsFileProcessor, Boolean> entry : 
tsFileProcessorMapForFlushing.entrySet()) {
-        if (entry.getKey().shouldFlush()) {
-          fileFlushPolicy.apply(this, entry.getKey(), entry.getValue());
+      if (tsFileProcessor != null) {
+        if (tsFileProcessor.shouldFlush()) {

Review Comment:
   Maybe `if (tsFileProcessor != null && tsFileProcessor.shouldFlush())` is 
better.



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