Class CompressionMetadata

  • All Implemented Interfaces:
    java.lang.AutoCloseable, SharedCloseable

    public class CompressionMetadata
    extends WrappedSharedCloseable
    Holds metadata about compressed file TODO extract interface ICompressionMetadata which will just provide non-resource properties
    • Field Detail

      • dataLength

        public final long dataLength
      • compressedFileLength

        public final long compressedFileLength
      • chunksIndexFile

        public final File chunksIndexFile
    • Constructor Detail

      • CompressionMetadata

        public CompressionMetadata​(File chunksIndexFile,
                                   CompressionParams parameters,
                                   Memory chunkOffsets,
                                   long chunkOffsetsSize,
                                   long dataLength,
                                   long compressedFileLength)
    • Method Detail

      • open

        public static CompressionMetadata open​(File chunksIndexFile,
                                               long compressedLength,
                                               boolean hasMaxCompressedSize)
      • chunkLength

        public int chunkLength()
      • maxCompressedLength

        public int maxCompressedLength()
      • offHeapSize

        public long offHeapSize()
        Returns the amount of memory in bytes used off heap.
        Returns:
        the amount of memory in bytes used off heap
      • sharedCopy

        public CompressionMetadata sharedCopy()
        Returns:
        a new instance of the object representing the same state and backed by the same underlying resources. Coordinates with the original (and other instances) when the underlying resource should be closed. Throws an exception if the shared resource has already been closed.
      • chunkFor

        public CompressionMetadata.Chunk chunkFor​(long position)
        Get a chunk of compressed data (offset, length) corresponding to given position
        Parameters:
        position - Position in the file.
        Returns:
        pair of chunk offset and length.
      • getDataOffsetForChunkOffset

        public long getDataOffsetForChunkOffset​(long chunkOffset)
      • getTotalSizeForSections

        public long getTotalSizeForSections​(java.util.Collection<SSTableReader.PartitionPositionBounds> sections)
        Parameters:
        sections - Collection of sections in uncompressed file. Should not contain sections that overlap each other.
        Returns:
        Total chunk size in bytes for given sections including checksum.
      • getChunksForSections

        public CompressionMetadata.Chunk[] getChunksForSections​(java.util.Collection<SSTableReader.PartitionPositionBounds> sections)
        Parameters:
        sections - Collection of sections in uncompressed file
        Returns:
        Array of chunks which corresponds to given sections of uncompressed file, sorted by chunk offset