示例#1
0
 /** {@inheritDoc} */
 @Override
 public String toString() {
   BSONEncoder enc = new BSONEncoder();
   BasicOutputBuffer buf = new BasicOutputBuffer();
   enc.set(buf);
   enc.putObject(_doc);
   enc.done();
   String str = buf.asString();
   log.debug("Output As String: '" + str + "'");
   return str;
 }
示例#2
0
 /**
  * {@inheritDoc}
  *
  * @see Writable#write(DataOutput)
  */
 public void write(DataOutput out) throws IOException {
   BSONEncoder enc = new BSONEncoder();
   BasicOutputBuffer buf = new BasicOutputBuffer();
   enc.set(buf);
   enc.putObject(_doc);
   enc.done();
   out.writeInt(buf.size());
   // For better performance we can copy BasicOutputBuffer.pipe(OutputStream)
   // to have a method signature that works with DataOutput
   out.write(buf.toByteArray());
 }