private static Object stringTypeToPig(Object value) {
    if (value instanceof String) {
      return value;
    }
    if (value instanceof byte[]) {
      byte[] buf = (byte[])value;
      return new DataByteArray(Arrays.copyOf(buf, buf.length));
    }
    if (value instanceof ByteBuffer) {
      ByteBuffer bin = (ByteBuffer)value;
      byte[] buf = new byte[bin.remaining()];
      bin.mark();
      bin.get(buf);
      bin.reset();
      return new DataByteArray(buf);
    }
    return null;
  }
private static Object stringTypeToPig(Object value) {
    if (value instanceof String) {
      return value;
    }
    if (value instanceof byte[]) {
      byte[] buf = (byte[])value;
      return new DataByteArray(Arrays.copyOf(buf, buf.length));
    }
    if (value instanceof ByteBuffer) {
      ByteBuffer bin = (ByteBuffer)value;
      byte[] buf = new byte[bin.remaining()];
      bin.mark();
      bin.get(buf);
      bin.reset();
      return new DataByteArray(buf);
    }
    return null;
  }
private static Object stringTypeToPig ( Object value ) { if ( value instanceof String ) { return value ; } if ( value instanceof byte [ ] ) { byte [ ] buf = ( byte [ ] ) value ; return new DataByteArray ( Arrays . copyOf ( buf , buf . length ) ) ; } if ( value instanceof ByteBuffer ) { ByteBuffer bin = ( ByteBuffer ) value ; byte [ ] buf = new byte [ bin . remaining ( ) ] ; bin . mark ( ) ; bin . get ( buf ) ; bin . reset ( ) ; return new DataByteArray ( buf ) ; } return null ; }
TType.STRING is a mess in Thrift. It could be byte[], ByteBuffer,
or even a String!.
TType . STRING is a mess in Thrift . It could be byte [] ByteBuffer or even a String! .