You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/03/27 15:45:09 UTC

[iotdb] 02/11: Spotless

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch InsertTabletNode
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit a89b94ecd8c4e0ff193aa9e4fa01a0a20c59bdca
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu Mar 24 15:48:57 2022 +0800

    Spotless
---
 .../org/apache/iotdb/db/engine/StorageEngine.java  |  5 +-
 .../iotdb/db/engine/memtable/AbstractMemTable.java | 68 +++++++++---------
 .../apache/iotdb/db/engine/memtable/IMemTable.java |  4 +-
 .../db/engine/storagegroup/TsFileProcessor.java    | 58 +++++++--------
 .../storagegroup/VirtualStorageGroupProcessor.java | 82 +++++++++++-----------
 .../sql/planner/plan/node/write/InsertNode.java    |  1 -
 .../java/org/apache/iotdb/db/utils/MemUtils.java   |  4 +-
 7 files changed, 111 insertions(+), 111 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
index 674c5cf..b877735 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
@@ -650,8 +650,9 @@ public class StorageEngine implements IService {
   }
 
   /** insert an InsertTabletNode to a storage group */
-  public void insertTabletV2(VirtualStorageGroupProcessor virtualStorageGroupProcessor, InsertTabletNode insertTabletNode)
-          throws StorageEngineException, BatchProcessException, MetadataException {
+  public void insertTabletV2(
+      VirtualStorageGroupProcessor virtualStorageGroupProcessor, InsertTabletNode insertTabletNode)
+      throws StorageEngineException, BatchProcessException, MetadataException {
     if (enableMemControl) {
       try {
         blockInsertionIfReject(null);
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java b/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
index 75787c1..38be207 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/memtable/AbstractMemTable.java
@@ -281,9 +281,9 @@ public abstract class AbstractMemTable implements IMemTable {
 
   @Override
   public void insertTablet(InsertTabletNode insertTabletNode, int start, int end)
-          throws WriteProcessException {
+      throws WriteProcessException {
     // TODO: PlanIndex
-    //updatePlanIndexes(insertTabletPlan.getIndex());
+    // updatePlanIndexes(insertTabletPlan.getIndex());
     updatePlanIndexes(0);
     try {
       write(insertTabletNode, start, end);
@@ -292,13 +292,13 @@ public abstract class AbstractMemTable implements IMemTable {
       totalPointsNum += pointsInserted;
       if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
         MetricsService.getInstance()
-                .getMetricManager()
-                .count(
-                        pointsInserted,
-                        Metric.QUANTITY.toString(),
-                        MetricLevel.IMPORTANT,
-                        Tag.NAME.toString(),
-                        METRIC_POINT_IN);
+            .getMetricManager()
+            .count(
+                pointsInserted,
+                Metric.QUANTITY.toString(),
+                MetricLevel.IMPORTANT,
+                Tag.NAME.toString(),
+                METRIC_POINT_IN);
       }
     } catch (RuntimeException e) {
       throw new WriteProcessException(e);
@@ -307,9 +307,9 @@ public abstract class AbstractMemTable implements IMemTable {
 
   @Override
   public void insertAlignedTablet(InsertTabletNode insertTabletNode, int start, int end)
-          throws WriteProcessException {
+      throws WriteProcessException {
     // TODO: PlanIndex
-    //updatePlanIndexes(insertTabletPlan.getIndex());
+    // updatePlanIndexes(insertTabletPlan.getIndex());
     updatePlanIndexes(0);
     try {
       writeAlignedTablet(insertTabletNode, start, end);
@@ -318,13 +318,13 @@ public abstract class AbstractMemTable implements IMemTable {
       totalPointsNum += pointsInserted;
       if (MetricConfigDescriptor.getInstance().getMetricConfig().getEnableMetric()) {
         MetricsService.getInstance()
-                .getMetricManager()
-                .count(
-                        pointsInserted,
-                        Metric.QUANTITY.toString(),
-                        MetricLevel.IMPORTANT,
-                        Tag.NAME.toString(),
-                        METRIC_POINT_IN);
+            .getMetricManager()
+            .count(
+                pointsInserted,
+                Metric.QUANTITY.toString(),
+                MetricLevel.IMPORTANT,
+                Tag.NAME.toString(),
+                METRIC_POINT_IN);
       }
     } catch (RuntimeException e) {
       throw new WriteProcessException(e);
@@ -385,7 +385,7 @@ public abstract class AbstractMemTable implements IMemTable {
     // if this insert plan isn't from storage engine, we should set a temp device id for it
     if (insertTabletNode.getDeviceID() == null) {
       insertTabletNode.setDeviceID(
-              DeviceIDFactory.getInstance().getDeviceID(insertTabletNode.getDevicePath()));
+          DeviceIDFactory.getInstance().getDeviceID(insertTabletNode.getDevicePath()));
     }
 
     List<IMeasurementSchema> schemaList = new ArrayList<>();
@@ -397,14 +397,14 @@ public abstract class AbstractMemTable implements IMemTable {
       schemaList.add(schema);
     }
     IWritableMemChunkGroup memChunkGroup =
-            createMemChunkGroupIfNotExistAndGet(insertTabletNode.getDeviceID(), schemaList);
+        createMemChunkGroupIfNotExistAndGet(insertTabletNode.getDeviceID(), schemaList);
     memChunkGroup.writeValues(
-            insertTabletNode.getTimes(),
-            insertTabletNode.getColumns(),
-            insertTabletNode.getBitMaps(),
-            schemaList,
-            start,
-            end);
+        insertTabletNode.getTimes(),
+        insertTabletNode.getColumns(),
+        insertTabletNode.getBitMaps(),
+        schemaList,
+        start,
+        end);
   }
 
   @Override
@@ -441,7 +441,7 @@ public abstract class AbstractMemTable implements IMemTable {
     // if this insert plan isn't from storage engine, we should set a temp device id for it
     if (insertTabletNode.getDeviceID() == null) {
       insertTabletNode.setDeviceID(
-              DeviceIDFactory.getInstance().getDeviceID(insertTabletNode.getDevicePath()));
+          DeviceIDFactory.getInstance().getDeviceID(insertTabletNode.getDevicePath()));
     }
 
     List<IMeasurementSchema> schemaList = new ArrayList<>();
@@ -456,14 +456,14 @@ public abstract class AbstractMemTable implements IMemTable {
       return;
     }
     IWritableMemChunkGroup memChunkGroup =
-            createAlignedMemChunkGroupIfNotExistAndGet(insertTabletNode.getDeviceID(), schemaList);
+        createAlignedMemChunkGroupIfNotExistAndGet(insertTabletNode.getDeviceID(), schemaList);
     memChunkGroup.writeValues(
-            insertTabletNode.getTimes(),
-            insertTabletNode.getColumns(),
-            insertTabletNode.getBitMaps(),
-            schemaList,
-            start,
-            end);
+        insertTabletNode.getTimes(),
+        insertTabletNode.getColumns(),
+        insertTabletNode.getBitMaps(),
+        schemaList,
+        start,
+        end);
   }
 
   @Override
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/memtable/IMemTable.java b/server/src/main/java/org/apache/iotdb/db/engine/memtable/IMemTable.java
index ce3747f..5f130ea 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/memtable/IMemTable.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/memtable/IMemTable.java
@@ -117,10 +117,10 @@ public interface IMemTable {
       throws WriteProcessException;
 
   void insertTablet(InsertTabletNode insertTabletNode, int start, int end)
-          throws WriteProcessException;
+      throws WriteProcessException;
 
   void insertAlignedTablet(InsertTabletNode insertTabletNode, int start, int end)
-          throws WriteProcessException;
+      throws WriteProcessException;
 
   ReadOnlyMemChunk query(
       PartialPath fullPath, long ttlLowerBound, List<Pair<Modification, IMemTable>> modsToMemtable)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
index e09b90e..9f78c97 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
@@ -352,8 +352,8 @@ public class TsFileProcessor {
    * @param results result array
    */
   public void insertTablet(
-          InsertTabletNode insertTabletNode, int start, int end, TSStatus[] results)
-          throws WriteProcessException {
+      InsertTabletNode insertTabletNode, int start, int end, TSStatus[] results)
+      throws WriteProcessException {
 
     if (workMemTable == null) {
       if (enableMemControl) {
@@ -381,21 +381,21 @@ public class TsFileProcessor {
     }
 
     // TODO(WAL)
-//    try {
-//      if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
-//        insertTabletPlan.setStart(start);
-//        insertTabletPlan.setEnd(end);
-//        getLogNode().write(insertTabletPlan);
-//      }
-//    } catch (Exception e) {
-//      for (int i = start; i < end; i++) {
-//        results[i] = RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
-//      }
-//      if (enableMemControl && memIncrements != null) {
-//        rollbackMemoryInfo(memIncrements);
-//      }
-//      throw new WriteProcessException(e);
-//    }
+    //    try {
+    //      if (IoTDBDescriptor.getInstance().getConfig().isEnableWal()) {
+    //        insertTabletPlan.setStart(start);
+    //        insertTabletPlan.setEnd(end);
+    //        getLogNode().write(insertTabletPlan);
+    //      }
+    //    } catch (Exception e) {
+    //      for (int i = start; i < end; i++) {
+    //        results[i] = RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
+    //      }
+    //      if (enableMemControl && memIncrements != null) {
+    //        rollbackMemoryInfo(memIncrements);
+    //      }
+    //      throw new WriteProcessException(e);
+    //    }
 
     try {
       if (insertTabletNode.isAligned()) {
@@ -414,17 +414,17 @@ public class TsFileProcessor {
       results[i] = RpcUtils.SUCCESS_STATUS;
     }
     tsFileResource.updateStartTime(
-            insertTabletNode.getDeviceID().toStringID(), insertTabletNode.getTimes()[start]);
+        insertTabletNode.getDeviceID().toStringID(), insertTabletNode.getTimes()[start]);
 
     // for sequence tsfile, we update the endTime only when the file is prepared to be closed.
     // for unsequence tsfile, we have to update the endTime for each insertion.
     if (!sequence) {
       tsFileResource.updateEndTime(
-              insertTabletNode.getDeviceID().toStringID(), insertTabletNode.getTimes()[end - 1]);
+          insertTabletNode.getDeviceID().toStringID(), insertTabletNode.getTimes()[end - 1]);
     }
     // TODO: PlanIndex
     tsFileResource.updatePlanIndexes(0);
-//    tsFileResource.updatePlanIndexes(insertTabletPlan.getIndex());
+    //    tsFileResource.updatePlanIndexes(insertTabletPlan.getIndex());
   }
 
   @SuppressWarnings("squid:S3776") // high Cognitive Complexity
@@ -559,7 +559,7 @@ public class TsFileProcessor {
   }
 
   private long[] checkMemCostAndAddToTspInfo(InsertTabletNode insertTabletNode, int start, int end)
-          throws WriteProcessException {
+      throws WriteProcessException {
     if (start >= end) {
       return new long[] {0, 0, 0};
     }
@@ -621,7 +621,7 @@ public class TsFileProcessor {
   }
 
   private long[] checkAlignedMemCostAndAddToTsp(
-          InsertTabletNode insertTabletNode, int start, int end) throws WriteProcessException {
+      InsertTabletNode insertTabletNode, int start, int end) throws WriteProcessException {
     if (start >= end) {
       return new long[] {0, 0, 0};
     }
@@ -636,13 +636,13 @@ public class TsFileProcessor {
     }
 
     updateAlignedMemCost(
-            insertTabletNode.getDataTypes(),
-            deviceID,
-            insertTabletNode.getMeasurements(),
-            start,
-            end,
-            memIncrements,
-            insertTabletNode.getColumns());
+        insertTabletNode.getDataTypes(),
+        deviceID,
+        insertTabletNode.getMeasurements(),
+        start,
+        end,
+        memIncrements,
+        insertTabletNode.getColumns());
     long memTableIncrement = memIncrements[0];
     long textDataIncrement = memIncrements[1];
     long chunkMetadataIncrement = memIncrements[2];
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
index a17a2e2..d638dcf 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
@@ -1111,7 +1111,7 @@ public class VirtualStorageGroupProcessor {
    */
   @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
   public void insertTablet(InsertTabletNode insertTabletNode)
-          throws BatchProcessException, TriggerExecutionException {
+      throws BatchProcessException, TriggerExecutionException {
 
     writeLock("insertTablet");
     try {
@@ -1128,9 +1128,9 @@ public class VirtualStorageGroupProcessor {
         // skip points that do not satisfy TTL
         if (!isAlive(currTime)) {
           results[loc] =
-                  RpcUtils.getStatus(
-                          TSStatusCode.OUT_OF_TTL_ERROR,
-                          "time " + currTime + " in current line is out of TTL: " + dataTTL);
+              RpcUtils.getStatus(
+                  TSStatusCode.OUT_OF_TTL_ERROR,
+                  "time " + currTime + " in current line is out of TTL: " + dataTTL);
           loc++;
           noFailure = false;
         } else {
@@ -1142,19 +1142,19 @@ public class VirtualStorageGroupProcessor {
         throw new BatchProcessException(results);
       }
 
-//      TODO(Trigger)// fire trigger before insertion
-//      final int firePosition = loc;
-//      TriggerEngine.fire(TriggerEvent.BEFORE_INSERT, insertTabletPlan, firePosition);
+      //      TODO(Trigger)// fire trigger before insertion
+      //      final int firePosition = loc;
+      //      TriggerEngine.fire(TriggerEvent.BEFORE_INSERT, insertTabletPlan, firePosition);
 
       // before is first start point
       int before = loc;
       // before time partition
       long beforeTimePartition =
-              StorageEngine.getTimePartition(insertTabletNode.getTimes()[before]);
+          StorageEngine.getTimePartition(insertTabletNode.getTimes()[before]);
       // init map
       long lastFlushTime =
-              lastFlushTimeManager.ensureFlushedTimePartitionAndInit(
-                      beforeTimePartition, insertTabletNode.getDevicePath().getFullPath(), Long.MIN_VALUE);
+          lastFlushTimeManager.ensureFlushedTimePartitionAndInit(
+              beforeTimePartition, insertTabletNode.getDevicePath().getFullPath(), Long.MIN_VALUE);
       // if is sequence
       boolean isSequence = false;
       while (loc < insertTabletNode.getRowCount()) {
@@ -1164,20 +1164,20 @@ public class VirtualStorageGroupProcessor {
         if (curTimePartition != beforeTimePartition) {
           // insert last time partition
           if (isSequence
-                  || !IoTDBDescriptor.getInstance().getConfig().isEnableDiscardOutOfOrderData()) {
+              || !IoTDBDescriptor.getInstance().getConfig().isEnableDiscardOutOfOrderData()) {
             noFailure =
-                    insertTabletToTsFileProcessor(
-                            insertTabletNode, before, loc, isSequence, results, beforeTimePartition)
-                            && noFailure;
+                insertTabletToTsFileProcessor(
+                        insertTabletNode, before, loc, isSequence, results, beforeTimePartition)
+                    && noFailure;
           }
           // re initialize
           before = loc;
           beforeTimePartition = curTimePartition;
           lastFlushTime =
-                  lastFlushTimeManager.ensureFlushedTimePartitionAndInit(
-                          beforeTimePartition,
-                          insertTabletNode.getDevicePath().getFullPath(),
-                          Long.MIN_VALUE);
+              lastFlushTimeManager.ensureFlushedTimePartitionAndInit(
+                  beforeTimePartition,
+                  insertTabletNode.getDevicePath().getFullPath(),
+                  Long.MIN_VALUE);
 
           isSequence = false;
         }
@@ -1188,9 +1188,9 @@ public class VirtualStorageGroupProcessor {
             // insert into unsequence and then start sequence
             if (!IoTDBDescriptor.getInstance().getConfig().isEnableDiscardOutOfOrderData()) {
               noFailure =
-                      insertTabletToTsFileProcessor(
-                              insertTabletNode, before, loc, false, results, beforeTimePartition)
-                              && noFailure;
+                  insertTabletToTsFileProcessor(
+                          insertTabletNode, before, loc, false, results, beforeTimePartition)
+                      && noFailure;
             }
             before = loc;
             isSequence = true;
@@ -1201,24 +1201,24 @@ public class VirtualStorageGroupProcessor {
 
       // do not forget last part
       if (before < loc
-              && (isSequence
+          && (isSequence
               || !IoTDBDescriptor.getInstance().getConfig().isEnableDiscardOutOfOrderData())) {
         noFailure =
-                insertTabletToTsFileProcessor(
-                        insertTabletNode, before, loc, isSequence, results, beforeTimePartition)
-                        && noFailure;
+            insertTabletToTsFileProcessor(
+                    insertTabletNode, before, loc, isSequence, results, beforeTimePartition)
+                && noFailure;
       }
       long globalLatestFlushedTime =
-              lastFlushTimeManager.getGlobalFlushedTime(insertTabletNode.getDevicePath().getFullPath());
+          lastFlushTimeManager.getGlobalFlushedTime(insertTabletNode.getDevicePath().getFullPath());
       // TODO:LAST CACHE
-//      tryToUpdateBatchInsertLastCache(insertTabletNode, globalLatestFlushedTime);
+      //      tryToUpdateBatchInsertLastCache(insertTabletNode, globalLatestFlushedTime);
 
       if (!noFailure) {
         throw new BatchProcessException(results);
       }
 
-//      TODO: trigger // fire trigger after insertion
-//      TriggerEngine.fire(TriggerEvent.AFTER_INSERT, insertTabletPlan, firePosition);
+      //      TODO: trigger // fire trigger after insertion
+      //      TriggerEngine.fire(TriggerEvent.AFTER_INSERT, insertTabletPlan, firePosition);
     } finally {
       writeUnlock();
     }
@@ -1305,12 +1305,12 @@ public class VirtualStorageGroupProcessor {
    * @return false if any failure occurs when inserting the tablet, true otherwise
    */
   private boolean insertTabletToTsFileProcessor(
-          InsertTabletNode insertTabletNode,
-          int start,
-          int end,
-          boolean sequence,
-          TSStatus[] results,
-          long timePartitionId) {
+      InsertTabletNode insertTabletNode,
+      int start,
+      int end,
+      boolean sequence,
+      TSStatus[] results,
+      long timePartitionId) {
     // return when start >= end
     if (start >= end) {
       return true;
@@ -1320,9 +1320,9 @@ public class VirtualStorageGroupProcessor {
     if (tsFileProcessor == null) {
       for (int i = start; i < end; i++) {
         results[i] =
-                RpcUtils.getStatus(
-                        TSStatusCode.INTERNAL_SERVER_ERROR,
-                        "can not create TsFileProcessor, timePartitionId: " + timePartitionId);
+            RpcUtils.getStatus(
+                TSStatusCode.INTERNAL_SERVER_ERROR,
+                "can not create TsFileProcessor, timePartitionId: " + timePartitionId);
       }
       return false;
     }
@@ -1341,9 +1341,9 @@ public class VirtualStorageGroupProcessor {
     // try to update the latest time of the device of this tsRecord
     if (sequence) {
       lastFlushTimeManager.updateLastTime(
-              timePartitionId,
-              insertTabletNode.getDevicePath().getFullPath(),
-              insertTabletNode.getTimes()[end - 1]);
+          timePartitionId,
+          insertTabletNode.getDevicePath().getFullPath(),
+          insertTabletNode.getTimes()[end - 1]);
     }
 
     // check memtable size and may async try to flush the work memtable
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/write/InsertNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/write/InsertNode.java
index 3108166..8331f62 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/write/InsertNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/write/InsertNode.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.db.mpp.sql.analyze.Analysis;
 import org.apache.iotdb.db.mpp.sql.planner.plan.node.PlanNode;
 import org.apache.iotdb.db.mpp.sql.planner.plan.node.PlanNodeId;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema;
 import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
 
 import java.util.List;
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/MemUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/MemUtils.java
index 11df91c..66bfc6a 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/MemUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/MemUtils.java
@@ -138,7 +138,7 @@ public class MemUtils {
    * before inserting.
    */
   public static long getTabletSize(
-          InsertTabletPlan insertTabletPlan, int start, int end, boolean addingTextDataSize) {
+      InsertTabletPlan insertTabletPlan, int start, int end, boolean addingTextDataSize) {
     if (start >= end) {
       return 0L;
     }
@@ -187,7 +187,7 @@ public class MemUtils {
   }
 
   public static long getAlignedTabletSize(
-          InsertTabletNode insertTabletNode, int start, int end, boolean addingTextDataSize) {
+      InsertTabletNode insertTabletNode, int start, int end, boolean addingTextDataSize) {
     if (start >= end) {
       return 0L;
     }