shizy818 commented on code in PR #14265:
URL: https://github.com/apache/iotdb/pull/14265#discussion_r1867241601


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java:
##########
@@ -136,6 +186,105 @@ public long getTime(int index) {
     return timestamps.get(arrayIndex)[elementIndex];
   }
 
+  protected void set(int index, long timestamp, int value) {
+    if (index >= rowCount) {
+      throw new ArrayIndexOutOfBoundsException(index);
+    }
+    int arrayIndex = index / ARRAY_SIZE;
+    int elementIndex = index % ARRAY_SIZE;
+    timestamps.get(arrayIndex)[elementIndex] = timestamp;
+    indices.get(arrayIndex)[elementIndex] = value;
+  }
+
+  @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity 
warning
+  protected int[] cloneIndex(int[] array) {
+    int[] cloneArray = new int[array.length];
+    System.arraycopy(array, 0, cloneArray, 0, array.length);
+    return cloneArray;
+  }
+
+  /**
+   * Get the row index value in index column.
+   *
+   * @param index row index
+   */
+  public int getValueIndex(int index) {
+    if (index >= rowCount) {
+      throw new ArrayIndexOutOfBoundsException(index);
+    }
+    int arrayIndex = index / ARRAY_SIZE;
+    int elementIndex = index % ARRAY_SIZE;
+    return indices.get(arrayIndex)[elementIndex];
+  }
+
+  protected void markNullValue(int arrayIndex, int elementIndex) {
+    // init bitMap if doesn't have
+    if (bitMap == null) {
+      bitMap = new CopyOnWriteArrayList<>();
+      for (int i = 0; i < timestamps.size(); i++) {
+        bitMap.add(new BitMap(ARRAY_SIZE));
+      }
+    }
+    // if the bitmap in arrayIndex is null, init the bitmap
+    if (bitMap.get(arrayIndex) == null) {
+      bitMap.set(arrayIndex, new BitMap(ARRAY_SIZE));
+    }
+
+    // mark the null value in the current bitmap
+    bitMap.get(arrayIndex).mark(elementIndex);
+  }
+
+  /**
+   * Get whether value is null at the given position in TvList.
+   *
+   * @param rowIndex value index
+   * @return boolean
+   */
+  public boolean isNullValue(int rowIndex) {
+    if (rowIndex >= rowCount) {
+      return false;
+    }

Review Comment:
   Here I do it as `isNullValue` method in AlignedTVList class. Anyway I can 
throw exception later when I deal with AlignendTVList.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TVList.java:
##########
@@ -136,6 +186,105 @@ public long getTime(int index) {
     return timestamps.get(arrayIndex)[elementIndex];
   }
 
+  protected void set(int index, long timestamp, int value) {
+    if (index >= rowCount) {
+      throw new ArrayIndexOutOfBoundsException(index);
+    }
+    int arrayIndex = index / ARRAY_SIZE;
+    int elementIndex = index % ARRAY_SIZE;
+    timestamps.get(arrayIndex)[elementIndex] = timestamp;
+    indices.get(arrayIndex)[elementIndex] = value;
+  }
+
+  @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity 
warning
+  protected int[] cloneIndex(int[] array) {
+    int[] cloneArray = new int[array.length];
+    System.arraycopy(array, 0, cloneArray, 0, array.length);
+    return cloneArray;
+  }
+
+  /**
+   * Get the row index value in index column.
+   *
+   * @param index row index
+   */
+  public int getValueIndex(int index) {
+    if (index >= rowCount) {
+      throw new ArrayIndexOutOfBoundsException(index);
+    }
+    int arrayIndex = index / ARRAY_SIZE;
+    int elementIndex = index % ARRAY_SIZE;
+    return indices.get(arrayIndex)[elementIndex];
+  }
+
+  protected void markNullValue(int arrayIndex, int elementIndex) {
+    // init bitMap if doesn't have
+    if (bitMap == null) {
+      bitMap = new CopyOnWriteArrayList<>();
+      for (int i = 0; i < timestamps.size(); i++) {
+        bitMap.add(new BitMap(ARRAY_SIZE));
+      }
+    }
+    // if the bitmap in arrayIndex is null, init the bitmap
+    if (bitMap.get(arrayIndex) == null) {
+      bitMap.set(arrayIndex, new BitMap(ARRAY_SIZE));
+    }
+
+    // mark the null value in the current bitmap
+    bitMap.get(arrayIndex).mark(elementIndex);
+  }
+
+  /**
+   * Get whether value is null at the given position in TvList.
+   *
+   * @param rowIndex value index
+   * @return boolean
+   */
+  public boolean isNullValue(int rowIndex) {
+    if (rowIndex >= rowCount) {
+      return false;
+    }

Review Comment:
   Here I do it same as `isNullValue` method in AlignedTVList class. Anyway I 
can throw exception later when I deal with AlignendTVList.



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