Package org.apache.pinot.spi.utils
Class ByteArray
- java.lang.Object
-
- org.apache.pinot.spi.utils.ByteArray
-
- All Implemented Interfaces:
Serializable,Comparable<ByteArray>
public class ByteArray extends Object implements Comparable<ByteArray>, Serializable
Wrapper around byte[] that provides additional features such as:- Implements comparable interface, so comparison and sorting can be performed
- Implements equals() and hashCode(), so it can be used as key for HashMap/Set
- Caches the hash code of the byte[]
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ByteArray(byte[] bytes)
-
Method Summary
Modifier and Type Method Description static intcompare(byte[] left, byte[] right)Compares two byte[] values.static intcompare(byte[] left, int leftFromIndex, int leftToIndex, byte[] right, int rightFromIndex, int rightToIndex)Compares two byte[] values.intcompareTo(ByteArray that)booleanequals(Object o)byte[]getBytes()inthashCode()intlength()StringtoHexString()StringtoString()
-
-
-
Method Detail
-
getBytes
public byte[] getBytes()
-
length
public int length()
-
toHexString
public String toHexString()
-
compareTo
public int compareTo(ByteArray that)
- Specified by:
compareToin interfaceComparable<ByteArray>
-
compare
public static int compare(byte[] left, byte[] right)Compares two byte[] values. The comparison performed is on unsigned value for each byte. Returns:- 0 if both values are identical.
- -ve integer if first value is smaller than the second.
- +ve integer if first value is larger than the second.
- Parameters:
left- First byte[] to compare.right- Second byte[] to compare.- Returns:
- Result of comparison as stated above.
-
compare
public static int compare(byte[] left, int leftFromIndex, int leftToIndex, byte[] right, int rightFromIndex, int rightToIndex)Compares two byte[] values. The comparison performed is on unsigned value for each byte. Returns:- 0 if both values are identical.
- -ve integer if first value is smaller than the second.
- +ve integer if first value is larger than the second.
- Parameters:
left- First byte[] to compare.leftFromIndex- inclusive index of first byte to compare in leftleftToIndex- exclusive index of last byte to compare in leftright- Second byte[] to compare.rightFromIndex- inclusive index of first byte to compare in rightrightToIndex- exclusive index of last byte to compare in right- Returns:
- Result of comparison as stated above.
-
-