Package com.illumon.iris.binarystore
Class BinaryStoreUtils
java.lang.Object
com.illumon.iris.binarystore.BinaryStoreUtils
public class BinaryStoreUtils extends Object
Container class for utility functions related to binary stores.
-
Constructor Summary
Constructors Constructor Description BinaryStoreUtils()
-
Method Summary
Modifier and Type Method Description static void
adlerUpdateInt(Adler32 adler32, int value)
Adler32 doesn't have a nice way to add an int.static void
adlerUpdateIntAndByte(Adler32 adler32, int intValue, byte byteValue)
Adler32 doesn't have a nice way to add an int.static ByteBuffer
appendAdler(ByteBuffer theBuffer)
Calculate the Adler32 checksum on the buffer, from beginning to current position, and append it.static ByteBuffer
appendAdler(ByteBuffer theBuffer, int startingPosition)
Compute the Adler checksum of the buffer from the given position to the current position and add it to the buffer.static int
computeAdler(ByteBuffer theBuffer)
Compute the Adler32 checksum of the given buffer.static int
computeAdler(ByteBuffer originalBuffer, int startingPosition)
Compute the Adler32 checksum of the buffer from startingPosition to current position.static byte[]
getTemporaryDataArray(byte[] currentArray, int requiredLength)
Get the current array or a newly-allocated array large enough to accommodate the required length.
-
Constructor Details
-
BinaryStoreUtils
public BinaryStoreUtils()
-
-
Method Details
-
computeAdler
Compute the Adler32 checksum of the given buffer. The buffer should be in read mode, and this operation consumes the buffer.- Parameters:
theBuffer
- Compute the checksum of this buffer from position to limit.- Returns:
- The Adler32 checksum of the consumed buffer.
-
appendAdler
Calculate the Adler32 checksum on the buffer, from beginning to current position, and append it. The buffer will have its position advanced by 32 bits and will remain in write mode.- Parameters:
theBuffer
- Operate on this buffer.- Returns:
- The buffer, for chaining.
-
computeAdler
Compute the Adler32 checksum of the buffer from startingPosition to current position. The buffer should be in write mode and will not be changed.- Parameters:
originalBuffer
- Compute the checksum on this buffer.startingPosition
- Calculate the checksum from this position to the buffer's current position.- Returns:
- The Adler32 checksum of the buffer from startingPosition to current position.
-
appendAdler
Compute the Adler checksum of the buffer from the given position to the current position and add it to the buffer. The buffer will have its position advanced by 32 bits and will remain in write mode.- Parameters:
theBuffer
- Operate on this buffer.startingPosition
- Starting position for the checksum calculation.- Returns:
- The buffer, for chaining.
-
adlerUpdateInt
Adler32 doesn't have a nice way to add an int.- Parameters:
adler32
- the Adler32 instance to append an int to.value
- the int to add to the Adler32.
-
adlerUpdateIntAndByte
Adler32 doesn't have a nice way to add an int.- Parameters:
adler32
- the Adler32 instance to append an int to.intValue
- the int to add to the Adler32.byteValue
- the byte to add to the Adler32.
-
getTemporaryDataArray
public static byte[] getTemporaryDataArray(byte[] currentArray, int requiredLength)Get the current array or a newly-allocated array large enough to accommodate the required length.- Parameters:
currentArray
- The current array, or null if there is nonerequiredLength
- The minimum length of the returned array- Returns:
- An array large enough to accommodate the required length
-