Copilot commented on code in PR #17297: URL: https://github.com/apache/iotdb/pull/17297#discussion_r2944107160
########## iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/alterDataType/CompactionDataTypeNotMatchAlterableDataTypeTest.java: ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.db.storageengine.dataregion.compaction.alterDataType; + +import org.apache.iotdb.commons.exception.IllegalPathException; +import org.apache.iotdb.commons.exception.MetadataException; +import org.apache.iotdb.commons.path.MeasurementPath; +import org.apache.iotdb.db.exception.StorageEngineException; +import org.apache.iotdb.db.storageengine.dataregion.compaction.execute.task.InnerSpaceCompactionTask; +import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource; +import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResourceStatus; +import org.apache.iotdb.db.storageengine.dataregion.utils.TsFileResourceUtils; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.exception.write.WriteProcessException; +import org.apache.tsfile.read.common.Path; +import org.apache.tsfile.read.common.TimeRange; +import org.apache.tsfile.write.TsFileWriter; +import org.apache.tsfile.write.record.TSRecord; +import org.apache.tsfile.write.record.datapoint.DoubleDataPoint; +import org.apache.tsfile.write.record.datapoint.FloatDataPoint; +import org.apache.tsfile.write.schema.IMeasurementSchema; +import org.apache.tsfile.write.schema.MeasurementSchema; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +@SuppressWarnings("OptionalGetWithoutIsPresent") +@RunWith(Parameterized.class) +public class CompactionDataTypeNotMatchAlterableDataTypeTest + extends AbstractCompactionAlterDataTypeTest { + + private String performerType; + + @Before + public void setUp() + throws IOException, WriteProcessException, MetadataException, InterruptedException { + super.setUp(); + } + + @After + public void tearDown() throws IOException, StorageEngineException { + super.tearDown(); + } + + @Parameterized.Parameters(name = "type={0}") + public static Collection<Object[]> data() { + return Arrays.asList( + new Object[][] { + {"read_chunk"}, {"fast"}, {"read_point"}, + }); + } + + public CompactionDataTypeNotMatchAlterableDataTypeTest(String type) { + this.performerType = type; + } + + @Test + public void testCompactNonAlignedSeries() + throws IOException, WriteProcessException, IllegalPathException { + generateDataTypeNotMatchFilesWithNonAlignedSeries(); + InnerSpaceCompactionTask task = + new InnerSpaceCompactionTask( + 0, tsFileManager, seqResources, true, getPerformer(performerType), 0); + Assert.assertTrue(task.start()); + TsFileResourceUtils.validateTsFileDataCorrectness(tsFileManager.getTsFileList(true).get(0)); + Assert.assertEquals( + 1, ((long) tsFileManager.getTsFileList(true).get(0).getStartTime(device).get())); + } + + @Test + public void testCompactAlignedSeriesWithReadChunkCompactionPerformer() + throws IOException, WriteProcessException, IllegalPathException { + generateDataTypeNotMatchFilesWithAlignedSeries(); + InnerSpaceCompactionTask task = + new InnerSpaceCompactionTask( + 0, tsFileManager, seqResources, true, getPerformer(performerType), 0); + Assert.assertTrue(task.start()); + TsFileResourceUtils.validateTsFileDataCorrectness(tsFileManager.getTsFileList(true).get(0)); + Assert.assertEquals( + 1, ((long) tsFileManager.getTsFileList(true).get(0).getStartTime(device).get())); + } + + private void generateDataTypeNotMatchFilesWithNonAlignedSeries() + throws IOException, WriteProcessException, IllegalPathException { + MeasurementSchema measurementSchema1 = new MeasurementSchema("s1", TSDataType.INT32); + TsFileResource resource1 = generateInt32NonAlignedSeriesFile(new TimeRange(1, 1), true); + seqResources.add(resource1); + + MeasurementSchema measurementSchema2 = new MeasurementSchema("s1", TSDataType.FLOAT); + TsFileResource resource2 = generateFloatNonAlignedSeriesFile(new TimeRange(2, 2), true); + seqResources.add(resource2); + + schemaFetcher + .getSchemaTree() + .appendSingleMeasurementPath(new MeasurementPath(device, "s1", measurementSchema2)); + } + + private void generateDataTypeNotMatchFilesWithAlignedSeries() + throws IOException, WriteProcessException, IllegalPathException { + List<IMeasurementSchema> measurementSchemas1 = new ArrayList<>(); + measurementSchemas1.add(new MeasurementSchema("s1", TSDataType.INT32)); + measurementSchemas1.add(new MeasurementSchema("s2", TSDataType.INT32)); + Review Comment: `measurementSchemas1` is built but never used (the test uses `generateInt32AlignedSeriesFile(...)` which defines its own schemas). Removing this unused local variable will avoid confusion about which schema set is intended to drive the file generation. ########## iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/alterDataType/CompactionDataTypeNotMatchAlterableDataTypeTest.java: ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.db.storageengine.dataregion.compaction.alterDataType; + +import org.apache.iotdb.commons.exception.IllegalPathException; +import org.apache.iotdb.commons.exception.MetadataException; +import org.apache.iotdb.commons.path.MeasurementPath; +import org.apache.iotdb.db.exception.StorageEngineException; +import org.apache.iotdb.db.storageengine.dataregion.compaction.execute.task.InnerSpaceCompactionTask; +import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResource; +import org.apache.iotdb.db.storageengine.dataregion.tsfile.TsFileResourceStatus; +import org.apache.iotdb.db.storageengine.dataregion.utils.TsFileResourceUtils; + +import org.apache.tsfile.enums.TSDataType; +import org.apache.tsfile.exception.write.WriteProcessException; +import org.apache.tsfile.read.common.Path; +import org.apache.tsfile.read.common.TimeRange; +import org.apache.tsfile.write.TsFileWriter; +import org.apache.tsfile.write.record.TSRecord; +import org.apache.tsfile.write.record.datapoint.DoubleDataPoint; +import org.apache.tsfile.write.record.datapoint.FloatDataPoint; +import org.apache.tsfile.write.schema.IMeasurementSchema; +import org.apache.tsfile.write.schema.MeasurementSchema; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +@SuppressWarnings("OptionalGetWithoutIsPresent") +@RunWith(Parameterized.class) +public class CompactionDataTypeNotMatchAlterableDataTypeTest + extends AbstractCompactionAlterDataTypeTest { + + private String performerType; + + @Before + public void setUp() + throws IOException, WriteProcessException, MetadataException, InterruptedException { + super.setUp(); + } + + @After + public void tearDown() throws IOException, StorageEngineException { + super.tearDown(); + } + + @Parameterized.Parameters(name = "type={0}") + public static Collection<Object[]> data() { + return Arrays.asList( + new Object[][] { + {"read_chunk"}, {"fast"}, {"read_point"}, + }); + } + + public CompactionDataTypeNotMatchAlterableDataTypeTest(String type) { + this.performerType = type; + } + + @Test + public void testCompactNonAlignedSeries() + throws IOException, WriteProcessException, IllegalPathException { + generateDataTypeNotMatchFilesWithNonAlignedSeries(); + InnerSpaceCompactionTask task = + new InnerSpaceCompactionTask( + 0, tsFileManager, seqResources, true, getPerformer(performerType), 0); + Assert.assertTrue(task.start()); + TsFileResourceUtils.validateTsFileDataCorrectness(tsFileManager.getTsFileList(true).get(0)); + Assert.assertEquals( + 1, ((long) tsFileManager.getTsFileList(true).get(0).getStartTime(device).get())); + } + + @Test + public void testCompactAlignedSeriesWithReadChunkCompactionPerformer() Review Comment: `testCompactAlignedSeriesWithReadChunkCompactionPerformer` is parameterized and runs for `read_chunk`, `fast`, and `read_point`, so the method name is misleading. Rename it to a performer-agnostic name (e.g., `testCompactAlignedSeries`) to reflect what it actually validates and to keep test reports accurate. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
