public static byte[] stripTrailingWhitespace(Text valueToStrip) {
    byte[] input = valueToStrip.getBytes();
    int i = input.length;
    // iterate from end while we see space or 0x character
    while (i-- > 0 && (input[i] == 32 || input[i] == 0)) {
    }
    byte[] output = new byte[i + 1];
    System.arraycopy(input, 0, output, 0, i + 1);
    return output;
  }
HiveCharWritable.
String values will be padded to full char length.
Character length, comparison, hashCode should ignore trailing spaces.
serde/src/java/org/apache/hadoop/hive/serde2/io/HiveCharWritable.java