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

    switch(rawType) {
      case serdeConstants.BOOLEAN_TYPE_NAME:
        return Boolean.valueOf(new String(value)).toString().getBytes(UTF_8);
      case serdeConstants.SMALLINT_TYPE_NAME :
      case serdeConstants.TINYINT_TYPE_NAME :
      case serdeConstants.INT_TYPE_NAME :
        return INTEGER_LEXICODER.encode(Integer.valueOf(new String(value)));
      case serdeConstants.FLOAT_TYPE_NAME :
      case serdeConstants.DOUBLE_TYPE_NAME :
        return DOUBLE_LEXICODER.encode(Double.valueOf(new String(value)));
      case serdeConstants.BIGINT_TYPE_NAME :
        return BIG_INTEGER_LEXICODER.encode(new BigInteger(new String(value), 10));
      case serdeConstants.DECIMAL_TYPE_NAME :
        return new String(value).getBytes(UTF_8);
      default :
        // return the passed in string value
        return value;
    }
  }
Utility class to encode index values for accumulo.
accumulo-handler/src/java/org/apache/hadoop/hive/accumulo/AccumuloIndexLexicoder.java