This is an automated email from the ASF dual-hosted git repository. marklau99 pushed a commit to branch IOTDB-4636 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 34d3d9b841edf3c2e8596e89de1186838f1c12c2 Author: Liu Xuxin <[email protected]> AuthorDate: Mon Oct 17 15:32:37 2022 +0800 check before compacting aligned timeseries --- .../performer/impl/ReadChunkCompactionPerformer.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/engine/compaction/performer/impl/ReadChunkCompactionPerformer.java b/server/src/main/java/org/apache/iotdb/db/engine/compaction/performer/impl/ReadChunkCompactionPerformer.java index 582cc82e15..a730730964 100644 --- a/server/src/main/java/org/apache/iotdb/db/engine/compaction/performer/impl/ReadChunkCompactionPerformer.java +++ b/server/src/main/java/org/apache/iotdb/db/engine/compaction/performer/impl/ReadChunkCompactionPerformer.java @@ -78,13 +78,11 @@ public class ReadChunkCompactionPerformer implements ISeqCompactionPerformer { String device = deviceInfo.left; boolean aligned = deviceInfo.right; - writer.startChunkGroup(device); if (aligned) { compactAlignedSeries(device, targetResource, writer, deviceIterator); } else { compactNotAlignedSeries(device, targetResource, writer, deviceIterator); } - writer.endChunkGroup(); } for (TsFileResource tsFileResource : seqFiles) { @@ -120,10 +118,20 @@ public class ReadChunkCompactionPerformer implements ISeqCompactionPerformer { checkThreadInterrupted(); LinkedList<Pair<TsFileSequenceReader, List<AlignedChunkMetadata>>> readerAndChunkMetadataList = deviceIterator.getReaderAndChunkMetadataForCurrentAlignedSeries(); + boolean anyChunkExists = false; + for (Pair<TsFileSequenceReader, List<AlignedChunkMetadata>> readerListPair : + readerAndChunkMetadataList) { + anyChunkExists = anyChunkExists || !readerListPair.right.isEmpty(); + } + if (!anyChunkExists) { + return; + } + writer.startChunkGroup(device); AlignedSeriesCompactionExecutor compactionExecutor = new AlignedSeriesCompactionExecutor( device, targetResource, readerAndChunkMetadataList, writer); compactionExecutor.execute(); + writer.endChunkGroup(); } private void checkThreadInterrupted() throws InterruptedException { @@ -140,6 +148,7 @@ public class ReadChunkCompactionPerformer implements ISeqCompactionPerformer { TsFileIOWriter writer, MultiTsFileDeviceIterator deviceIterator) throws IOException, MetadataException, InterruptedException { + writer.startChunkGroup(device); MultiTsFileDeviceIterator.MeasurementIterator seriesIterator = deviceIterator.iterateNotAlignedSeries(device, true); while (seriesIterator.hasNextSeries()) { @@ -155,6 +164,7 @@ public class ReadChunkCompactionPerformer implements ISeqCompactionPerformer { new SingleSeriesCompactionExecutor(p, readerAndChunkMetadataList, writer, targetResource); compactionExecutorOfCurrentTimeSeries.execute(); } + writer.endChunkGroup(); } @Override
