Skip to content

Commit

Permalink
spotless & remove V4 related test
Browse files Browse the repository at this point in the history
(cherry picked from commit b93019f)
  • Loading branch information
jt2594838 committed Nov 11, 2024
1 parent 1716a88 commit 0bc238b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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<String> 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<IMeasurementSchema> 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<Tablet.ColumnType> 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<String> 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<String> measurementNames,
Expand Down

0 comments on commit 0bc238b

Please sign in to comment.