Package org.apache.cassandra.io.compress
Class CompressionMetadata
- java.lang.Object
-
- org.apache.cassandra.utils.concurrent.SharedCloseableImpl
-
- org.apache.cassandra.utils.concurrent.WrappedSharedCloseable
-
- org.apache.cassandra.io.compress.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompressionMetadata.Chunk
Holds offset and length of the file chunkstatic class
CompressionMetadata.Writer
-
Field Summary
Fields Modifier and Type Field Description File
chunksIndexFile
long
compressedFileLength
long
dataLength
CompressionParams
parameters
-
Constructor Summary
Constructors Constructor Description CompressionMetadata(File chunksIndexFile, CompressionParams parameters, Memory chunkOffsets, long chunkOffsetsSize, long dataLength, long compressedFileLength)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTo(Ref.IdentityCollection identities)
CompressionMetadata.Chunk
chunkFor(long position)
Get a chunk of compressed data (offset, length) corresponding to given positionint
chunkLength()
ICompressor
compressor()
CompressionMetadata.Chunk[]
getChunksForSections(java.util.Collection<SSTableReader.PartitionPositionBounds> sections)
long
getDataOffsetForChunkOffset(long chunkOffset)
long
getTotalSizeForSections(java.util.Collection<SSTableReader.PartitionPositionBounds> sections)
int
maxCompressedLength()
long
offHeapSize()
Returns the amount of memory in bytes used off heap.static CompressionMetadata
open(File chunksIndexFile, long compressedLength, boolean hasMaxCompressedSize)
CompressionMetadata
sharedCopy()
-
Methods inherited from class org.apache.cassandra.utils.concurrent.SharedCloseableImpl
close, close, isCleanedUp
-
-
-
-
Field Detail
-
dataLength
public final long dataLength
-
compressedFileLength
public final long compressedFileLength
-
chunksIndexFile
public final File chunksIndexFile
-
parameters
public final CompressionParams parameters
-
-
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)
-
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 interfaceSharedCloseable
- Overrides:
addTo
in classSharedCloseableImpl
-
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
-
-