- All Known Implementing Classes:
PackBitmapIndexBuilder,PackBitmapIndexRemapper
public interface PackBitmapIndex
Logical representation of the bitmap data stored in the pack index.
ObjectIds are encoded as a single integer in the
range [0, getObjectCount()). Compressed bitmaps are available at
certain ObjectIds, which represent all of the objects reachable from
that ObjectId (include the ObjectId itself). The meaning of
the positions in the bitmaps can be decoded using getObject(int) and
ofObjectType(EWAHCompressedBitmap, int). Furthermore,
findPosition(AnyObjectId) can be used to build other bitmaps that a
compatible with the encoded bitmaps available from the index.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSupplier that propagates IOException. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFlag bit denoting the bitmap should be reused during index creation. -
Method Summary
Modifier and TypeMethodDescriptionintfindPosition(AnyObjectId objectId) Finds the position in the bitmap of the object.intReturns the number of bitmaps in this bitmap index ready to use, not XOR'ed against other entries.longCurrent size in bytes of all base bitmaps in the index.com.googlecode.javaewah.EWAHCompressedBitmapgetBitmap(AnyObjectId objectId) Returns the previously constructed bitmap for the object.intReturns the number of bitmaps in this bitmap index.getObject(int position) Get the object at the bitmap position.intObtain the total number of objects described by this index.default byte[]Footer checksum applied on the bottom of the pack file.intReturns the number of bitmaps in this bitmap index XOR'ed against other entries.longCurrent size in bytes of all XOR'ed bitmaps in the index.com.googlecode.javaewah.EWAHCompressedBitmapofObjectType(com.googlecode.javaewah.EWAHCompressedBitmap bitmap, int type) Returns a bitmap containing positions for objects that have the given Git type.static PackBitmapIndexopen(File idxFile, PackIndex packIndex, PackReverseIndex reverseIndex) Read an existing pack bitmap index file from a buffered stream.static PackBitmapIndexread(InputStream fd, PackBitmapIndex.SupplierWithIOException<PackIndex> packIndexSupplier, PackBitmapIndex.SupplierWithIOException<PackReverseIndex> reverseIndexSupplier, boolean loadParallelRevIndex) Read an existing pack bitmap index file from a buffered stream.static PackBitmapIndexread(InputStream fd, PackIndex packIndex, PackReverseIndex reverseIndex) Read an existing pack bitmap index file from a buffered stream.
-
Field Details
-
FLAG_REUSE
static final int FLAG_REUSEFlag bit denoting the bitmap should be reused during index creation.- See Also:
-
-
Method Details
-
open
static PackBitmapIndex open(File idxFile, PackIndex packIndex, PackReverseIndex reverseIndex) throws IOException Read an existing pack bitmap index file from a buffered stream.The format of the file will be automatically detected and a proper access implementation for that format will be constructed and returned to the caller. The file may or may not be held open by the returned instance.
- Parameters:
idxFile- existing pack .bitmap to read.packIndex- the pack index for the corresponding pack file.reverseIndex- the pack reverse index for the corresponding pack file.- Returns:
- a copy of the index in-memory.
- Throws:
IOException- the stream cannot be read.CorruptObjectException- the stream does not contain a valid pack bitmap index.
-
read
static PackBitmapIndex read(InputStream fd, PackIndex packIndex, PackReverseIndex reverseIndex) throws IOException Read an existing pack bitmap index file from a buffered stream.The format of the file will be automatically detected and a proper access implementation for that format will be constructed and returned to the caller. The file may or may not be held open by the returned instance.
- Parameters:
fd- stream to read the bitmap index file from. The stream must be buffered as some small IOs are performed against the stream. The caller is responsible for closing the stream.packIndex- the pack index for the corresponding pack file.reverseIndex- the pack reverse index for the corresponding pack file.- Returns:
- a copy of the index in-memory.
- Throws:
IOException- the stream cannot be read.CorruptObjectException- the stream does not contain a valid pack bitmap index.
-
read
static PackBitmapIndex read(InputStream fd, PackBitmapIndex.SupplierWithIOException<PackIndex> packIndexSupplier, PackBitmapIndex.SupplierWithIOException<PackReverseIndex> reverseIndexSupplier, boolean loadParallelRevIndex) throws IOException Read an existing pack bitmap index file from a buffered stream.The format of the file will be automatically detected and a proper access implementation for that format will be constructed and returned to the caller. The file may or may not be held open by the returned instance.
- Parameters:
fd- stream to read the bitmap index file from. The stream must be buffered as some small IOs are performed against the stream. The caller is responsible for closing the stream.packIndexSupplier- the supplier for pack index for the corresponding pack file.reverseIndexSupplier- the supplier for pack reverse index for the corresponding pack file.loadParallelRevIndex- whether reverse index should be loaded in parallel- Returns:
- a copy of the index in-memory.
- Throws:
IOException- the stream cannot be read.CorruptObjectException- the stream does not contain a valid pack bitmap index.
-
getPackChecksum
default byte[] getPackChecksum()Footer checksum applied on the bottom of the pack file.- Returns:
- checksum as a byte array
-
findPosition
Finds the position in the bitmap of the object.- Parameters:
objectId- the id for which the bitmap position will be found.- Returns:
- the bitmap id or -1 if the object was not found.
-
getObject
Get the object at the bitmap position.- Parameters:
position- the offset in the bitmap which corresponds to an object of interest. This position is the same as the order of the object in thePackFile.- Returns:
- the ObjectId.
- Throws:
IllegalArgumentException- when the item is not found.
-
ofObjectType
com.googlecode.javaewah.EWAHCompressedBitmap ofObjectType(com.googlecode.javaewah.EWAHCompressedBitmap bitmap, int type) Returns a bitmap containing positions for objects that have the given Git type.- Parameters:
bitmap- the object bitmap.type- the Git type.- Returns:
- the object bitmap with only objects of the Git type.
-
getBitmap
Returns the previously constructed bitmap for the object.- Parameters:
objectId- the id for which the bitmap will be found.- Returns:
- the bitmap or null if the object was not found.
-
getObjectCount
int getObjectCount()Obtain the total number of objects described by this index.getObjectCount() - 1is the largest bit that will be set in a bitmap.- Returns:
- number of objects in this index, and likewise in the associated pack that this index was generated from.
-
getBitmapCount
int getBitmapCount()Returns the number of bitmaps in this bitmap index.- Returns:
- the number of bitmaps in this bitmap index.
-
getBaseBitmapCount
int getBaseBitmapCount()Returns the number of bitmaps in this bitmap index ready to use, not XOR'ed against other entries.- Returns:
- the number of bitmaps in this bitmap index ready to use.
-
getBaseBitmapSizeInBytes
long getBaseBitmapSizeInBytes()Current size in bytes of all base bitmaps in the index. Resolving xors for bitmaps can affect this size.- Returns:
- Current size (in bytes) of all base bitmaps in this index.
-
getXorBitmapCount
int getXorBitmapCount()Returns the number of bitmaps in this bitmap index XOR'ed against other entries.- Returns:
- the number of bitmaps in this bitmap index represented as XOR masks.
-
getXorBitmapSizeInBytes
long getXorBitmapSizeInBytes()Current size in bytes of all XOR'ed bitmaps in the index. Resolving xors for bitmaps can affect this size.- Returns:
- Current size (in bytes) of all xor bitmaps in this index.
-