public class TsFileRewriteTool extends Object implements AutoCloseable
| 限定符和类型 | 字段和说明 |
|---|---|
protected Decoder |
defaultTimeDecoder |
protected long |
maxPlanIndex
Maximum index of plans executed within this TsFile.
|
protected long |
minPlanIndex
Minimum index of plans executed within this TsFile.
|
protected Iterator<Modification> |
modsIterator |
protected List<Modification> |
oldModification |
protected File |
oldTsFile |
protected TsFileResource |
oldTsFileResource |
protected Map<Long,TsFileIOWriter> |
partitionWriterMap
PartitionId -> TsFileIOWriter
|
protected TsFileSequenceReader |
reader |
protected Decoder |
valueDecoder |
| 构造器和说明 |
|---|
TsFileRewriteTool(TsFileResource resourceToBeRewritten)
Create a file reader of the given file.
|
TsFileRewriteTool(TsFileResource resourceToBeRewritten,
boolean needReaderForV2) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected boolean |
checkIfNeedToDecode(MeasurementSchema schema,
String deviceId,
PageHeader pageHeader,
long chunkHeaderOffset)
If the page have no statistics or crosses multi partitions, will return true, otherwise return
false.
|
void |
close() |
protected void |
decodeAndWritePage(String deviceId,
MeasurementSchema schema,
ByteBuffer pageData,
Map<Long,ChunkWriterImpl> partitionChunkWriterMap,
long chunkHeaderOffset) |
protected void |
endChunkGroup() |
protected TsFileResource |
endFileAndGenerateResource(TsFileIOWriter tsFileIOWriter) |
protected boolean |
fileCheck()
check if the file has correct magic strings and version number
|
protected TsFileIOWriter |
getOrDefaultTsFileIOWriter(File oldTsFile,
long partition) |
void |
parseAndRewriteFile(List<TsFileResource> rewrittenResources)
Parse the old files and generate some new files according to the time partition interval.
|
protected void |
reWriteChunk(String deviceId,
boolean firstChunkInChunkGroup,
MeasurementSchema schema,
List<PageHeader> pageHeadersInChunk,
List<ByteBuffer> pageDataInChunk,
List<Boolean> needToDecodeInfoInChunk,
long chunkHeaderOffset)
This method is for rewriting the Chunk which data is in the different time partitions.
|
protected void |
rewritePageIntoFiles(BatchData batchData,
MeasurementSchema schema,
Map<Long,ChunkWriterImpl> partitionChunkWriterMap) |
static void |
rewriteTsFile(TsFileResource resourceToBeRewritten,
List<TsFileResource> rewrittenResources)
Rewrite an old file to the latest version
|
String |
upgradeTsFileName(String oldTsFileName) |
protected void |
writePage(MeasurementSchema schema,
PageHeader pageHeader,
ByteBuffer pageData,
Map<Long,ChunkWriterImpl> partitionChunkWriterMap) |
protected TsFileSequenceReader reader
protected File oldTsFile
protected List<Modification> oldModification
protected TsFileResource oldTsFileResource
protected Iterator<Modification> modsIterator
protected Decoder defaultTimeDecoder
protected Decoder valueDecoder
protected Map<Long,TsFileIOWriter> partitionWriterMap
protected long maxPlanIndex
protected long minPlanIndex
public TsFileRewriteTool(TsFileResource resourceToBeRewritten) throws IOException
IOException - If some I/O error occurspublic TsFileRewriteTool(TsFileResource resourceToBeRewritten, boolean needReaderForV2) throws IOException
IOExceptionpublic static void rewriteTsFile(TsFileResource resourceToBeRewritten, List<TsFileResource> rewrittenResources) throws IOException, WriteProcessException, IllegalPathException
resourceToBeRewritten - the tsfile which to be rewriterewrittenResources - the rewritten filesIOExceptionWriteProcessExceptionIllegalPathExceptionpublic void close()
throws IOException
close 在接口中 AutoCloseableIOExceptionpublic void parseAndRewriteFile(List<TsFileResource> rewrittenResources) throws IOException, WriteProcessException, IllegalPathException
IOException - WriteProcessExceptionWriteProcessExceptionIllegalPathExceptionprotected boolean checkIfNeedToDecode(MeasurementSchema schema, String deviceId, PageHeader pageHeader, long chunkHeaderOffset) throws IllegalPathException
protected void reWriteChunk(String deviceId, boolean firstChunkInChunkGroup, MeasurementSchema schema, List<PageHeader> pageHeadersInChunk, List<ByteBuffer> pageDataInChunk, List<Boolean> needToDecodeInfoInChunk, long chunkHeaderOffset) throws IOException, PageException, IllegalPathException
protected void endChunkGroup()
throws IOException
IOExceptionprotected TsFileIOWriter getOrDefaultTsFileIOWriter(File oldTsFile, long partition)
protected void writePage(MeasurementSchema schema, PageHeader pageHeader, ByteBuffer pageData, Map<Long,ChunkWriterImpl> partitionChunkWriterMap) throws PageException
PageExceptionprotected void decodeAndWritePage(String deviceId, MeasurementSchema schema, ByteBuffer pageData, Map<Long,ChunkWriterImpl> partitionChunkWriterMap, long chunkHeaderOffset) throws IOException, IllegalPathException
protected void rewritePageIntoFiles(BatchData batchData, MeasurementSchema schema, Map<Long,ChunkWriterImpl> partitionChunkWriterMap)
protected boolean fileCheck()
throws IOException
IOExceptionprotected TsFileResource endFileAndGenerateResource(TsFileIOWriter tsFileIOWriter) throws IOException
IOExceptionCopyright © 2022 The Apache Software Foundation. All rights reserved.