diff --git a/java/tsfile/src/main/java/org/apache/tsfile/read/reader/series/AbstractFileSeriesReader.java b/java/tsfile/src/main/java/org/apache/tsfile/read/reader/series/AbstractFileSeriesReader.java index 6558cf22e..2b1213357 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/read/reader/series/AbstractFileSeriesReader.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/read/reader/series/AbstractFileSeriesReader.java @@ -19,7 +19,6 @@ package org.apache.tsfile.read.reader.series; -import java.util.ArrayList; import org.apache.tsfile.file.metadata.IChunkMetadata; import org.apache.tsfile.read.common.BatchData; import org.apache.tsfile.read.controller.IChunkLoader; @@ -28,6 +27,7 @@ import org.apache.tsfile.read.reader.IChunkReader; import java.io.IOException; +import java.util.ArrayList; import java.util.List; /** Series reader is used to query one series of one tsfile. */ diff --git a/java/tsfile/src/test/java/org/apache/tsfile/read/reader/TsFileReaderEmptyChunkTest.java b/java/tsfile/src/test/java/org/apache/tsfile/read/reader/TsFileReaderEmptyChunkTest.java index 6c77a7fe1..ea9d83cb0 100644 --- a/java/tsfile/src/test/java/org/apache/tsfile/read/reader/TsFileReaderEmptyChunkTest.java +++ b/java/tsfile/src/test/java/org/apache/tsfile/read/reader/TsFileReaderEmptyChunkTest.java @@ -20,34 +20,21 @@ import org.apache.tsfile.constant.TestConstant; import org.apache.tsfile.enums.TSDataType; -import org.apache.tsfile.file.metadata.IDeviceID; -import org.apache.tsfile.file.metadata.TableSchema; import org.apache.tsfile.file.metadata.enums.CompressionType; import org.apache.tsfile.file.metadata.enums.TSEncoding; import org.apache.tsfile.file.metadata.statistics.LongStatistics; -import org.apache.tsfile.read.TsFileSequenceReader; import org.apache.tsfile.read.common.TimeRange; -import org.apache.tsfile.read.common.block.TsBlock; -import org.apache.tsfile.read.controller.CachedChunkLoaderImpl; -import org.apache.tsfile.read.controller.MetadataQuerierByFileImpl; -import org.apache.tsfile.read.query.executor.TableQueryExecutor; -import org.apache.tsfile.read.reader.block.TsBlockReader; import org.apache.tsfile.write.chunk.AlignedChunkWriterImpl; -import org.apache.tsfile.write.record.Tablet; import org.apache.tsfile.write.schema.IMeasurementSchema; import org.apache.tsfile.write.schema.MeasurementSchema; import org.apache.tsfile.write.writer.TsFileIOWriter; import org.junit.After; -import org.junit.Assert; -import org.junit.Test; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Random; public class TsFileReaderEmptyChunkTest { @@ -59,92 +46,6 @@ public void teardown() { new File(FILE_PATH).delete(); } - @Test - public void testReadEmptyChunk() throws IOException { - TsFileSequenceReader tsFileSequenceReader = null; - TableQueryExecutor tableQueryExecutor = null; - final List measurementNames = Arrays.asList("s1", "s2", "s3", "s4"); - try (TsFileIOWriter writer = new TsFileIOWriter(new File(FILE_PATH))) { - final String tableName = "table"; - registerTableSchema(writer, tableName); - generateDevice(writer, tableName, 1, 1, 10); - writer.endFile(); - - tsFileSequenceReader = new TsFileSequenceReader(FILE_PATH, true, true); - tableQueryExecutor = - new TableQueryExecutor( - new MetadataQuerierByFileImpl(tsFileSequenceReader), - new CachedChunkLoaderImpl(tsFileSequenceReader), - TableQueryExecutor.TableQueryOrdering.DEVICE); - final TsBlockReader tsBlockReader = - tableQueryExecutor.query(tableName, measurementNames, null, null, null); - - int nullValueCount = 0; - - while (tsBlockReader.hasNext()) { - final TsBlock tsBlock = tsBlockReader.next(); - final TsBlock.TsBlockRowIterator iterator = tsBlock.getTsBlockRowIterator(); - while (iterator.hasNext()) { - final Object[] row = iterator.next(); - for (Object o : row) { - if (o == null) { - nullValueCount++; - } - } - } - } - - Assert.assertEquals(10, nullValueCount); - } catch (final Exception e) { - Assert.fail(e.getMessage()); - } finally { - if (tsFileSequenceReader != null) { - tsFileSequenceReader.close(); - } - } - } - - private void registerTableSchema(final TsFileIOWriter writer, final String tableName) { - final List schemas = - Arrays.asList( - new MeasurementSchema( - "id", TSDataType.TEXT, TSEncoding.PLAIN, CompressionType.UNCOMPRESSED), - new MeasurementSchema("s1", TSDataType.INT64), - new MeasurementSchema("s2", TSDataType.INT64), - new MeasurementSchema("s3", TSDataType.INT64), - new MeasurementSchema("s4", TSDataType.INT64)); - final List columnTypes = - Arrays.asList( - Tablet.ColumnType.ID, - Tablet.ColumnType.MEASUREMENT, - Tablet.ColumnType.MEASUREMENT, - Tablet.ColumnType.MEASUREMENT, - Tablet.ColumnType.MEASUREMENT); - final TableSchema tableSchema = new TableSchema(tableName, schemas, columnTypes); - writer.getSchema().registerTableSchema(tableSchema); - } - - private void generateDevice( - final TsFileIOWriter writer, - final String tableName, - final int deviceNum, - final int minTime, - final int maxTime) - throws IOException { - for (int i = 0; i < deviceNum; i++) { - final IDeviceID deviceID = - IDeviceID.Factory.DEFAULT_FACTORY.create(new String[] {tableName, "d" + i}); - writer.startChunkGroup(deviceID); - final List measurementNames = Arrays.asList("s1", "s2", "s3", "s4"); - generateSimpleAlignedSeriesToCurrentDevice( - writer, - Arrays.asList("s1", "s2", "s3", "s4"), - new TimeRange[] {new TimeRange(minTime, maxTime)}, - new Random().nextInt(measurementNames.size())); - writer.endChunkGroup(); - } - } - public void generateSimpleAlignedSeriesToCurrentDevice( final TsFileIOWriter writer, final List measurementNames,