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.prefixLenthat 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 classFanoutBucket.LazyNoteBucket
-
Field Summary
Fields Modifier and Type Field Description private intcntNumber of non-null slots intable.private static byte[]hexcharprivate NoteBucket[]tableFan-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) InMemoryNoteBucketappend(Note note)private 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) ObjectIdgetTreeId()(package private) java.util.Iterator<Note>iterator(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) voidsetBucket(int cell, ObjectId id)(package private) voidsetBucket(int cell, InMemoryNoteBucket bucket)private inttreeSize()(package private) ObjectIdwriteTree(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:
getNotein 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:
iteratorin classNoteBucket- Throws:
java.io.IOException
-
estimateSize
int estimateSize(AnyObjectId noteOn, ObjectReader or) throws java.io.IOException
- Specified by:
estimateSizein classNoteBucket- Throws:
java.io.IOException
-
set
InMemoryNoteBucket set(AnyObjectId noteOn, AnyObjectId noteData, ObjectReader or) throws java.io.IOException
- Specified by:
setin 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:
writeTreein classNoteBucket- Throws:
java.io.IOException
-
getTreeId
ObjectId getTreeId()
- Specified by:
getTreeIdin 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:
appendin classInMemoryNoteBucket
-
cell
private int cell(AnyObjectId id)
-
-