public void setValue(Object obj) {
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      TypedBytesOutput tbo = TypedBytesOutput.get(new DataOutputStream(baos));
      tbo.write(obj);
      byte[] bytes = baos.toByteArray();
      set(bytes, 0, bytes.length);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Set the typed bytes from a given Java object.
contrib/src/java/org/apache/hadoop/hive/contrib/util/typedbytes/TypedBytesWritable.java