|
27 | 27 | import org.apache.tsfile.enums.TSDataType; |
28 | 28 | import org.apache.tsfile.file.metadata.AbstractAlignedChunkMetadata; |
29 | 29 | import org.apache.tsfile.file.metadata.AbstractAlignedTimeSeriesMetadata; |
30 | | -import org.apache.tsfile.file.metadata.AlignedChunkMetadata; |
31 | 30 | import org.apache.tsfile.file.metadata.ChunkMetadata; |
32 | 31 | import org.apache.tsfile.file.metadata.IChunkMetadata; |
33 | 32 | import org.apache.tsfile.file.metadata.TimeseriesMetadata; |
|
41 | 40 | import org.slf4j.LoggerFactory; |
42 | 41 |
|
43 | 42 | import java.nio.charset.StandardCharsets; |
44 | | -import java.util.ArrayList; |
45 | 43 | import java.util.Arrays; |
46 | 44 | import java.util.Collections; |
47 | 45 | import java.util.HashMap; |
@@ -400,25 +398,20 @@ public static void changeAlignedMetadataModified( |
400 | 398 | } |
401 | 399 | } |
402 | 400 |
|
403 | | - public static AbstractAlignedChunkMetadata rewriteAlignedChunkMetadataStatistics( |
404 | | - AbstractAlignedChunkMetadata alignedChunkMetadata, TSDataType targetDataType) { |
405 | | - List<IChunkMetadata> newValueChunkMetadataList = new ArrayList<>(); |
406 | | - for (IChunkMetadata valueChunkMetadata : alignedChunkMetadata.getValueChunkMetadataList()) { |
407 | | - if (valueChunkMetadata != null |
408 | | - && targetDataType.isCompatible(valueChunkMetadata.getDataType())) { |
409 | | - Statistics<?> statistics = Statistics.getStatsByType(targetDataType); |
410 | | - statistics = getNewStatistics(valueChunkMetadata, targetDataType, statistics); |
411 | | - |
412 | | - ChunkMetadata newChunkMetadata = (ChunkMetadata) valueChunkMetadata; |
413 | | - newChunkMetadata.setTsDataType(targetDataType); |
414 | | - newChunkMetadata.setStatistics(statistics); |
415 | | - newValueChunkMetadataList.add(newChunkMetadata); |
416 | | - } else { |
417 | | - newValueChunkMetadataList.add(null); |
418 | | - } |
| 401 | + public static void rewriteAlignedChunkMetadataStatistics( |
| 402 | + AbstractAlignedChunkMetadata alignedChunkMetadata, int index, TSDataType targetDataType) { |
| 403 | + IChunkMetadata valueChunkMetadata = alignedChunkMetadata.getValueChunkMetadataList().get(index); |
| 404 | + if (valueChunkMetadata != null |
| 405 | + && targetDataType.isCompatible(valueChunkMetadata.getDataType())) { |
| 406 | + Statistics<?> statistics = Statistics.getStatsByType(targetDataType); |
| 407 | + statistics = getNewStatistics(valueChunkMetadata, targetDataType, statistics); |
| 408 | + |
| 409 | + ChunkMetadata newChunkMetadata = (ChunkMetadata) valueChunkMetadata; |
| 410 | + newChunkMetadata.setTsDataType(targetDataType); |
| 411 | + newChunkMetadata.setStatistics(statistics); |
| 412 | + } else { |
| 413 | + alignedChunkMetadata.getValueChunkMetadataList().set(index, null); |
419 | 414 | } |
420 | | - return new AlignedChunkMetadata( |
421 | | - alignedChunkMetadata.getTimeChunkMetadata(), newValueChunkMetadataList); |
422 | 415 | } |
423 | 416 |
|
424 | 417 | public static void rewriteNonAlignedChunkMetadataStatistics( |
|
0 commit comments