From 24205774c45917a6ac7d64fb3faf96b0ba405156 Mon Sep 17 00:00:00 2001 From: Tian Jiang Date: Sun, 4 Jan 2026 16:04:41 +0800 Subject: [PATCH 01/10] add void writeToFileWriter(TsFileIOWriter tsfileWriter, Function measurementNameRemapper) throws IOException; --- .../write/chunk/AlignedChunkWriterImpl.java | 10 ++++++++++ .../tsfile/write/chunk/ChunkWriterImpl.java | 19 ++++++++++++++----- .../tsfile/write/chunk/IChunkWriter.java | 6 ++++++ .../tsfile/write/chunk/ValueChunkWriter.java | 16 ++++++++++++---- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java index 27761e678..08ae57536 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java @@ -18,6 +18,7 @@ */ package org.apache.tsfile.write.chunk; +import java.util.function.Function; import org.apache.tsfile.block.column.Column; import org.apache.tsfile.common.conf.TSFileDescriptor; import org.apache.tsfile.encoding.encoder.Encoder; @@ -477,6 +478,15 @@ public void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException { } } + @Override + public void writeToFileWriter(TsFileIOWriter tsfileWriter, + Function measurementNameRemapper) throws IOException { + timeChunkWriter.writeToFileWriter(tsfileWriter); + for (ValueChunkWriter valueChunkWriter : valueChunkWriterList) { + valueChunkWriter.writeToFileWriter(tsfileWriter, measurementNameRemapper); + } + } + @Override public long estimateMaxSeriesMemSize() { long estimateMaxSeriesMemSize = timeChunkWriter.estimateMaxSeriesMemSize(); diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java index 25e0410b0..d450b3733 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java @@ -18,6 +18,7 @@ */ package org.apache.tsfile.write.chunk; +import java.util.function.Function; import org.apache.tsfile.common.conf.TSFileDescriptor; import org.apache.tsfile.compress.ICompressor; import org.apache.tsfile.encoding.encoder.SDTEncoder; @@ -346,8 +347,14 @@ private void writePageToPageBuffer() { @Override public void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException { + writeToFileWriter(tsfileWriter, null); + } + + @Override + public void writeToFileWriter(TsFileIOWriter tsfileWriter, + Function measurementNameRemapper) throws IOException { sealCurrentPage(); - writeAllPagesOfChunkToTsFile(tsfileWriter, statistics); + writeAllPagesOfChunkToTsFile(tsfileWriter, statistics, measurementNameRemapper); // reinit this chunk writer pageBuffer.reset(); @@ -472,19 +479,21 @@ public void writePageHeaderAndDataIntoBuff(ByteBuffer data, PageHeader header) /** * write the page to specified IOWriter. * - * @param writer the specified IOWriter - * @param statistics the chunk statistics + * @param writer the specified IOWriter + * @param statistics the chunk statistics + * @param measurementNameRemapper * @throws IOException exception in IO */ private void writeAllPagesOfChunkToTsFile( - TsFileIOWriter writer, Statistics statistics) throws IOException { + TsFileIOWriter writer, Statistics statistics, + Function measurementNameRemapper) throws IOException { if (statistics.getCount() == 0) { return; } // start to write this column chunk writer.startFlushChunk( - measurementSchema.getMeasurementName(), + measurementNameRemapper == null ? measurementSchema.getMeasurementName() : measurementNameRemapper.apply(measurementSchema.getMeasurementName()), compressor.getType(), measurementSchema.getType(), measurementSchema.getEncodingType(), diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java index 85b9828a7..113040738 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java @@ -18,6 +18,7 @@ */ package org.apache.tsfile.write.chunk; +import java.util.function.Function; import org.apache.tsfile.write.writer.TsFileIOWriter; import java.io.IOException; @@ -28,6 +29,11 @@ public interface IChunkWriter { /** flush data to TsFileIOWriter. */ void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException; + /** + * flush data to TsFileIOWriter, may rename the measurement in the file according to the remapper. + */ + void writeToFileWriter(TsFileIOWriter tsfileWriter, Function measurementNameRemapper) throws IOException; + /** estimate memory usage of this series. */ long estimateMaxSeriesMemSize(); diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java index d011e1258..a778f741d 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java @@ -18,6 +18,7 @@ */ package org.apache.tsfile.write.chunk; +import java.util.function.Function; import org.apache.tsfile.common.conf.TSFileDescriptor; import org.apache.tsfile.common.constant.TsFileConstant; import org.apache.tsfile.compress.ICompressor; @@ -295,8 +296,13 @@ public void writePageHeaderAndDataIntoBuff(ByteBuffer data, PageHeader header) } public void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException { + writeToFileWriter(tsfileWriter, null); + } + + public void writeToFileWriter(TsFileIOWriter tsfileWriter, + Function measurementNameRemapper) throws IOException { sealCurrentPage(); - writeAllPagesOfChunkToTsFile(tsfileWriter); + writeAllPagesOfChunkToTsFile(tsfileWriter, measurementNameRemapper); // reinit this chunk writer pageBuffer.reset(); @@ -385,7 +391,9 @@ public TSDataType getDataType() { * @param writer the specified IOWriter * @throws IOException exception in IO */ - public void writeAllPagesOfChunkToTsFile(TsFileIOWriter writer) throws IOException { + public void writeAllPagesOfChunkToTsFile(TsFileIOWriter writer, + Function measurementNameRemapper) throws IOException { + String finalMeasurementId = measurementNameRemapper == null ? measurementId : measurementNameRemapper.apply(measurementId); if (statistics.getCount() == 0) { if (pageBuffer.size() == 0) { return; @@ -395,7 +403,7 @@ public void writeAllPagesOfChunkToTsFile(TsFileIOWriter writer) throws IOExcepti // chunkGroup during compaction. To save the disk space, we only serialize chunkHeader for the // empty valueChunk, whose dataSize is 0. writer.startFlushChunk( - measurementId, + finalMeasurementId, compressionType, dataType, encodingType, @@ -409,7 +417,7 @@ public void writeAllPagesOfChunkToTsFile(TsFileIOWriter writer) throws IOExcepti // start to write this column chunk writer.startFlushChunk( - measurementId, + finalMeasurementId, compressionType, dataType, encodingType, From d71552b94a0fb7794541ca2af04ec56cbe05a4d3 Mon Sep 17 00:00:00 2001 From: Tian Jiang Date: Sun, 4 Jan 2026 16:07:41 +0800 Subject: [PATCH 02/10] spotless --- .../write/chunk/AlignedChunkWriterImpl.java | 7 ++++--- .../tsfile/write/chunk/ChunkWriterImpl.java | 21 ++++++++++++------- .../tsfile/write/chunk/IChunkWriter.java | 6 ++++-- .../tsfile/write/chunk/ValueChunkWriter.java | 16 ++++++++------ 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java index 08ae57536..fa3cb3482 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/AlignedChunkWriterImpl.java @@ -18,7 +18,6 @@ */ package org.apache.tsfile.write.chunk; -import java.util.function.Function; import org.apache.tsfile.block.column.Column; import org.apache.tsfile.common.conf.TSFileDescriptor; import org.apache.tsfile.encoding.encoder.Encoder; @@ -42,6 +41,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.function.Function; public class AlignedChunkWriterImpl implements IChunkWriter { @@ -479,8 +479,9 @@ public void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException { } @Override - public void writeToFileWriter(TsFileIOWriter tsfileWriter, - Function measurementNameRemapper) throws IOException { + public void writeToFileWriter( + TsFileIOWriter tsfileWriter, Function measurementNameRemapper) + throws IOException { timeChunkWriter.writeToFileWriter(tsfileWriter); for (ValueChunkWriter valueChunkWriter : valueChunkWriterList) { valueChunkWriter.writeToFileWriter(tsfileWriter, measurementNameRemapper); diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java index d450b3733..742054364 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ChunkWriterImpl.java @@ -18,7 +18,6 @@ */ package org.apache.tsfile.write.chunk; -import java.util.function.Function; import org.apache.tsfile.common.conf.TSFileDescriptor; import org.apache.tsfile.compress.ICompressor; import org.apache.tsfile.encoding.encoder.SDTEncoder; @@ -44,6 +43,7 @@ import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.WritableByteChannel; +import java.util.function.Function; public class ChunkWriterImpl implements IChunkWriter { @@ -351,8 +351,9 @@ public void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException { } @Override - public void writeToFileWriter(TsFileIOWriter tsfileWriter, - Function measurementNameRemapper) throws IOException { + public void writeToFileWriter( + TsFileIOWriter tsfileWriter, Function measurementNameRemapper) + throws IOException { sealCurrentPage(); writeAllPagesOfChunkToTsFile(tsfileWriter, statistics, measurementNameRemapper); @@ -479,21 +480,25 @@ public void writePageHeaderAndDataIntoBuff(ByteBuffer data, PageHeader header) /** * write the page to specified IOWriter. * - * @param writer the specified IOWriter - * @param statistics the chunk statistics + * @param writer the specified IOWriter + * @param statistics the chunk statistics * @param measurementNameRemapper * @throws IOException exception in IO */ private void writeAllPagesOfChunkToTsFile( - TsFileIOWriter writer, Statistics statistics, - Function measurementNameRemapper) throws IOException { + TsFileIOWriter writer, + Statistics statistics, + Function measurementNameRemapper) + throws IOException { if (statistics.getCount() == 0) { return; } // start to write this column chunk writer.startFlushChunk( - measurementNameRemapper == null ? measurementSchema.getMeasurementName() : measurementNameRemapper.apply(measurementSchema.getMeasurementName()), + measurementNameRemapper == null + ? measurementSchema.getMeasurementName() + : measurementNameRemapper.apply(measurementSchema.getMeasurementName()), compressor.getType(), measurementSchema.getType(), measurementSchema.getEncodingType(), diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java index 113040738..4a198841c 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/IChunkWriter.java @@ -18,10 +18,10 @@ */ package org.apache.tsfile.write.chunk; -import java.util.function.Function; import org.apache.tsfile.write.writer.TsFileIOWriter; import java.io.IOException; +import java.util.function.Function; /** IChunkWriter provides a list of writing methods for different value types. */ public interface IChunkWriter { @@ -32,7 +32,9 @@ public interface IChunkWriter { /** * flush data to TsFileIOWriter, may rename the measurement in the file according to the remapper. */ - void writeToFileWriter(TsFileIOWriter tsfileWriter, Function measurementNameRemapper) throws IOException; + void writeToFileWriter( + TsFileIOWriter tsfileWriter, Function measurementNameRemapper) + throws IOException; /** estimate memory usage of this series. */ long estimateMaxSeriesMemSize(); diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java index a778f741d..31ab3f6c4 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java @@ -18,7 +18,6 @@ */ package org.apache.tsfile.write.chunk; -import java.util.function.Function; import org.apache.tsfile.common.conf.TSFileDescriptor; import org.apache.tsfile.common.constant.TsFileConstant; import org.apache.tsfile.compress.ICompressor; @@ -46,6 +45,7 @@ import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.WritableByteChannel; +import java.util.function.Function; public class ValueChunkWriter { @@ -299,8 +299,9 @@ public void writeToFileWriter(TsFileIOWriter tsfileWriter) throws IOException { writeToFileWriter(tsfileWriter, null); } - public void writeToFileWriter(TsFileIOWriter tsfileWriter, - Function measurementNameRemapper) throws IOException { + public void writeToFileWriter( + TsFileIOWriter tsfileWriter, Function measurementNameRemapper) + throws IOException { sealCurrentPage(); writeAllPagesOfChunkToTsFile(tsfileWriter, measurementNameRemapper); @@ -391,9 +392,12 @@ public TSDataType getDataType() { * @param writer the specified IOWriter * @throws IOException exception in IO */ - public void writeAllPagesOfChunkToTsFile(TsFileIOWriter writer, - Function measurementNameRemapper) throws IOException { - String finalMeasurementId = measurementNameRemapper == null ? measurementId : measurementNameRemapper.apply(measurementId); + public void writeAllPagesOfChunkToTsFile( + TsFileIOWriter writer, Function measurementNameRemapper) throws IOException { + String finalMeasurementId = + measurementNameRemapper == null + ? measurementId + : measurementNameRemapper.apply(measurementId); if (statistics.getCount() == 0) { if (pageBuffer.size() == 0) { return; From f54b426de709b4311be6c9a3e0a47caeb5f4470c Mon Sep 17 00:00:00 2001 From: Tian Jiang Date: Sun, 4 Jan 2026 16:10:37 +0800 Subject: [PATCH 03/10] fix test --- .../java/org/apache/tsfile/write/chunk/ValueChunkWriter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java index 31ab3f6c4..a1c03ee5c 100644 --- a/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java +++ b/java/tsfile/src/main/java/org/apache/tsfile/write/chunk/ValueChunkWriter.java @@ -386,6 +386,10 @@ public TSDataType getDataType() { return dataType; } + public void writeAllPagesOfChunkToTsFile(TsFileIOWriter writer) throws IOException { + writeAllPagesOfChunkToTsFile(writer, null); + } + /** * write the page to specified IOWriter. * From 2d081240887b974d4a5e8fcc377bf75dc24b5f55 Mon Sep 17 00:00:00 2001 From: Tian Jiang Date: Sun, 4 Jan 2026 16:07:02 +0800 Subject: [PATCH 04/10] bump version --- cpp/pom.xml | 2 +- cpp/third_party/zlib-1.3.1/treebuild.xml | 188 +++++++++--------- .../zlib-1.3.1/zlib-1.3.1/treebuild.xml | 188 +++++++++--------- java/common/pom.xml | 2 +- java/examples/pom.xml | 4 +- java/pom.xml | 4 +- java/tools/pom.xml | 6 +- java/tsfile/pom.xml | 4 +- pom.xml | 2 +- python/pom.xml | 2 +- 10 files changed, 197 insertions(+), 205 deletions(-) diff --git a/cpp/pom.xml b/cpp/pom.xml index b31b2dc12..25c8a10ae 100644 --- a/cpp/pom.xml +++ b/cpp/pom.xml @@ -22,7 +22,7 @@ org.apache.tsfile tsfile-parent - 2.2.1-SNAPSHOT + 2.2.1-sevo-SNAPSHOT tsfile-cpp pom diff --git a/cpp/third_party/zlib-1.3.1/treebuild.xml b/cpp/third_party/zlib-1.3.1/treebuild.xml index 930b00be4..8e030572a 100644 --- a/cpp/third_party/zlib-1.3.1/treebuild.xml +++ b/cpp/third_party/zlib-1.3.1/treebuild.xml @@ -1,103 +1,99 @@ - + - zip compression library - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + zip compression library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + zip compression library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + zip compression library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + zip compression library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +