class FanoutBucket extends InMemoryNoteBucket
InMemoryNoteBucket.prefixLen that defines how many digits it
skips in an ObjectId before it gets to the digits matching table.
The root tree has prefixLen == 0, and thus does not skip any digits.
For ObjectId "c0ffee...", the note (if it exists) will be stored within the
bucket table[0xc0].
The first level tree has prefixLen == 2, and thus skips the first two
digits. For the same example "c0ffee..." object, its note would be found
within the table[0xff] bucket (as first 2 digits "c0" are skipped).
Each subtree is loaded on-demand, reducing startup latency for reads that
only need to examine a few objects. However, due to the rather uniform
distribution of the SHA-1 hash that is used for ObjectIds, accessing 256
objects is very likely to load all of the subtrees into memory.
A FanoutBucket must be parsed from a tree object by NoteParser.| Modifier and Type | Class and Description |
|---|---|
private class |
FanoutBucket.LazyNoteBucket |
| Modifier and Type | Field and Description |
|---|---|
private int |
cnt
Number of non-null slots in
table. |
private static byte[] |
hexchar |
private NoteBucket[] |
table
Fan-out table similar to the PackIndex structure.
|
nonNotes, prefixLen| Constructor and Description |
|---|
FanoutBucket(int prefixLen) |
| Modifier and Type | Method and Description |
|---|---|
(package private) InMemoryNoteBucket |
append(Note note) |
private TreeFormatter |
build(boolean insert,
ObjectInserter inserter) |
private int |
cell(AnyObjectId id) |
(package private) InMemoryNoteBucket |
contractIfTooSmall(AnyObjectId noteOn,
ObjectReader or) |
(package private) int |
estimateSize(AnyObjectId noteOn,
ObjectReader or) |
(package private) NoteBucket |
getBucket(int cell) |
(package private) Note |
getNote(AnyObjectId objId,
ObjectReader or) |
(package private) ObjectId |
getTreeId() |
(package private) java.util.Iterator<Note> |
iterator(AnyObjectId objId,
ObjectReader reader) |
(package private) static InMemoryNoteBucket |
loadIfLazy(NoteBucket b,
AnyObjectId prefix,
ObjectReader or) |
(package private) InMemoryNoteBucket |
set(AnyObjectId noteOn,
AnyObjectId noteData,
ObjectReader or) |
(package private) void |
setBucket(int cell,
InMemoryNoteBucket bucket) |
(package private) void |
setBucket(int cell,
ObjectId id) |
private int |
treeSize() |
(package private) ObjectId |
writeTree(ObjectInserter inserter) |
private final NoteBucket[] table
table[ objectId.getByte( prefixLen / 2 ) ]. If the slot is null
there are no notes with that prefix.private int cnt
table.private static final byte[] hexchar
void setBucket(int cell,
ObjectId id)
void setBucket(int cell,
InMemoryNoteBucket bucket)
Note getNote(AnyObjectId objId, ObjectReader or) throws java.io.IOException
getNote in class NoteBucketjava.io.IOExceptionNoteBucket getBucket(int cell)
static InMemoryNoteBucket loadIfLazy(NoteBucket b, AnyObjectId prefix, ObjectReader or) throws java.io.IOException
java.io.IOExceptionjava.util.Iterator<Note> iterator(AnyObjectId objId, ObjectReader reader) throws java.io.IOException
iterator in class NoteBucketjava.io.IOExceptionint estimateSize(AnyObjectId noteOn, ObjectReader or) throws java.io.IOException
estimateSize in class NoteBucketjava.io.IOExceptionInMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws java.io.IOException
set in class NoteBucketjava.io.IOExceptionInMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or) throws java.io.IOException
java.io.IOExceptionObjectId writeTree(ObjectInserter inserter) throws java.io.IOException
writeTree in class NoteBucketjava.io.IOExceptionObjectId getTreeId()
getTreeId in class NoteBucketprivate TreeFormatter build(boolean insert, ObjectInserter inserter) throws java.io.IOException
java.io.IOExceptionprivate int treeSize()
InMemoryNoteBucket append(Note note)
append in class InMemoryNoteBucketprivate int cell(AnyObjectId id)