Package org.eclipse.jgit.notes
Class FanoutBucket
java.lang.Object
org.eclipse.jgit.notes.NoteBucket
org.eclipse.jgit.notes.InMemoryNoteBucket
org.eclipse.jgit.notes.FanoutBucket
A note tree holding only note subtrees, each named using a 2 digit hex name.
The fanout buckets/trees contain on average 256 subtrees, naming the subtrees
by a slice of the ObjectId contained within them, from "00" through "ff".
Each fanout bucket has a
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.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intNumber of non-null slots intable.private static final byte[]private final NoteBucket[]Fan-out table similar to the PackIndex structure.Fields inherited from class org.eclipse.jgit.notes.InMemoryNoteBucket
nonNotes, prefixLen -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) InMemoryNoteBucketprivate TreeFormatterbuild(boolean insert, ObjectInserter inserter) private intcell(AnyObjectId id) (package private) InMemoryNoteBucketcontractIfTooSmall(AnyObjectId noteOn, ObjectReader or) (package private) intestimateSize(AnyObjectId noteOn, ObjectReader or) (package private) NoteBucketgetBucket(int cell) (package private) NotegetNote(AnyObjectId objId, ObjectReader or) (package private) ObjectIditerator(AnyObjectId objId, ObjectReader reader) (package private) static InMemoryNoteBucketloadIfLazy(NoteBucket b, AnyObjectId prefix, ObjectReader or) (package private) InMemoryNoteBucketset(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) (package private) void(package private) voidsetBucket(int cell, InMemoryNoteBucket bucket) private inttreeSize()(package private) ObjectIdwriteTree(ObjectInserter inserter)
-
Field Details
-
table
Fan-out table similar to the PackIndex structure. Notes for an object are stored within the sub-bucket that is held here astable[ objectId.getByte( prefixLen / 2 ) ]. If the slot is null there are no notes with that prefix. -
cnt
private int cntNumber of non-null slots intable. -
hexchar
private static final byte[] hexchar
-
-
Constructor Details
-
FanoutBucket
FanoutBucket(int prefixLen)
-
-
Method Details
-
setBucket
-
setBucket
-
getNote
- Specified by:
getNotein classNoteBucket- Throws:
IOException
-
getBucket
-
loadIfLazy
static InMemoryNoteBucket loadIfLazy(NoteBucket b, AnyObjectId prefix, ObjectReader or) throws IOException - Throws:
IOException
-
iterator
- Specified by:
iteratorin classNoteBucket- Throws:
IOException
-
estimateSize
- Specified by:
estimateSizein classNoteBucket- Throws:
IOException
-
set
InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws IOException - Specified by:
setin classNoteBucket- Throws:
IOException
-
contractIfTooSmall
- Throws:
IOException
-
writeTree
- Specified by:
writeTreein classNoteBucket- Throws:
IOException
-
getTreeId
ObjectId getTreeId()- Specified by:
getTreeIdin classNoteBucket
-
build
- Throws:
IOException
-
treeSize
private int treeSize() -
append
- Specified by:
appendin classInMemoryNoteBucket
-
cell
-