public static byte[] encodeBinaryValue(byte[] value, String hiveType) {
    String rawType = getRawType(hiveType);

    switch(rawType) {
      case serdeConstants.BOOLEAN_TYPE_NAME :
        return String.valueOf(value[0] == 1).getBytes();
      case serdeConstants.INT_TYPE_NAME :
        return INTEGER_LEXICODER.encode(ByteBuffer.wrap(value).asIntBuffer().get());
      case serdeConstants.SMALLINT_TYPE_NAME :
        return INTEGER_LEXICODER.encode((int)(ByteBuffer.wrap(value).asShortBuffer().get()));
      case serdeConstants.TINYINT_TYPE_NAME :
        return INTEGER_LEXICODER.encode((int)value[0]);
      case serdeConstants.FLOAT_TYPE_NAME :
        return DOUBLE_LEXICODER.encode((double)ByteBuffer.wrap(value).asFloatBuffer().get());
      case serdeConstants.DOUBLE_TYPE_NAME :
        return DOUBLE_LEXICODER.encode(ByteBuffer.wrap(value).asDoubleBuffer().get());
      case serdeConstants.BIGINT_TYPE_NAME :
        return BIG_INTEGER_LEXICODER.encode(new BigInteger(value));
      case serdeConstants.DECIMAL_TYPE_NAME :
        return new String(value).getBytes(UTF_8);
      default :
        return value;
    }
  }
Utility class to encode index values for accumulo.
accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java