Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,6 @@ public class IoTDBConfig implements DefaultEncodingProvider {
*/
private int tvListSortThreshold = 0;

/** Enable streaming query mem chunk */
private boolean streamingQueryMemChunk = true;

/** Enable inner space compaction for sequence files */
private volatile boolean enableSeqSpaceCompaction = true;

Expand Down Expand Up @@ -2536,14 +2533,6 @@ public void setTVListSortThreshold(int tvListSortThreshold) {
this.tvListSortThreshold = tvListSortThreshold;
}

public boolean isStreamingQueryMemChunk() {
return streamingQueryMemChunk;
}

public void setStreamingQueryMemChunk(boolean streamingQueryMemChunk) {
this.streamingQueryMemChunk = streamingQueryMemChunk;
}

public boolean isRpcThriftCompressionEnable() {
return rpcThriftCompressionEnable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ public void processStatistics(Statistics timeStatistics, Statistics[] valueStati
}
}

public boolean usesTimeStatistics() {
for (InputLocation[] inputLocations : inputLocationList) {
if (inputLocations[0].getValueColumnIndex() == -1) {
return true;
}
}
return false;
}

public TSDataType[] getOutputType() {
if (step.isOutputPartial()) {
return accumulator.getIntermediateType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public abstract class AbstractSeriesAggregationScanOperator extends AbstractData
/** Some special data types(like BLOB) cannot use statistics. */
protected final boolean canUseStatistics;

private final boolean hasTimeStatisticsAggregator;

@SuppressWarnings("squid:S107")
protected AbstractSeriesAggregationScanOperator(
PlanNodeId sourceId,
Expand Down Expand Up @@ -99,6 +101,14 @@ protected AbstractSeriesAggregationScanOperator(
this.maxReturnSize = maxReturnSize;
this.outputEndTime = outputEndTime;
this.canUseStatistics = canUseStatistics;
boolean usesTimeStatistics = false;
for (TreeAggregator aggregator : aggregators) {
if (aggregator.usesTimeStatistics()) {
usesTimeStatistics = true;
break;
}
}
this.hasTimeStatisticsAggregator = usesTimeStatistics;
}

@Override
Expand Down Expand Up @@ -282,7 +292,10 @@ protected boolean readAndCalcFromFile() throws IOException {
if (!b.get()) {
break;
}
if (canUseStatistics && seriesScanUtil.canUseCurrentFileStatistics()) {
if (canUseStatistics
&& (hasTimeStatisticsAggregator
? seriesScanUtil.canUseCurrentFileTimeStatistics()
: seriesScanUtil.canUseCurrentFileStatistics())) {
Statistics fileTimeStatistics = seriesScanUtil.currentFileTimeStatistics();
if (fileTimeStatistics.getStartTime() > curTimeRange.getMax()) {
if (ascending) {
Expand Down Expand Up @@ -330,7 +343,10 @@ protected boolean readAndCalcFromChunk() throws IOException {
if (!b.get()) {
break;
}
if (canUseStatistics && seriesScanUtil.canUseCurrentChunkStatistics()) {
if (canUseStatistics
&& (hasTimeStatisticsAggregator
? seriesScanUtil.canUseCurrentChunkTimeStatistics()
: seriesScanUtil.canUseCurrentChunkStatistics())) {
Statistics chunkTimeStatistics = seriesScanUtil.currentChunkTimeStatistics();
if (chunkTimeStatistics.getStartTime() > curTimeRange.getMax()) {
if (ascending) {
Expand Down Expand Up @@ -372,7 +388,10 @@ protected boolean readAndCalcFromPage() throws IOException {
long start = System.nanoTime();
try {
while (System.nanoTime() - start < leftRuntimeOfOneNextCall && seriesScanUtil.hasNextPage()) {
if (canUseStatistics && seriesScanUtil.canUseCurrentPageStatistics()) {
if (canUseStatistics
&& (hasTimeStatisticsAggregator
? seriesScanUtil.canUseCurrentPageTimeStatistics()
: seriesScanUtil.canUseCurrentPageStatistics())) {
Statistics pageTimeStatistics = seriesScanUtil.currentPageTimeStatistics();
// There is no more eligible points in current time range
if (pageTimeStatistics.getStartTime() > curTimeRange.getMax()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.file.metadata.AbstractAlignedTimeSeriesMetadata;
import org.apache.tsfile.file.metadata.IMetadata;
import org.apache.tsfile.file.metadata.statistics.Statistics;
import org.apache.tsfile.read.common.block.TsBlock;
import org.apache.tsfile.read.reader.IPointReader;
import org.apache.tsfile.write.schema.IMeasurementSchema;
Expand All @@ -45,12 +46,6 @@

private final List<TSDataType> dataTypes;

// only used for limit and offset push down optimizer, if we select all columns from aligned
// device, we can use statistics to skip.
// it's only exact while using limit & offset push down
// for table scan, it should always be true
private final boolean queryAllSensors;

// for table model, it will be false
// for tree model, it will be true
private final boolean ignoreAllNullRows;
Expand All @@ -68,7 +63,7 @@
Ordering scanOrder,
SeriesScanOptions scanOptions,
FragmentInstanceContext context,
boolean queryAllSensors,

Check warning on line 66 in iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/AlignedSeriesScanUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused method parameter "queryAllSensors".

See more on https://sonarcloud.io/project/issues?id=apache_iotdb&issues=AaIlL4K9A8dDtxJnTEyJ&open=AaIlL4K9A8dDtxJnTEyJ&pullRequest=19445
List<TSDataType> givenDataTypes) {
super(seriesPath, scanOrder, scanOptions, context);
isAligned = true;
Expand All @@ -78,7 +73,6 @@
: seriesPath.getSchemaList().stream()
.map(IMeasurementSchema::getType)
.collect(Collectors.toList());
this.queryAllSensors = queryAllSensors;
this.ignoreAllNullRows = context.isIgnoreAllNullRows();
}

Expand Down Expand Up @@ -115,9 +109,90 @@
return new TsBlockAlignedRowPointReader(tsBlock);
}

@Override
public boolean canUseCurrentFileTimeStatistics() {
return canUseCurrentFileStatistics() && canUseAlignedTimeStatistics(firstTimeSeriesMetadata);
}

@Override
public boolean canUseCurrentChunkTimeStatistics() {
return canUseCurrentChunkStatistics() && canUseAlignedTimeStatistics(firstChunkMetadata);
}

@Override
public boolean canUseCurrentPageTimeStatistics() throws IOException {
return canUseCurrentPageStatistics()
&& firstPageReader != null
&& !(firstPageReader instanceof LazyMemVersionPageReader)
&& canUseAlignedTimeStatistics(firstPageReader.getPageReader());
}

@Override
@SuppressWarnings("squid:S3740")
public Statistics currentFileTimeStatistics() {
return getAlignedTimeStatistics(firstTimeSeriesMetadata, super.currentFileTimeStatistics());
}

@Override
@SuppressWarnings("squid:S3740")
public Statistics currentChunkTimeStatistics() {
return getAlignedTimeStatistics(firstChunkMetadata, super.currentChunkTimeStatistics());
}

@Override
@SuppressWarnings("squid:S3740")
public Statistics currentPageTimeStatistics() {
if (firstPageReader == null || firstPageReader instanceof LazyMemVersionPageReader) {
return super.currentPageTimeStatistics();
}
return getAlignedTimeStatistics(
firstPageReader.getPageReader(), super.currentPageTimeStatistics());
}

private boolean canUseAlignedTimeStatistics(IMetadata metadata) {
if (!ignoreAllNullRows || metadata == null) {
return true;
}
return timeAllSelected(metadata) || hasAtMostOneNonNullMeasurement(metadata);
}

private boolean hasAtMostOneNonNullMeasurement(IMetadata metadata) {
int nonNullCount = 0;
for (int i = 0, count = metadata.getMeasurementCount(); i < count; i++) {
Statistics<?> valueStats = metadata.getMeasurementStatistics(i).orElse(null);
if (valueStats != null && !valueStats.isEmpty() && ++nonNullCount > 1) {
return false;
}
}
return true;
}

@SuppressWarnings("squid:S3740")
private Statistics getAlignedTimeStatistics(IMetadata metadata, Statistics timeStatistics) {
if (!ignoreAllNullRows || metadata == null || timeStatistics == null) {
return timeStatistics;
}
int measurementCount = metadata.getMeasurementCount();
if (measurementCount <= 0) {
return timeStatistics;
}
Statistics singleNonNullMeasurementStatistics = null;
int nonNullCount = 0;
for (int i = 0; i < measurementCount; i++) {
Statistics valueStats = metadata.getMeasurementStatistics(i).orElse(null);
if (valueStats != null && !valueStats.isEmpty()) {
if (++nonNullCount > 1) {
return timeStatistics;
}
singleNonNullMeasurementStatistics = valueStats;
}
}
return nonNullCount == 1 ? singleNonNullMeasurementStatistics : timeStatistics;
}

@Override
protected boolean timeAllSelected(IMetadata metadata) {
if (queryAllSensors || metadata.getMeasurementCount() == 0) {
if (!ignoreAllNullRows || metadata.getMeasurementCount() == 0) {
return true;
}
return metadata.timeAllSelected();
Expand Down
Loading
Loading