abstract class BlockBasedFile
extends java.lang.Object
DfsBlockCache
.Modifier and Type | Class and Description |
---|---|
private static class |
BlockBasedFile.LazyChannel
A supplier of readable channel that opens the channel lazily.
|
Modifier and Type | Field and Description |
---|---|
(package private) int |
blockSize
Preferred alignment for loading blocks from the backing file.
|
(package private) DfsBlockCache |
cache
Cache that owns this file and its data.
|
(package private) DfsPackDescription |
desc
Description of the associated pack file's storage.
|
(package private) PackExt |
ext |
(package private) boolean |
invalid
True once corruption has been detected that cannot be worked around.
|
protected java.lang.Exception |
invalidatingCause
Exception that caused the packfile to be flagged as invalid
|
(package private) DfsStreamKey |
key
Unique identity of this file while in-memory.
|
(package private) long |
length
Total number of bytes in this pack file.
|
Constructor and Description |
---|
BlockBasedFile(DfsBlockCache cache,
DfsPackDescription desc,
PackExt ext) |
Modifier and Type | Method and Description |
---|---|
(package private) long |
alignToBlock(long pos) |
(package private) int |
blockSize(ReadableChannel rc) |
(package private) static long |
elapsedMicros(long start) |
(package private) java.lang.String |
getFileName() |
(package private) DfsBlock |
getOrLoadBlock(long pos,
DfsReader ctx) |
(package private) boolean |
invalid() |
(package private) static int |
read(ReadableChannel rc,
java.nio.ByteBuffer buf) |
(package private) DfsBlock |
readOneBlock(long pos,
DfsReader ctx,
ReadableChannel rc) |
(package private) void |
setBlockSize(int newSize) |
(package private) void |
setInvalid() |
final DfsBlockCache cache
final DfsStreamKey key
final DfsPackDescription desc
final PackExt ext
volatile int blockSize
It is initialized to 0 and filled in on the first read made from the file. Block sizes may be odd, e.g. 4091, caused by the underling DFS storing 4091 user bytes and 5 bytes block metadata into a lower level 4096 byte block on disk.
volatile long length
This field initializes to -1 and gets populated when a block is loaded.
volatile boolean invalid
protected volatile java.lang.Exception invalidatingCause
BlockBasedFile(DfsBlockCache cache, DfsPackDescription desc, PackExt ext)
java.lang.String getFileName()
boolean invalid()
void setInvalid()
void setBlockSize(int newSize)
long alignToBlock(long pos)
int blockSize(ReadableChannel rc)
DfsBlock getOrLoadBlock(long pos, DfsReader ctx) throws java.io.IOException
java.io.IOException
DfsBlock readOneBlock(long pos, DfsReader ctx, ReadableChannel rc) throws java.io.IOException
java.io.IOException
static int read(ReadableChannel rc, java.nio.ByteBuffer buf) throws java.io.IOException
java.io.IOException
static long elapsedMicros(long start)