This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new 06a6aad1731 [To dev/1.3] Add more checkpoints in series scan
06a6aad1731 is described below
commit 06a6aad17318a4c65aa81dfd568de9169494342a
Author: shuwenwei <[email protected]>
AuthorDate: Tue Jul 15 09:00:16 2025 +0800
[To dev/1.3] Add more checkpoints in series scan
---
.../AbstractSeriesAggregationScanOperator.java | 70 ++++++++++++----
.../source/AbstractSeriesScanOperator.java | 46 ++++++----
.../execution/operator/source/SeriesScanUtil.java | 73 +++++++++++-----
.../utils/reader/SeriesDataBlockReader.java | 20 ++++-
.../AlignedSeriesScanLimitOffsetPushDownTest.java | 97 +++++++++++-----------
.../AlignedSeriesScanPredicatePushDownTest.java | 47 ++++++-----
...gleColumnSeriesScanLimitOffsetPushDownTest.java | 48 +++++------
.../read/reader/series/SeriesReaderTestUtil.java | 17 ++++
.../series/SeriesScanLimitOffsetPushDownTest.java | 60 ++++++-------
.../series/SeriesScanPredicatePushDownTest.java | 40 ++++-----
10 files changed, 319 insertions(+), 199 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesAggregationScanOperator.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesAggregationScanOperator.java
index 2d2492b090f..fe24513ae43 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesAggregationScanOperator.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesAggregationScanOperator.java
@@ -35,6 +35,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import static
org.apache.iotdb.db.queryengine.execution.operator.AggregationUtil.appendAggregationResult;
@@ -140,7 +141,11 @@ public abstract class
AbstractSeriesAggregationScanOperator extends AbstractData
// calculate aggregation result on current time window
// Keep curTimeRange if the calculation of this timeRange is not done
- if (calculateAggregationResultForCurrentTimeRange()) {
+ Optional<Boolean> b = calculateAggregationResultForCurrentTimeRange();
+ if (!b.isPresent()) {
+ continue;
+ }
+ if (b.get()) {
curTimeRange = null;
}
}
@@ -164,41 +169,58 @@ public abstract class
AbstractSeriesAggregationScanOperator extends AbstractData
@SuppressWarnings("squid:S112")
/** Return true if we have the result of this timeRange. */
- protected boolean calculateAggregationResultForCurrentTimeRange() {
+ protected Optional<Boolean> calculateAggregationResultForCurrentTimeRange() {
try {
if (calcFromCachedData()) {
updateResultTsBlock();
- return true;
+ return Optional.of(true);
}
if (readAndCalcFromPage()) {
updateResultTsBlock();
- return true;
+ return Optional.of(true);
}
// only when all the page data has been consumed, we need to read the
chunk data
if (!seriesScanUtil.hasNextPage() && readAndCalcFromChunk()) {
updateResultTsBlock();
- return true;
+ return Optional.of(true);
}
// only when all the page and chunk data has been consumed, we need to
read the file data
- if (!seriesScanUtil.hasNextPage()
- && !seriesScanUtil.hasNextChunk()
- && readAndCalcFromFile()) {
- updateResultTsBlock();
- return true;
+ Optional<Boolean> b;
+ if (!seriesScanUtil.hasNextPage()) {
+ b = seriesScanUtil.hasNextChunk();
+ if (!b.isPresent()) {
+ return b;
+ }
+ if (!b.get() && readAndCalcFromFile()) {
+ updateResultTsBlock();
+ return Optional.of(true);
+ }
}
// If the TimeRange is (Long.MIN_VALUE, Long.MAX_VALUE), for Aggregators
like countAggregator,
// we have to consume all the data before we finish the aggregation
calculation.
- if (seriesScanUtil.hasNextPage()
- || seriesScanUtil.hasNextChunk()
- || seriesScanUtil.hasNextFile()) {
- return false;
+ if (seriesScanUtil.hasNextPage()) {
+ return Optional.of(false);
+ }
+ b = seriesScanUtil.hasNextChunk();
+ if (!b.isPresent()) {
+ return b;
+ }
+ if (b.get()) {
+ return Optional.of(false);
+ }
+ b = seriesScanUtil.hasNextFile();
+ if (!b.isPresent()) {
+ return b;
+ }
+ if (b.get()) {
+ return Optional.of(false);
}
updateResultTsBlock();
- return true;
+ return Optional.of(true);
} catch (IOException e) {
throw new RuntimeException("Error while scanning the file", e);
}
@@ -241,7 +263,14 @@ public abstract class
AbstractSeriesAggregationScanOperator extends AbstractData
protected boolean readAndCalcFromFile() throws IOException {
// start stopwatch
long start = System.nanoTime();
- while (System.nanoTime() - start < leftRuntimeOfOneNextCall &&
seriesScanUtil.hasNextFile()) {
+ while (System.nanoTime() - start < leftRuntimeOfOneNextCall) {
+ Optional<Boolean> b = seriesScanUtil.hasNextFile();
+ if (!b.isPresent()) {
+ continue;
+ }
+ if (!b.get()) {
+ break;
+ }
if (canUseStatistics && seriesScanUtil.canUseCurrentFileStatistics()) {
Statistics fileTimeStatistics =
seriesScanUtil.currentFileTimeStatistics();
if (fileTimeStatistics.getStartTime() > curTimeRange.getMax()) {
@@ -282,7 +311,14 @@ public abstract class
AbstractSeriesAggregationScanOperator extends AbstractData
protected boolean readAndCalcFromChunk() throws IOException {
// start stopwatch
long start = System.nanoTime();
- while (System.nanoTime() - start < leftRuntimeOfOneNextCall &&
seriesScanUtil.hasNextChunk()) {
+ while (System.nanoTime() - start < leftRuntimeOfOneNextCall) {
+ Optional<Boolean> b = seriesScanUtil.hasNextChunk();
+ if (!b.isPresent()) {
+ continue;
+ }
+ if (!b.get()) {
+ break;
+ }
if (canUseStatistics && seriesScanUtil.canUseCurrentChunkStatistics()) {
Statistics chunkTimeStatistics =
seriesScanUtil.currentChunkTimeStatistics();
if (chunkTimeStatistics.getStartTime() > curTimeRange.getMax()) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesScanOperator.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesScanOperator.java
index d8c07d75caf..d53b792ebfb 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesScanOperator.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AbstractSeriesScanOperator.java
@@ -24,6 +24,7 @@ import org.apache.tsfile.read.common.block.TsBlock;
import java.io.IOException;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
public abstract class AbstractSeriesScanOperator extends
AbstractDataSourceOperator {
@@ -70,10 +71,19 @@ public abstract class AbstractSeriesScanOperator extends
AbstractDataSourceOpera
* 2. consume chunk data secondly
* 3. consume next file finally
*/
- if (!readPageData() && !readChunkData() && !readFileData()) {
- noMoreData = true;
- break;
+ if (readPageData()) {
+ continue;
}
+ Optional<Boolean> b = readChunkData();
+ if (!b.isPresent() || b.get()) {
+ continue;
+ }
+ b = readFileData();
+ if (!b.isPresent() || b.get()) {
+ continue;
+ }
+ noMoreData = true;
+ break;
} while (System.nanoTime() - start < maxRuntime
&& !resultTsBlockBuilder.isFull()
@@ -87,22 +97,28 @@ public abstract class AbstractSeriesScanOperator extends
AbstractDataSourceOpera
}
}
- private boolean readFileData() throws IOException {
- while (seriesScanUtil.hasNextFile()) {
- if (readChunkData()) {
- return true;
- }
+ protected Optional<Boolean> readFileData() throws IOException {
+ Optional<Boolean> b = seriesScanUtil.hasNextFile();
+ if (!b.isPresent() || !b.get()) {
+ return b;
}
- return false;
+ b = readChunkData();
+ if (!b.isPresent() || b.get()) {
+ return b;
+ }
+ return Optional.empty();
}
- private boolean readChunkData() throws IOException {
- while (seriesScanUtil.hasNextChunk()) {
- if (readPageData()) {
- return true;
- }
+ protected Optional<Boolean> readChunkData() throws IOException {
+ Optional<Boolean> b = seriesScanUtil.hasNextChunk();
+ if (!b.isPresent() || !b.get()) {
+ return b;
}
- return false;
+
+ if (readPageData()) {
+ return Optional.of(true);
+ }
+ return Optional.empty();
}
private boolean readPageData() throws IOException {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
index c6f79ca6424..76a817f18ef 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/SeriesScanUtil.java
@@ -198,9 +198,14 @@ public class SeriesScanUtil implements Accountable {
// file level methods
/////////////////////////////////////////////////////////////////////////////////////////////////
- public boolean hasNextFile() throws IOException {
+ // When Optional.empty() is returned, it means that the current hasNextFile
has not been fully
+ // executed. In order to avoid the execution time of this method exceeding
the allocated time
+ // slice, it is return early in this way. For the upper-level method, when
encountering
+ // Optional.empty(), it needs to return directly to the checkpoint method
that checks the operator
+ // execution time slice.
+ public Optional<Boolean> hasNextFile() throws IOException {
if (!paginationController.hasCurLimit()) {
- return false;
+ return Optional.of(false);
}
if (!unSeqPageReaders.isEmpty()
@@ -220,21 +225,25 @@ public class SeriesScanUtil implements Accountable {
}
if (firstTimeSeriesMetadata != null) {
- return true;
+ return Optional.of(true);
}
- while (firstTimeSeriesMetadata == null
- && (orderUtils.hasNextSeqResource()
- || orderUtils.hasNextUnseqResource()
- || !seqTimeSeriesMetadata.isEmpty()
- || !unSeqTimeSeriesMetadata.isEmpty())) {
+ boolean checked = false;
+ if (orderUtils.hasNextSeqResource()
+ || orderUtils.hasNextUnseqResource()
+ || !seqTimeSeriesMetadata.isEmpty()
+ || !unSeqTimeSeriesMetadata.isEmpty()) {
// init first time series metadata whose startTime is minimum
tryToUnpackAllOverlappedFilesToTimeSeriesMetadata();
// filter file based on push-down conditions
filterFirstTimeSeriesMetadata();
+ checked = true;
}
- return firstTimeSeriesMetadata != null;
+ if (checked && firstTimeSeriesMetadata == null) {
+ return Optional.empty();
+ }
+ return Optional.of(firstTimeSeriesMetadata != null);
}
private boolean currentFileOverlapped() {
@@ -278,11 +287,16 @@ public class SeriesScanUtil implements Accountable {
* This method should be called after hasNextFile() until no next chunk,
make sure that all
* overlapped chunks are consumed.
*
+ * @return Optional<Boolean> When Optional.empty() is returned, it means
that the current
+ * hasNextFile has not been fully executed. In order to avoid the
execution time of this
+ * method exceeding the allocated time slice, it is return early in this
way. For the
+ * upper-level method, when encountering Optional.empty(), it needs to
return directly to the
+ * checkpoint method who checks the operator execution time slice.
* @throws IllegalStateException illegal state
*/
- public boolean hasNextChunk() throws IOException {
+ public Optional<Boolean> hasNextChunk() throws IOException {
if (!paginationController.hasCurLimit()) {
- return false;
+ return Optional.of(false);
}
if (!unSeqPageReaders.isEmpty()
@@ -298,18 +312,28 @@ public class SeriesScanUtil implements Accountable {
}
if (firstChunkMetadata != null) {
- return true;
+ return Optional.of(true);
// hasNextFile() has not been invoked
} else if (firstTimeSeriesMetadata == null &&
cachedChunkMetadata.isEmpty()) {
- return false;
+ return Optional.of(false);
}
- while (firstChunkMetadata == null && (!cachedChunkMetadata.isEmpty() ||
hasNextFile())) {
+ Optional<Boolean> hasNextFileReturnValue = null;
+ while (firstChunkMetadata == null) {
+ if (cachedChunkMetadata.isEmpty()) {
+ if (hasNextFileReturnValue != null) {
+ return Optional.empty();
+ }
+ hasNextFileReturnValue = hasNextFile();
+ if (!hasNextFileReturnValue.isPresent() ||
!hasNextFileReturnValue.get()) {
+ return hasNextFileReturnValue;
+ }
+ }
initFirstChunkMetadata();
// filter chunk based on push-down conditions
filterFirstChunkMetadata();
}
- return firstChunkMetadata != null;
+ return Optional.of(firstChunkMetadata != null);
}
private void filterFirstChunkMetadata() {
@@ -1051,15 +1075,21 @@ public class SeriesScanUtil implements Accountable {
/*
* Fill sequence TimeSeriesMetadata List until it is not empty
*/
- while (seqTimeSeriesMetadata.isEmpty() && orderUtils.hasNextSeqResource())
{
- unpackSeqTsFileResource();
+ if (seqTimeSeriesMetadata.isEmpty() && orderUtils.hasNextSeqResource()) {
+ // Avoid exceeding the time slice when a series cannot be found
+ if (!unpackSeqTsFileResource().isPresent()) {
+ return;
+ }
}
/*
* Fill unSequence TimeSeriesMetadata Priority Queue until it is not empty
*/
- while (unSeqTimeSeriesMetadata.isEmpty() &&
orderUtils.hasNextUnseqResource()) {
- unpackUnseqTsFileResource();
+ if (unSeqTimeSeriesMetadata.isEmpty() &&
orderUtils.hasNextUnseqResource()) {
+ // Avoid exceeding the time slice when a series cannot be found
+ if (!unpackUnseqTsFileResource().isPresent()) {
+ return;
+ }
}
/*
@@ -1166,13 +1196,16 @@ public class SeriesScanUtil implements Accountable {
}
}
- private void unpackUnseqTsFileResource() throws IOException {
+ private Optional<ITimeSeriesMetadata> unpackUnseqTsFileResource() throws
IOException {
ITimeSeriesMetadata timeseriesMetadata =
loadTimeSeriesMetadata(orderUtils.getNextUnseqFileResource(true),
false);
// skip if data type is mismatched which may be caused by delete
if (timeseriesMetadata != null &&
timeseriesMetadata.typeMatch(getTsDataTypeList())) {
timeseriesMetadata.setSeq(false);
unSeqTimeSeriesMetadata.add(timeseriesMetadata);
+ return Optional.of(timeseriesMetadata);
+ } else {
+ return Optional.empty();
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/reader/SeriesDataBlockReader.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/reader/SeriesDataBlockReader.java
index 0e3a9945648..51f4f3ebbbb 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/reader/SeriesDataBlockReader.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/utils/reader/SeriesDataBlockReader.java
@@ -37,6 +37,7 @@ import org.apache.tsfile.read.common.block.TsBlock;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
public class SeriesDataBlockReader implements IDataBlockReader {
@@ -133,7 +134,14 @@ public class SeriesDataBlockReader implements
IDataBlockReader {
/*
* consume next file finally
*/
- while (seriesScanUtil.hasNextFile()) {
+ while (true) {
+ Optional<Boolean> b = seriesScanUtil.hasNextFile();
+ if (!b.isPresent()) {
+ continue;
+ }
+ if (!b.get()) {
+ break;
+ }
if (readChunkData()) {
hasCachedBatchData = true;
return true;
@@ -157,7 +165,15 @@ public class SeriesDataBlockReader implements
IDataBlockReader {
}
private boolean readChunkData() throws IOException {
- while (seriesScanUtil.hasNextChunk()) {
+ while (true) {
+ Optional<Boolean> b = seriesScanUtil.hasNextChunk();
+ if (!b.isPresent()) {
+ // This reader is used for compaction, just keep traversing
+ continue;
+ }
+ if (!b.get()) {
+ break;
+ }
if (readPageData()) {
return true;
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanLimitOffsetPushDownTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanLimitOffsetPushDownTest.java
index cec1a8f0391..45b652e717a 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanLimitOffsetPushDownTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanLimitOffsetPushDownTest.java
@@ -68,8 +68,8 @@ public class AlignedSeriesScanLimitOffsetPushDownTest extends
AbstractAlignedSer
public void testSkipFile() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(5, 10);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -80,26 +80,27 @@ public class AlignedSeriesScanLimitOffsetPushDownTest
extends AbstractAlignedSer
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testCannotSkipFile() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(5, 20);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -114,18 +115,18 @@ public class AlignedSeriesScanLimitOffsetPushDownTest
extends AbstractAlignedSer
public void testSkipChunk() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(5, 30);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -140,28 +141,28 @@ public class AlignedSeriesScanLimitOffsetPushDownTest
extends AbstractAlignedSer
public void testCannotSkipChunk() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(5, 40);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -176,28 +177,28 @@ public class AlignedSeriesScanLimitOffsetPushDownTest
extends AbstractAlignedSer
public void testSkipPage() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(5, 50);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -212,35 +213,35 @@ public class AlignedSeriesScanLimitOffsetPushDownTest
extends AbstractAlignedSer
public void testCannotSkipPage() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(5, 60);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -255,35 +256,35 @@ public class AlignedSeriesScanLimitOffsetPushDownTest
extends AbstractAlignedSer
public void testSkipPoint() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(10, 75);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanPredicatePushDownTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanPredicatePushDownTest.java
index 9c63821bfd2..d9b9aa4619c 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanPredicatePushDownTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSeriesScanPredicatePushDownTest.java
@@ -69,16 +69,17 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
}
@Test
- @SuppressWarnings("squid:S5961") // Suppress "Test methods should not
contain too many assertions"
+ @SuppressWarnings(
+ "squid:S5961") // Suppress "Test methods should not contain too manya
assertions"
public void testNoFilter() throws IllegalPathException, IOException {
AlignedSeriesScanUtil seriesScanUtil = getAlignedSeriesScanUtil(null,
null);
// File 1
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentFileStatistics());
// File 1 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 1 - Chunk 1 - Page 1
@@ -87,14 +88,14 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 2
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentFileStatistics());
// File 2 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 2 - Chunk 1 - Page 1
@@ -103,14 +104,14 @@ public class AlignedSeriesScanPredicatePushDownTest
extends AbstractAlignedSerie
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentFileStatistics());
// File 3 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 3 - Chunk 1 - Page 1
@@ -121,7 +122,7 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
Assert.assertFalse(seriesScanUtil.hasNextPage());
// File 3 - Chunk 2
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 3 - Chunk 2 - Page 1
@@ -130,14 +131,14 @@ public class AlignedSeriesScanPredicatePushDownTest
extends AbstractAlignedSerie
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 4
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentFileStatistics());
// File 4 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 4 - Chunk 1 - Page 1 (chunk actually)
@@ -148,7 +149,7 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
Assert.assertFalse(seriesScanUtil.hasNextPage());
// File 4 - Chunk 1 - Page 2 (chunk actually)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
Assert.assertTrue(seriesScanUtil.canUseCurrentPageStatistics());
tsBlock = seriesScanUtil.nextPage();
@@ -156,7 +157,7 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
Assert.assertFalse(seriesScanUtil.hasNextPage());
// File 4 - Chunk 1 - Page 3 (chunk actually)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
Assert.assertTrue(seriesScanUtil.canUseCurrentPageStatistics());
tsBlock = seriesScanUtil.nextPage();
@@ -164,7 +165,7 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
Assert.assertFalse(seriesScanUtil.hasNextPage());
// (File 4 - Chunk 2) merge (File 5 - Chunk 1)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentChunkStatistics());
// (File 4 - Chunk 2 - Page 1) merge (File 5 - Chunk 1 - Page 1)
@@ -179,8 +180,8 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
@@ -195,11 +196,11 @@ public class AlignedSeriesScanPredicatePushDownTest
extends AbstractAlignedSerie
// File 1 skipped
// File 2 skipped
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentFileStatistics());
// File 3 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 3 - Chunk 1 - Page 1
@@ -214,7 +215,7 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
// File 3 - Chunk 2 skipped
// File 4 - Chunk 1 skipped
// (File 4 - Chunk 2) merge (File 5 - Chunk 1)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentChunkStatistics());
Assert.assertTrue(seriesScanUtil.hasNextPage());
Assert.assertFalse(seriesScanUtil.canUseCurrentPageStatistics());
@@ -227,7 +228,7 @@ public class AlignedSeriesScanPredicatePushDownTest extends
AbstractAlignedSerie
Assert.assertTrue(tsBlock == null || tsBlock.isEmpty());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSingleColumnSeriesScanLimitOffsetPushDownTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSingleColumnSeriesScanLimitOffsetPushDownTest.java
index 2f9a5ec5231..bea93461250 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSingleColumnSeriesScanLimitOffsetPushDownTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/AlignedSingleColumnSeriesScanLimitOffsetPushDownTest.java
@@ -71,18 +71,18 @@ public class
AlignedSingleColumnSeriesScanLimitOffsetPushDownTest
// File 1 skipped
// File 2
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -99,21 +99,21 @@ public class
AlignedSingleColumnSeriesScanLimitOffsetPushDownTest
// File 1 skipped (10 points)
// File 2 skipped (6 points)
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
// File 3 Chunk 1 skipped (10 points)
// File 3 Chunk 2 (6 points should skip 4 points)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -125,11 +125,11 @@ public class
AlignedSingleColumnSeriesScanLimitOffsetPushDownTest
// remaining 3 points selected
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(3, tsBlock.getPositionCount());
@@ -139,8 +139,8 @@ public class
AlignedSingleColumnSeriesScanLimitOffsetPushDownTest
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
@@ -149,36 +149,36 @@ public class
AlignedSingleColumnSeriesScanLimitOffsetPushDownTest
// File 1 skipped (10 points)
// File 2 skipped (6 points)
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
// File 3 - Chunk 1 skipped (10 points)
// File 3 - Chunk 2 skipped (6 points)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(0, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 4
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
// File 4 - Chunk 1 - Page 1 skipped (10 points)
// File 4 - Chunk 1 - Page 2 (6 points should skip 3 points)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(3, tsBlock.getPositionCount());
@@ -189,7 +189,7 @@ public class
AlignedSingleColumnSeriesScanLimitOffsetPushDownTest
Assert.assertFalse(seriesScanUtil.hasNextPage());
// File 4 - Chunk 1 - Page 2 (remaining 2 points)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesReaderTestUtil.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesReaderTestUtil.java
index 4261dd2d898..55331fafc89 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesReaderTestUtil.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesReaderTestUtil.java
@@ -45,6 +45,7 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import static org.apache.iotdb.commons.conf.IoTDBConstant.PATH_SEPARATOR;
@@ -215,4 +216,20 @@ public class SeriesReaderTestUtil {
FileReaderManager.getInstance().closeAndRemoveAllOpenedReaders();
}
+
+ static void assertWithHasNext(SeriesScanHasNextSupplier supplier, boolean
value)
+ throws IOException {
+ while (true) {
+ Optional<Boolean> b = supplier.get();
+ if (!b.isPresent()) {
+ continue;
+ }
+ Assert.assertEquals(b.get(), value);
+ break;
+ }
+ }
+
+ interface SeriesScanHasNextSupplier {
+ Optional<Boolean> get() throws IOException;
+ }
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanLimitOffsetPushDownTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanLimitOffsetPushDownTest.java
index ccff1e9a8d4..00d84414fa6 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanLimitOffsetPushDownTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanLimitOffsetPushDownTest.java
@@ -59,8 +59,8 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
public void testSkipFile() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(5, 10, Ordering.ASC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -71,16 +71,16 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testSkipChunk() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(5, 20, Ordering.ASC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -91,16 +91,16 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testSkipPage() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(5, 30, Ordering.ASC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -111,16 +111,16 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testSkipPoint1() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(10, 45, Ordering.ASC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -134,7 +134,7 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
Assert.assertEquals(expectedTime++, tsBlock.getTimeByIndex(i));
}
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(5, tsBlock.getPositionCount());
@@ -143,16 +143,16 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testSkipPoint2() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(10, 55, Ordering.ASC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -170,16 +170,16 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testSkipPointDesc1() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(10, 5, Ordering.DESC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -200,16 +200,16 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
public void testSkipPointDesc2() throws IllegalPathException, IOException {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(10, 25, Ordering.DESC);
- Assert.assertTrue(seriesScanUtil.hasNextFile());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
TsBlock tsBlock = seriesScanUtil.nextPage();
@@ -222,7 +222,7 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.hasNextPage());
tsBlock = seriesScanUtil.nextPage();
@@ -243,7 +243,7 @@ public class SeriesScanLimitOffsetPushDownTest extends
AbstractSeriesScanTest {
}
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
}
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanPredicatePushDownTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanPredicatePushDownTest.java
index de295f1ce9a..83f4a67ef4a 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanPredicatePushDownTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/read/reader/series/SeriesScanPredicatePushDownTest.java
@@ -66,11 +66,11 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
SeriesScanUtil seriesScanUtil = getSeriesScanUtil(null, null);
// File 1
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentFileStatistics());
// File 1 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 1 - Chunk 1 - Page 1
@@ -79,14 +79,14 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
TsBlock tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 2
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentFileStatistics());
// File 2 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 2 - Chunk 1 - Page 1
@@ -97,7 +97,7 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
Assert.assertFalse(seriesScanUtil.hasNextPage());
// File 2 - Chunk 2
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 2 - Chunk 2 - Page 1
@@ -106,14 +106,14 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentFileStatistics());
// File 3 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 3 - Chunk 1 - Page 1
@@ -130,7 +130,7 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
Assert.assertFalse(seriesScanUtil.hasNextPage());
// (File 3 - Chunk 2) merge (File 4 - Chunk 1)
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentChunkStatistics());
// (File 3 - Chunk 2 - Page 1) merge (File 4 - Chunk 1 - Page 1)
@@ -145,8 +145,8 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
tsBlock = seriesScanUtil.nextPage();
Assert.assertEquals(10, tsBlock.getPositionCount());
Assert.assertFalse(seriesScanUtil.hasNextPage());
- Assert.assertFalse(seriesScanUtil.hasNextChunk());
- Assert.assertFalse(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk,
false);
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, false);
}
@Test
@@ -166,11 +166,11 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
private void checkFile1Skipped(SeriesScanUtil seriesScanUtil) throws
IOException {
// File 1
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentFileStatistics());
// File 1 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 1 - Chunk 1 - Page 1
@@ -199,12 +199,12 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
private void checkFile2Chunk1Skipped(SeriesScanUtil seriesScanUtil) throws
IOException {
// File 1 skipped
// File 2
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentFileStatistics());
// File 2 - Chunk 1 skipped
// File 2 - Chunk 2
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertTrue(seriesScanUtil.canUseCurrentChunkStatistics());
// File 2 - Chunk 2 - Page 1
@@ -255,11 +255,11 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
// File 1 skipped
// File 2 skipped
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentFileStatistics());
// File 3 - Chunk 1
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentChunkStatistics());
}
@@ -284,12 +284,12 @@ public class SeriesScanPredicatePushDownTest extends
AbstractSeriesScanTest {
// File 1 skipped
// File 2 skipped
// File 3
- Assert.assertTrue(seriesScanUtil.hasNextFile());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextFile, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentFileStatistics());
// File 3 - Chunk 1 skipped
// File 3 - Chunk 2
- Assert.assertTrue(seriesScanUtil.hasNextChunk());
+ SeriesReaderTestUtil.assertWithHasNext(seriesScanUtil::hasNextChunk, true);
Assert.assertFalse(seriesScanUtil.canUseCurrentChunkStatistics());
}