Package org.apache.arrow.memory.util
Class ByteFunctionHelpers
java.lang.Object
org.apache.arrow.memory.util.ByteFunctionHelpers
Utility methods for memory comparison at a byte level.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
combineHash
(int currentHash, int newHash) Generate a new hashCode with the given current hashCode and new hashCode.static int
Helper function to compare a set of bytes in ArrowBuf to a ByteArray.static int
Helper function to compare a set of bytes in two ArrowBufs.static int
Helper function to check for equality of bytes in two ArrowBufs.static int
Compute hashCode with the givenArrowBuf
and start/end index.static final int
hash
(ArrowBufHasher hasher, ArrowBuf buf, long start, long end) Compute hashCode with the givenArrowBufHasher
,ArrowBuf
and start/end index.static int
unsignedIntCompare
(int a, int b) static int
unsignedLongCompare
(long a, long b) Compares the two specifiedlong
values, treating them as unsigned values between0
and2^64 - 1
inclusive.
-
Method Details
-
equal
public static int equal(ArrowBuf left, long lStart, long lEnd, ArrowBuf right, long rStart, long rEnd) Helper function to check for equality of bytes in two ArrowBufs.- Parameters:
left
- Left ArrowBuf for comparisonlStart
- start offset in the bufferlEnd
- end offset in the bufferright
- Right ArrowBuf for comparisonrStart
- start offset in the bufferrEnd
- end offset in the buffer- Returns:
- 1 if equals, 0 otherwise
-
compare
public static int compare(ArrowBuf left, long lStart, long lEnd, ArrowBuf right, long rStart, long rEnd) Helper function to compare a set of bytes in two ArrowBufs.Function will check data before completing in the case that
- Parameters:
left
- Left ArrowBuf to comparelStart
- start offset in the bufferlEnd
- end offset in the bufferright
- Right ArrowBuf to comparerStart
- start offset in the bufferrEnd
- end offset in the buffer- Returns:
- 1 if left input is greater, -1 if left input is smaller, 0 otherwise
-
compare
Helper function to compare a set of bytes in ArrowBuf to a ByteArray.- Parameters:
left
- Left ArrowBuf for comparison purposeslStart
- start offset in the bufferlEnd
- end offset in the bufferright
- second input to be comparedrStart
- start offset in the byte arrayrEnd
- end offset in the byte array- Returns:
- 1 if left input is greater, -1 if left input is smaller, 0 otherwise
-
unsignedLongCompare
public static int unsignedLongCompare(long a, long b) Compares the two specifiedlong
values, treating them as unsigned values between0
and2^64 - 1
inclusive.- Parameters:
a
- the first unsignedlong
to compareb
- the second unsignedlong
to compare- Returns:
- a negative value if
a
is less thanb
; a positive value ifa
is greater thanb
; or zero if they are equal
-
unsignedIntCompare
public static int unsignedIntCompare(int a, int b) -
hash
Compute hashCode with the givenArrowBuf
and start/end index. -
hash
Compute hashCode with the givenArrowBufHasher
,ArrowBuf
and start/end index. -
combineHash
public static int combineHash(int currentHash, int newHash) Generate a new hashCode with the given current hashCode and new hashCode.
-