Class ByteFunctionHelpers

java.lang.Object
org.apache.arrow.memory.util.ByteFunctionHelpers

public class ByteFunctionHelpers extends Object
Utility methods for memory comparison at a byte level.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    combineHash(int currentHash, int newHash)
    Generate a new hashCode with the given current hashCode and new hashCode.
    static int
    compare(ArrowBuf left, int lStart, int lEnd, byte[] right, int rStart, int rEnd)
    Helper function to compare a set of bytes in ArrowBuf to a ByteArray.
    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.
    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.
    static int
    hash(ArrowBuf buf, long start, long end)
    Compute hashCode with the given ArrowBuf and start/end index.
    static final int
    hash(ArrowBufHasher hasher, ArrowBuf buf, long start, long end)
    Compute hashCode with the given ArrowBufHasher, ArrowBuf and start/end index.
    static int
    unsignedIntCompare(int a, int b)
     
    static int
    unsignedLongCompare(long a, long b)
    Compares the two specified long values, treating them as unsigned values between 0 and 2^64 - 1 inclusive.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 comparison
      lStart - start offset in the buffer
      lEnd - end offset in the buffer
      right - Right ArrowBuf for comparison
      rStart - start offset in the buffer
      rEnd - 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 compare
      lStart - start offset in the buffer
      lEnd - end offset in the buffer
      right - Right ArrowBuf to compare
      rStart - start offset in the buffer
      rEnd - end offset in the buffer
      Returns:
      1 if left input is greater, -1 if left input is smaller, 0 otherwise
    • compare

      public static int compare(ArrowBuf left, int lStart, int lEnd, byte[] right, int rStart, int rEnd)
      Helper function to compare a set of bytes in ArrowBuf to a ByteArray.
      Parameters:
      left - Left ArrowBuf for comparison purposes
      lStart - start offset in the buffer
      lEnd - end offset in the buffer
      right - second input to be compared
      rStart - start offset in the byte array
      rEnd - 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 specified long values, treating them as unsigned values between 0 and 2^64 - 1 inclusive.
      Parameters:
      a - the first unsigned long to compare
      b - the second unsigned long to compare
      Returns:
      a negative value if a is less than b; a positive value if a is greater than b; or zero if they are equal
    • unsignedIntCompare

      public static int unsignedIntCompare(int a, int b)
    • hash

      public static int hash(ArrowBuf buf, long start, long end)
      Compute hashCode with the given ArrowBuf and start/end index.
    • hash

      public static final int hash(ArrowBufHasher hasher, ArrowBuf buf, long start, long end)
      Compute hashCode with the given ArrowBufHasher, 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.