public class FileHandle extends SharedCloseableImpl
FileHandle
provides access to a file for reading, including the ones written by various SequentialWriter
instances, and it is typically used by SSTableReader
.
Use FileHandle.Builder
to create an instance, and call createReader()
(and its variants) to
access the readers for the underlying file.
You can use FileHandle.Builder.complete()
several times during its lifecycle with different overrideLength
(i.e. early opening file).
For that reason, the builder keeps a reference to the file channel and makes a copy for each FileHandle.Builder.complete()
call.
Therefore, it is important to close the FileHandle.Builder
when it is no longer needed, as well as any FileHandle
instances.Modifier and Type | Class and Description |
---|---|
static class |
FileHandle.Builder
Configures how the file will be read (compressed, mmapped, use cache etc.)
|
Modifier and Type | Field and Description |
---|---|
ChannelProxy |
channel |
long |
onDiskLength |
Modifier and Type | Method and Description |
---|---|
void |
addTo(Ref.IdentityCollection identities) |
java.util.Optional<CompressionMetadata> |
compressionMetadata() |
RandomAccessReader |
createReader()
Create
RandomAccessReader with configured method of reading content of the file. |
FileDataInput |
createReader(long position) |
RandomAccessReader |
createReader(com.google.common.util.concurrent.RateLimiter limiter)
Create
RandomAccessReader with configured method of reading content of the file. |
long |
dataLength() |
void |
dropPageCache(long before)
Drop page cache from start to given
before . |
java.lang.String |
path() |
RebuffererFactory |
rebuffererFactory() |
FileHandle |
sharedCopy() |
java.lang.String |
toString() |
close, close, isCleanedUp
public final ChannelProxy channel
public final long onDiskLength
public java.lang.String path()
public long dataLength()
public RebuffererFactory rebuffererFactory()
public java.util.Optional<CompressionMetadata> compressionMetadata()
public void addTo(Ref.IdentityCollection identities)
addTo
in interface SharedCloseable
addTo
in class SharedCloseableImpl
public FileHandle sharedCopy()
public RandomAccessReader createReader()
RandomAccessReader
with configured method of reading content of the file.public RandomAccessReader createReader(com.google.common.util.concurrent.RateLimiter limiter)
RandomAccessReader
with configured method of reading content of the file.
Reading from file will be rate limited by given RateLimiter
.limiter
- RateLimiter to use for rate limiting readpublic FileDataInput createReader(long position)
public void dropPageCache(long before)
before
.before
- uncompressed position from start of the file to be dropped from cache. if 0, to end of file.public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2009-2022 The Apache Software Foundation