Package org.apache.cassandra.io.util
Class FileHandle.Builder
- java.lang.Object
-
- org.apache.cassandra.io.util.FileHandle.Builder
-
- Enclosing class:
- FileHandle
public static class FileHandle.Builder extends java.lang.Object
Configures how the file will be read (compressed, mmapped, use cache etc.)
-
-
Field Summary
Fields Modifier and Type Field Description File
file
static long
NO_LENGTH_OVERRIDE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileHandle.Builder
bufferSize(int bufferSize)
Set the buffer size to use (if appropriate).FileHandle.Builder
bufferType(BufferType bufferType)
Set the buffer type (on heap or off heap) to use (if appropriate).FileHandle
complete()
Complete buildingFileHandle
.FileHandle
complete(java.util.function.Function<File,ChannelProxy> channelProxyFactory)
FileHandle.Builder
mmapped(boolean mmapped)
Set whether to use mmap for readingFileHandle.Builder
mmapped(Config.DiskAccessMode diskAccessMode)
FileHandle.Builder
withChunkCache(ChunkCache chunkCache)
SetChunkCache
to use.FileHandle.Builder
withCompressionMetadata(CompressionMetadata metadata)
ProvideCompressionMetadata
to use when reading compressed file.FileHandle.Builder
withCrcCheckChance(java.util.function.Supplier<java.lang.Double> crcCheckChanceSupplier)
FileHandle.Builder
withLengthOverride(long lengthOverride)
Override the file length.FileHandle.Builder
withMmappedRegionsCache(MmappedRegionsCache mmappedRegionsCache)
-
-
-
Field Detail
-
NO_LENGTH_OVERRIDE
public static final long NO_LENGTH_OVERRIDE
- See Also:
- Constant Field Values
-
file
public final File file
-
-
Constructor Detail
-
Builder
public Builder(File file)
-
-
Method Detail
-
withChunkCache
public FileHandle.Builder withChunkCache(ChunkCache chunkCache)
SetChunkCache
to use.- Parameters:
chunkCache
- ChunkCache object to use for caching- Returns:
- this object
-
withCompressionMetadata
public FileHandle.Builder withCompressionMetadata(CompressionMetadata metadata)
ProvideCompressionMetadata
to use when reading compressed file. Upon completion, builder will create a shared copy of this object and that copy will be used in the created instance ofFileHandle
. Therefore, the caller is responsible for closing the instance ofCompressionMetadata
passed to this method after builder completion.- Parameters:
metadata
- CompressionMetadata to use, can benull
if no compression is used- Returns:
- this object
-
withCrcCheckChance
public FileHandle.Builder withCrcCheckChance(java.util.function.Supplier<java.lang.Double> crcCheckChanceSupplier)
-
mmapped
public FileHandle.Builder mmapped(boolean mmapped)
Set whether to use mmap for reading- Parameters:
mmapped
- true if using mmap- Returns:
- this instance
-
mmapped
public FileHandle.Builder mmapped(Config.DiskAccessMode diskAccessMode)
-
withMmappedRegionsCache
public FileHandle.Builder withMmappedRegionsCache(MmappedRegionsCache mmappedRegionsCache)
-
bufferSize
public FileHandle.Builder bufferSize(int bufferSize)
Set the buffer size to use (if appropriate).- Parameters:
bufferSize
- Buffer size in bytes- Returns:
- this instance
-
bufferType
public FileHandle.Builder bufferType(BufferType bufferType)
Set the buffer type (on heap or off heap) to use (if appropriate).- Parameters:
bufferType
- Buffer type to use- Returns:
- this instance
-
withLengthOverride
public FileHandle.Builder withLengthOverride(long lengthOverride)
Override the file length.- Parameters:
lengthOverride
- Override file length (in bytes) so that read cannot go further than this value. If the value is less than or equal to 0, then the value is ignored.- Returns:
- Built file
-
complete
public FileHandle complete()
Complete buildingFileHandle
.
-
complete
public FileHandle complete(java.util.function.Function<File,ChannelProxy> channelProxyFactory)
-
-