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
-
class FanoutBucket extends InMemoryNoteBucket
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 aInMemoryNoteBucket.prefixLen
that defines how many digits it skips in an ObjectId before it gets to the digits matchingtable
. The root tree hasprefixLen == 0
, and thus does not skip any digits. For ObjectId "c0ffee...", the note (if it exists) will be stored within the buckettable[0xc0]
. The first level tree hasprefixLen == 2
, and thus skips the first two digits. For the same example "c0ffee..." object, its note would be found within thetable[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 byNoteParser
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
FanoutBucket.LazyNoteBucket
-
Field Summary
Fields Modifier and Type Field Description private int
cnt
Number of non-null slots intable
.private static byte[]
hexchar
private NoteBucket[]
table
Fan-out table similar to the PackIndex structure.-
Fields inherited from class org.eclipse.jgit.notes.InMemoryNoteBucket
nonNotes, prefixLen
-
-
Constructor Summary
Constructors Constructor Description FanoutBucket(int prefixLen)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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, ObjectId id)
(package private) void
setBucket(int cell, InMemoryNoteBucket bucket)
private int
treeSize()
(package private) ObjectId
writeTree(ObjectInserter inserter)
-
-
-
Field Detail
-
table
private final NoteBucket[] 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 cnt
Number of non-null slots intable
.
-
hexchar
private static final byte[] hexchar
-
-
Method Detail
-
setBucket
void setBucket(int cell, ObjectId id)
-
setBucket
void setBucket(int cell, InMemoryNoteBucket bucket)
-
getNote
Note getNote(AnyObjectId objId, ObjectReader or) throws java.io.IOException
- Specified by:
getNote
in classNoteBucket
- Throws:
java.io.IOException
-
getBucket
NoteBucket getBucket(int cell)
-
loadIfLazy
static InMemoryNoteBucket loadIfLazy(NoteBucket b, AnyObjectId prefix, ObjectReader or) throws java.io.IOException
- Throws:
java.io.IOException
-
iterator
java.util.Iterator<Note> iterator(AnyObjectId objId, ObjectReader reader) throws java.io.IOException
- Specified by:
iterator
in classNoteBucket
- Throws:
java.io.IOException
-
estimateSize
int estimateSize(AnyObjectId noteOn, ObjectReader or) throws java.io.IOException
- Specified by:
estimateSize
in classNoteBucket
- Throws:
java.io.IOException
-
set
InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws java.io.IOException
- Specified by:
set
in classNoteBucket
- Throws:
java.io.IOException
-
contractIfTooSmall
InMemoryNoteBucket contractIfTooSmall(AnyObjectId noteOn, ObjectReader or) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTree
ObjectId writeTree(ObjectInserter inserter) throws java.io.IOException
- Specified by:
writeTree
in classNoteBucket
- Throws:
java.io.IOException
-
getTreeId
ObjectId getTreeId()
- Specified by:
getTreeId
in classNoteBucket
-
build
private TreeFormatter build(boolean insert, ObjectInserter inserter) throws java.io.IOException
- Throws:
java.io.IOException
-
treeSize
private int treeSize()
-
append
InMemoryNoteBucket append(Note note)
- Specified by:
append
in classInMemoryNoteBucket
-
cell
private int cell(AnyObjectId id)
-
-