Class BlockfileRow
java.lang.Object
io.datarouter.bytes.blockfile.row.BlockfileRow
A generic KeyValue, plus a version represented as bytes. Entries are compared by key+version.
Empty fields:
- A key is generally required for any useful workload.
- The version can be an empty byte[] if keys are unique.
- The value can be an empty byte[] if all information is contained in the key.
The bytes are interpreted lexicographically using Arrays::compareUnsigned.
Many of these can be written to an OutputStream to be persisted for backup or further processing.
Encodes KvFileEntry objects to bytes using the format:
- varInt: total length of the all following fields
- the total length is redundant, but can help split the InputStream faster for passing decoding to other threads
- it can also help identify corruption, if the lengths don't add up
- varInt: keyLength
- bytes: key
- varInt: versionLength
- bytes: version
- byte: opType
- varInt: valueLength
- bytes: value
-
Constructor Summary
ConstructorsConstructorDescriptionBlockfileRow(byte[] bytes, int offset, int length, int keyOffset, int keyLength, int versionOffset, int versionLength, BlockfileRowOp op, int valueOffset, int valueLength) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]static intcompareKey(BlockfileRow left, BlockfileRow right) static intcompareKeyVersionOpOptimized(BlockfileRow left, BlockfileRow right) intcompareToKey(byte[] otherKey) static intcompareVersion(BlockfileRow left, BlockfileRow right) byte[]byte[]byte[]byte[]static BlockfileRowcreate(byte[] key, byte[] version, BlockfileRowOp op, byte[] value) static BlockfileRowdelete(byte[] key, byte[] version) booleanbooleanequalsKey(byte[] otherKey) static booleanequalsKeyOptimized(BlockfileRow left, BlockfileRow right) static booleanequalsVersion(BlockfileRow left, BlockfileRow right) inthashCode()intintintlength()intoffset()op()static BlockfileRowputWithLongVersion(byte[] key, long version, byte[] value) static BlockfileRowputWithoutVersion(byte[] key, byte[] value) toString()static inttotalLength(List<BlockfileRow> rows) intintintint
-
Constructor Details
-
BlockfileRow
public BlockfileRow(byte[] bytes, int offset, int length, int keyOffset, int keyLength, int versionOffset, int versionLength, BlockfileRowOp op, int valueOffset, int valueLength)
-
-
Method Details
-
create
-
delete
-
putWithoutVersion
-
putWithLongVersion
-
equalsKey
public boolean equalsKey(byte[] otherKey) -
equalsKeyOptimized
-
equalsVersion
-
equals
-
hashCode
-
toString
-
compareToKey
public int compareToKey(byte[] otherKey) -
compareKey
-
compareVersion
-
compareKeyVersionOpOptimized
-
toRowVersion
-
totalLength
-
backingBytes
public byte[] backingBytes() -
copyOfBytes
public byte[] copyOfBytes() -
offset
public int offset() -
length
public int length() -
keyOffset
public int keyOffset() -
keyLength
public int keyLength() -
copyOfKey
public byte[] copyOfKey() -
versionOffset
public int versionOffset() -
versionLength
public int versionLength() -
copyOfVersion
public byte[] copyOfVersion() -
op
-
valueOffset
public int valueOffset() -
valueLength
public int valueLength() -
copyOfValue
public byte[] copyOfValue()
-