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 int
Number 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) InMemoryNoteBucket
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
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
(package private) void
setBucket
(int cell, InMemoryNoteBucket bucket) private int
treeSize()
(package private) ObjectId
writeTree
(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:
getNote
in classNoteBucket
- Throws:
IOException
-
getBucket
-
loadIfLazy
static InMemoryNoteBucket loadIfLazy(NoteBucket b, AnyObjectId prefix, ObjectReader or) throws IOException - Throws:
IOException
-
iterator
- Specified by:
iterator
in classNoteBucket
- Throws:
IOException
-
estimateSize
- Specified by:
estimateSize
in classNoteBucket
- Throws:
IOException
-
set
InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws IOException - Specified by:
set
in classNoteBucket
- Throws:
IOException
-
contractIfTooSmall
- Throws:
IOException
-
writeTree
- Specified by:
writeTree
in classNoteBucket
- Throws:
IOException
-
getTreeId
ObjectId getTreeId()- Specified by:
getTreeId
in classNoteBucket
-
build
- Throws:
IOException
-
treeSize
private int treeSize() -
append
- Specified by:
append
in classInMemoryNoteBucket
-
cell
-