Class CompressionMetadata

All Implemented Interfaces:
AutoCloseable, SharedCloseable

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

    • dataLength

      public final long dataLength
    • compressedFileLength

      public final long compressedFileLength
    • chunksIndexFile

      public final File chunksIndexFile
    • parameters

      public final CompressionParams parameters
  • Constructor Details

    • CompressionMetadata

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

    • open

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

      public ICompressor compressor()
    • 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
    • addTo

      public void addTo(Ref.IdentityCollection identities)
      Specified by:
      addTo in interface SharedCloseable
      Overrides:
      addTo in class SharedCloseableImpl
    • 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(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

      Parameters:
      sections - Collection of sections in uncompressed file
      Returns:
      Array of chunks which corresponds to given sections of uncompressed file, sorted by chunk offset