Class BlockReader
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftable.BlockReader
-
class BlockReader extends java.lang.ObjectReads a single block forReftableReader. Instances are tied to a specific block in the file so are not reused for other blocks. Instances hold an offset into the block.
-
-
Field Summary
Fields Modifier and Type Field Description private byteblockTypeprivate byte[]bufprivate intbufLenprivate longendPositionprivate intkeysEndprivate intkeysStartprivate byte[]nameBufprivate intnameLenprivate intptrprivate intrestartCntprivate intrestartTblprivate booleantruncatedprivate intvalueType
-
Constructor Summary
Constructors Constructor Description BlockReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static intdecodeBlockLen(int typeAndSize)(package private) longendPosition()private longinflateBuf(BlockSource src, long pos, int blockLen, int fileBlockSize)private static java.io.IOExceptioninvalidBlock()private static java.io.IOExceptioninvalidBlock(java.lang.Throwable cause)(package private) booleanmatch(byte[] match, boolean matchIsPrefix)(package private) java.lang.Stringname()private static RefnewRef(java.lang.String name, long updateIndex)(package private) booleannext()private voidparseBlockStart(BlockSource src, long pos, int fileBlockSize)(package private) voidparseKey()(package private) voidreadBlock(BlockSource src, long pos, int fileBlockSize)private voidreadBlockIntoBuf(BlockSource src, long pos, int size)(package private) LongListreadBlockPositionList()private shortreadInt16()(package private) ReflogEntryreadLogEntry()(package private) longreadLogUpdateIndex()private PersonIdentreadPersonIdent()(package private) longreadPositionFromIndex()(package private) RefreadRef(long minUpdateIndex)(package private) longreadUpdateIndexDelta()private ObjectIdreadValueId()private java.lang.StringreadValueString()private intreadVarint32()private longreadVarint64()private intscanToKey(byte[] key, int rPtr, int rIdx, int rCmp)Performs the linear search step within a restart interval.(package private) intseekKey(byte[] key)Finds a key in the block and positions the current pointer on its record.private voidsetupEmptyFileBlock()private voidskipString()(package private) voidskipValue()(package private) booleantruncated()(package private) bytetype()(package private) voidverifyIndex()
-
-
-
Field Detail
-
blockType
private byte blockType
-
endPosition
private long endPosition
-
truncated
private boolean truncated
-
buf
private byte[] buf
-
bufLen
private int bufLen
-
ptr
private int ptr
-
keysStart
private int keysStart
-
keysEnd
private int keysEnd
-
restartCnt
private int restartCnt
-
restartTbl
private int restartTbl
-
nameBuf
private byte[] nameBuf
-
nameLen
private int nameLen
-
valueType
private int valueType
-
-
Method Detail
-
type
byte type()
-
truncated
boolean truncated()
-
endPosition
long endPosition()
-
next
boolean next()
-
parseKey
void parseKey()
-
name
java.lang.String name()
-
match
boolean match(byte[] match, boolean matchIsPrefix)
-
readPositionFromIndex
long readPositionFromIndex() throws java.io.IOException- Throws:
java.io.IOException
-
readUpdateIndexDelta
long readUpdateIndexDelta()
-
readRef
Ref readRef(long minUpdateIndex) throws java.io.IOException
- Throws:
java.io.IOException
-
readLogUpdateIndex
long readLogUpdateIndex()
-
readLogEntry
@Nullable ReflogEntry readLogEntry()
-
readValueId
private ObjectId readValueId()
-
readValueString
private java.lang.String readValueString()
-
readPersonIdent
private PersonIdent readPersonIdent()
-
readBlock
void readBlock(BlockSource src, long pos, int fileBlockSize) throws java.io.IOException
- Throws:
java.io.IOException
-
readBlockIntoBuf
private void readBlockIntoBuf(BlockSource src, long pos, int size) throws java.io.IOException
- Throws:
java.io.IOException
-
parseBlockStart
private void parseBlockStart(BlockSource src, long pos, int fileBlockSize) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeBlockLen
static int decodeBlockLen(int typeAndSize)
-
inflateBuf
private long inflateBuf(BlockSource src, long pos, int blockLen, int fileBlockSize) throws java.io.IOException
- Throws:
java.io.IOException
-
setupEmptyFileBlock
private void setupEmptyFileBlock()
-
verifyIndex
void verifyIndex() throws java.io.IOException- Throws:
java.io.IOException
-
seekKey
int seekKey(byte[] key)
Finds a key in the block and positions the current pointer on its record.As a side-effect this method arranges for the current pointer to be near or exactly on
key, allowing other methods to access data from that current record:- Parameters:
key- key to find.- Returns:
<0if the key occurs before the start of this block;0if the block is positioned on the key;>0if the key occurs after the last key of this block.
-
scanToKey
private int scanToKey(byte[] key, int rPtr, int rIdx, int rCmp)Performs the linear search step within a restart interval.Starts at a restart position whose key sorts before (or equal to)
keyand walks sequentially through the following prefix compressed records to findkey.- Parameters:
key- key the caller wants to find.rPtr- current record pointer from restart table binary search.rIdx- current restart table index.rCmp- result of compare from restart table binary search.- Returns:
<0if the key occurs before the start of this block;0if the block is positioned on the key;>0if the key occurs after the last key of this block.
-
skipValue
void skipValue()
-
skipString
private void skipString()
-
readInt16
private short readInt16()
-
readVarint32
private int readVarint32()
-
readVarint64
private long readVarint64()
-
newRef
private static Ref newRef(java.lang.String name, long updateIndex)
-
invalidBlock
private static java.io.IOException invalidBlock()
-
invalidBlock
private static java.io.IOException invalidBlock(java.lang.Throwable cause)
-
-