public BytesWritable readBytes(BytesWritable bw) throws IOException {
   byte[] bytes = in.readBytes();
   if (bw == null) {
     bw = new BytesWritable(bytes);
   } else {
     bw.set(bytes, 0, bytes.length);
   }
   return bw;
 }
 public Writable readWritable(Writable writable) throws IOException {
   ByteArrayInputStream bais = new ByteArrayInputStream(in.readBytes());
   DataInputStream dis = new DataInputStream(bais);
   String className = WritableUtils.readString(dis);
   if (writable == null) {
     try {
       Class<? extends Writable> cls = conf.getClassByName(className).asSubclass(Writable.class);
       writable = (Writable) ReflectionUtils.newInstance(cls, conf);
     } catch (ClassNotFoundException e) {
       throw new IOException(e);
     }
   } else if (!writable.getClass().getName().equals(className)) {
     throw new IOException("wrong Writable class given");
   }
   writable.readFields(dis);
   return writable;
 }