Class ChunkWriterImpl

  • All Implemented Interfaces:
    IChunkWriter

    public class ChunkWriterImpl
    extends java.lang.Object
    implements IChunkWriter
    • Constructor Detail

      • ChunkWriterImpl

        public ChunkWriterImpl​(IMeasurementSchema schema)
        Parameters:
        schema - schema of this measurement
      • ChunkWriterImpl

        public ChunkWriterImpl​(IMeasurementSchema schema,
                               boolean isMerging)
    • Method Detail

      • write

        public void write​(long time,
                          long value)
      • write

        public void write​(long time,
                          int value)
      • write

        public void write​(long time,
                          boolean value)
      • write

        public void write​(long time,
                          float value)
      • write

        public void write​(long time,
                          double value)
      • write

        public void write​(long time,
                          Binary value)
      • write

        public void write​(long[] timestamps,
                          int[] values,
                          int batchSize)
      • write

        public void write​(long[] timestamps,
                          long[] values,
                          int batchSize)
      • write

        public void write​(long[] timestamps,
                          boolean[] values,
                          int batchSize)
      • write

        public void write​(long[] timestamps,
                          float[] values,
                          int batchSize)
      • write

        public void write​(long[] timestamps,
                          double[] values,
                          int batchSize)
      • write

        public void write​(long[] timestamps,
                          Binary[] values,
                          int batchSize)
      • writeToFileWriter

        public void writeToFileWriter​(TsFileIOWriter tsfileWriter)
                               throws java.io.IOException
        Description copied from interface: IChunkWriter
        flush data to TsFileIOWriter.
        Specified by:
        writeToFileWriter in interface IChunkWriter
        Throws:
        java.io.IOException
      • getSerializedChunkSize

        public long getSerializedChunkSize()
        Description copied from interface: IChunkWriter
        return the serialized size of the chunk header + all pages (not including the un-sealed page). Notice, call this method before calling writeToFileWriter(), otherwise the page buffer in memory will be cleared.
        If there is no data points in the chunk, return 0 (i.e., in this case, the size of header is not calculated, because nothing will be serialized latter)
        Specified by:
        getSerializedChunkSize in interface IChunkWriter
      • sealCurrentPage

        public void sealCurrentPage()
        Description copied from interface: IChunkWriter
        seal the current page which may has not enough data points in force.
        Specified by:
        sealCurrentPage in interface IChunkWriter
      • clearPageWriter

        public void clearPageWriter()
        Description copied from interface: IChunkWriter
        set the current pageWriter to null, friendly for gc
        Specified by:
        clearPageWriter in interface IChunkWriter
      • checkIsUnsealedPageOverThreshold

        public boolean checkIsUnsealedPageOverThreshold​(long size,
                                                        long pointNum,
                                                        boolean returnTrueIfPageEmpty)
        Description copied from interface: IChunkWriter
        used for compaction to check whether the unsealed page is over threshold or not. Return true if there is no unsealed page.
        Specified by:
        checkIsUnsealedPageOverThreshold in interface IChunkWriter
      • checkIsChunkSizeOverThreshold

        public boolean checkIsChunkSizeOverThreshold​(long size,
                                                     long pointNum,
                                                     boolean returnTrueIfChunkEmpty)
        Description copied from interface: IChunkWriter
        used for compaction to check whether the chunk is over threshold or not. Return true if there is no unsealed chunk.
        Specified by:
        checkIsChunkSizeOverThreshold in interface IChunkWriter
      • writePageHeaderAndDataIntoBuff

        public void writePageHeaderAndDataIntoBuff​(java.nio.ByteBuffer data,
                                                   PageHeader header)
                                            throws PageException
        write the page header and data into the PageWriter's output stream. @NOTE: for upgrading 0.11/v2 to 0.12/v3 TsFile
        Throws:
        PageException
      • setIsMerging

        public void setIsMerging​(boolean isMerging)
      • isMerging

        public boolean isMerging()
      • setLastPoint

        public void setLastPoint​(boolean isLastPoint)
      • getPageWriter

        public PageWriter getPageWriter()
        Only used for tests.