You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2024/11/19 10:50:21 UTC
(iotdb) branch fix_del_after_update created (now d6e0b5c214d)
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a change to branch fix_del_after_update
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at d6e0b5c214d fix that the row deletion mark is mistakenly use
This branch includes the following new commits:
new d6e0b5c214d fix that the row deletion mark is mistakenly use
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/01: fix that the row deletion mark is mistakenly use
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch fix_del_after_update
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit d6e0b5c214dc1b3c8057f705db940d75ff6bf50b
Author: Tian Jiang <jt...@163.com>
AuthorDate: Tue Nov 19 18:51:48 2024 +0800
fix that the row deletion mark is mistakenly use
---
.../org/apache/iotdb/db/it/IoTDBDeletionIT.java | 31 ++++++++++++++++++++++
.../db/utils/datastructure/AlignedTVList.java | 21 ++++++++-------
2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
index 76810eeddf0..0137a8c97cd 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
@@ -437,6 +437,37 @@ public class IoTDBDeletionIT {
}
}
+ @Test
+ public void testDelAfterUpdate() throws SQLException {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute(
+ "CREATE ALIGNED TIMESERIES root.ln12.d1 (status int32)");
+ statement.execute("INSERT INTO root.ln12.d1(timestamp, status) VALUES(1, 1)");
+ statement.execute("INSERT INTO root.ln12.d1(timestamp, status) VALUES(2, 2)");
+ statement.execute("INSERT INTO root.ln12.d1(timestamp, status) VALUES(3, 3)");
+ statement.execute("INSERT INTO root.ln12.d1(timestamp, status) VALUES(2, 2)");
+
+ try (ResultSet resultSet = statement.executeQuery("select status from root.ln12.d1")) {
+ int cnt = 0;
+ while (resultSet.next()) {
+ cnt++;
+ }
+ Assert.assertEquals(3, cnt);
+ }
+
+ statement.execute("DELETE FROM root.ln12.d1.* WHERE time <= 2");
+
+ try (ResultSet resultSet = statement.executeQuery("select status from root.ln12.d1")) {
+ int cnt = 0;
+ while (resultSet.next()) {
+ cnt++;
+ }
+ Assert.assertEquals(1, cnt);
+ }
+ }
+ }
+
private static void prepareSeries() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
index 2a9402aa00d..f0a645bf3ec 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
@@ -493,30 +493,28 @@ public abstract class AlignedTVList extends TVList {
/**
* Get whether value is null at the given position in AlignedTvList.
*
- * @param rowIndex value index inside this column
+ * @param unsortedRowIndex value index inside this column
* @param columnIndex index of the column
* @return boolean
*/
- public boolean isNullValue(int rowIndex, int columnIndex) {
- if (rowIndex >= rowCount) {
+ public boolean isNullValue(int unsortedRowIndex, int columnIndex) {
+ if (unsortedRowIndex >= rowCount) {
return false;
}
- if (allValueColDeletedMap != null && allValueColDeletedMap.isMarked(rowIndex)) {
- return true;
- }
- if (isTimeDeleted(rowIndex)) {
+ if (allValueColDeletedMap != null && allValueColDeletedMap.isMarked(unsortedRowIndex)) {
return true;
}
+
if (values.get(columnIndex) == null) {
return true;
}
if (bitMaps == null
|| bitMaps.get(columnIndex) == null
- || bitMaps.get(columnIndex).get(rowIndex / ARRAY_SIZE) == null) {
+ || bitMaps.get(columnIndex).get(unsortedRowIndex / ARRAY_SIZE) == null) {
return false;
}
- int arrayIndex = rowIndex / ARRAY_SIZE;
- int elementIndex = rowIndex % ARRAY_SIZE;
+ int arrayIndex = unsortedRowIndex / ARRAY_SIZE;
+ int elementIndex = unsortedRowIndex % ARRAY_SIZE;
List<BitMap> columnBitMaps = bitMaps.get(columnIndex);
return columnBitMaps.get(arrayIndex).isMarked(elementIndex);
}
@@ -1424,6 +1422,9 @@ public abstract class AlignedTVList extends TVList {
return timeColDeletedMap;
}
+ /**
+ * @param rowIndex should be the sorted index.
+ */
public boolean isTimeDeleted(int rowIndex) {
int bitmapIndex = getValueIndex(rowIndex);
if (timeColDeletedMap == null || timeColDeletedMap.getSize() <= bitmapIndex) {