private void reverse(byte[] arr, int first, int last) {
    for (int i = 0; i < (last - first + 1) / 2; i++) {
      byte temp = arr[last - i];
      arr[last - i] = arr[first + i];
      arr[first + i] = temp;
    }
  }
Reverse a portion of an array in-place.

@param arr
         The array where the data will be reversed.
@param first
         The beginning of the portion (inclusive).
@param last
         The end of the portion (inclusive).
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFReverse.java