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

jackietien pushed a commit to branch IOTDB-6115
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 06e0361492908f1e9583f0796c3d525a908ee06c
Author: JackieTien97 <[email protected]>
AuthorDate: Wed Aug 16 14:16:15 2023 +0800

    Use statistics if any value column has same count as time column
---
 .../operator/source/AlignedSeriesScanUtil.java     | 31 +++++++++++++++-------
 .../read/reader/chunk/MemAlignedPageReader.java    | 17 +++++++-----
 .../tsfile/read/reader/page/AlignedPageReader.java | 15 +++++++----
 3 files changed, 42 insertions(+), 21 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AlignedSeriesScanUtil.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AlignedSeriesScanUtil.java
index d36de2e4bf7..d577023a5aa 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AlignedSeriesScanUtil.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AlignedSeriesScanUtil.java
@@ -152,19 +152,25 @@ public class AlignedSeriesScanUtil extends SeriesScanUtil 
{
 
   @SuppressWarnings("squid:S3740")
   private void skipOffsetByTimeSeriesMetadata() {
-    // For aligned series, When we only query some measurements under an 
aligned device, if the
-    // values of these queried measurements at a timestamp are all null, the 
timestamp will not
-    // be selected.
+    // For aligned series, When we only query some measurements under an 
aligned device, if any
+    // values of these queried measurements has the same value count as the 
time column, the
+    // timestamp will be selected.
     // NOTE: if we change the query semantic in the future for aligned series, 
we need to remove
     // this check here.
     long rowCount =
         ((AlignedTimeSeriesMetadata) 
firstTimeSeriesMetadata).getTimeStatistics().getCount();
+    boolean canUse =
+        ((AlignedTimeSeriesMetadata) 
firstTimeSeriesMetadata).getValueStatisticsList().isEmpty();
     for (Statistics statistics :
         ((AlignedTimeSeriesMetadata) 
firstTimeSeriesMetadata).getValueStatisticsList()) {
-      if (statistics == null || statistics.hasNullValue(rowCount)) {
-        return;
+      if (statistics != null && !statistics.hasNullValue(rowCount)) {
+        canUse = true;
+        break;
       }
     }
+    if (!canUse) {
+      return;
+    }
     // When the number of points in all value chunk groups is the same as that 
in the time chunk
     // group, it means that there is no null value, and all timestamps will be 
selected.
     if (paginationController.hasCurOffset(rowCount)) {
@@ -188,18 +194,23 @@ public class AlignedSeriesScanUtil extends SeriesScanUtil 
{
 
   @SuppressWarnings("squid:S3740")
   private void skipOffsetByChunkMetadata() {
-    // For aligned series, When we only query some measurements under an 
aligned device, if the
-    // values of these queried measurements at a timestamp are all null, the 
timestamp will not
-    // be selected.
+    // For aligned series, When we only query some measurements under an 
aligned device, if any
+    // values of these queried measurements has the same value count as the 
time column, the
+    // timestamp will be selected.
     // NOTE: if we change the query semantic in the future for aligned series, 
we need to remove
     // this check here.
     long rowCount = firstChunkMetadata.getStatistics().getCount();
+    boolean canUse = ((AlignedChunkMetadata) 
firstChunkMetadata).getValueStatisticsList().isEmpty();
     for (Statistics statistics :
         ((AlignedChunkMetadata) firstChunkMetadata).getValueStatisticsList()) {
-      if (statistics == null || statistics.hasNullValue(rowCount)) {
-        return;
+      if (statistics != null && !statistics.hasNullValue(rowCount)) {
+        canUse = true;
+        break;
       }
     }
+    if (!canUse) {
+      return;
+    }
     // When the number of points in all value chunks is the same as that in 
the time chunk, it
     // means that there is no null value, and all timestamps will be selected.
     if (paginationController.hasCurOffset(rowCount)) {
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedPageReader.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedPageReader.java
index b1bba47f129..2f08be13c84 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedPageReader.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/chunk/MemAlignedPageReader.java
@@ -101,17 +101,22 @@ public class MemAlignedPageReader implements IPageReader, 
IAlignedPageReader {
   private boolean pageSatisfy() {
     Statistics<? extends Serializable> statistics = getStatistics();
     if (valueFilter == null || valueFilter.allSatisfy(statistics)) {
-      // For aligned series, When we only read some measurements under an 
aligned device, if the
-      // values of these queried measurements at a timestamp are all null, the 
timestamp will not be
-      // selected.
-      // NOTE: if we change the read semantic in the future for aligned 
series, we need to remove
+      // For aligned series, When we only query some measurements under an 
aligned device, if any
+      // values of these queried measurements has the same value count as the 
time column, the
+      // timestamp will be selected.
+      // NOTE: if we change the query semantic in the future for aligned 
series, we need to remove
       // this check here.
       long rowCount = getTimeStatistics().getCount();
+      boolean canUse = getValueStatisticsList().isEmpty();
       for (Statistics<? extends Serializable> vStatistics : 
getValueStatisticsList()) {
-        if (vStatistics == null || vStatistics.hasNullValue(rowCount)) {
-          return true;
+        if (vStatistics != null && !vStatistics.hasNullValue(rowCount)) {
+          canUse = true;
+          break;
         }
       }
+      if (!canUse) {
+        return true;
+      }
       // When the number of points in all value pages is the same as that in 
the time page, it means
       // that there is no null value, and all timestamps will be selected.
       if (paginationController.hasCurOffset(rowCount)) {
diff --git 
a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/AlignedPageReader.java
 
b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/AlignedPageReader.java
index 0a93e92f423..f0e7b497acb 100644
--- 
a/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/AlignedPageReader.java
+++ 
b/iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/AlignedPageReader.java
@@ -120,17 +120,22 @@ public class AlignedPageReader implements IPageReader, 
IAlignedPageReader {
   private boolean pageSatisfy() {
     Statistics statistics = getStatistics();
     if (filter == null || filter.allSatisfy(statistics)) {
-      // For aligned series, When we only query some measurements under an 
aligned device, if the
-      // values of these queried measurements at a timestamp are all null, the 
timestamp will not be
-      // selected.
+      // For aligned series, When we only query some measurements under an 
aligned device, if any
+      // values of these queried measurements has the same value count as the 
time column, the
+      // timestamp will be selected.
       // NOTE: if we change the query semantic in the future for aligned 
series, we need to remove
       // this check here.
       long rowCount = getTimeStatistics().getCount();
+      boolean canUse = getValueStatisticsList().isEmpty();
       for (Statistics vStatistics : getValueStatisticsList()) {
-        if (vStatistics == null || vStatistics.hasNullValue(rowCount)) {
-          return true;
+        if (vStatistics != null && !vStatistics.hasNullValue(rowCount)) {
+          canUse = true;
+          break;
         }
       }
+      if (!canUse) {
+        return true;
+      }
       // When the number of points in all value pages is the same as that in 
the time page, it means
       // that there is no null value, and all timestamps will be selected.
       if (paginationController.hasCurOffset(rowCount)) {

Reply via email to