Class TsFileOnlineUpgradeTool

    • Constructor Detail

      • TsFileOnlineUpgradeTool

        public TsFileOnlineUpgradeTool​(TsFileResource resourceToBeUpgraded)
                                throws java.io.IOException
        Create a file reader of the given file. This reader will read the old file and rewrite it to a new format(v3) file
        Parameters:
        resourceToBeUpgraded - the old tsfile resource which need to be upgrade
        Throws:
        java.io.IOException - If some I/O error occurs
    • Method Detail

      • upgradeOneTsFile

        public static void upgradeOneTsFile​(TsFileResource resourceToBeUpgraded,
                                            java.util.List<TsFileResource> upgradedResources)
                                     throws java.io.IOException,
                                            org.apache.iotdb.tsfile.exception.write.WriteProcessException
        upgrade a single TsFile.
        Parameters:
        resourceToBeUpgraded - the old file's resource which need to be upgrade.
        upgradedResources - new version tsFiles' resources
        Throws:
        java.io.IOException
        org.apache.iotdb.tsfile.exception.write.WriteProcessException
      • upgradeTsFileName

        public java.lang.String upgradeTsFileName​(java.lang.String oldTsFileName)
        TsFileName is changing like from 1610635230693-1-0.tsfile to 1610635230693-1-0-0.tsfile
        Overrides:
        upgradeTsFileName in class TsFileSplitByPartitionTool
      • checkIfNeedToDecode

        protected boolean checkIfNeedToDecode​(org.apache.iotdb.tsfile.file.metadata.enums.TSDataType dataType,
                                              org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding encoding,
                                              org.apache.iotdb.tsfile.file.header.PageHeader pageHeader,
                                              org.apache.iotdb.tsfile.write.schema.MeasurementSchema schema,
                                              java.lang.String deviceId,
                                              long chunkHeaderOffset)
                                       throws org.apache.iotdb.commons.exception.IllegalPathException
        Due to TsFile version-3 changed the serialize way of integer in TEXT data and INT32 data with PLAIN encoding, and also add a sum statistic for BOOLEAN data, these types of data need to decode to points and rewrite in new TsFile.
        Throws:
        org.apache.iotdb.commons.exception.IllegalPathException
      • decodeAndWritePage

        protected void decodeAndWritePage​(org.apache.iotdb.tsfile.write.schema.MeasurementSchema schema,
                                          java.nio.ByteBuffer pageData,
                                          java.util.Map<java.lang.Long,​org.apache.iotdb.tsfile.write.chunk.ChunkWriterImpl> partitionChunkWriterMap)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • fileCheck

        protected boolean fileCheck()
                             throws java.io.IOException
        check if the file to be upgraded has correct magic strings and version number
        Overrides:
        fileCheck in class TsFileSplitByPartitionTool
        Throws:
        java.io.IOException