/** * Write the contents of this part to the specified byte buffer. */ public final void sendTo(ByteBuffer buf) { if (getLength() > 0) { if (this.part instanceof byte[]) { buf.put((byte[])this.part); } else { HeapDataOutputStream hdos = (HeapDataOutputStream)this.part; hdos.sendTo(buf); hdos.rewind(); } } } /**
HeapDataOutputStream hdos = (HeapDataOutputStream)this.part; hdos.sendTo(sc, buf); hdos.rewind();
/** * Write the contents of this part to the specified output stream. */ public final void sendTo(OutputStream out) throws IOException { if (getLength() > 0) { if (this.part instanceof byte[]) { byte[] bytes = (byte[])this.part; out.write(bytes, 0, bytes.length); } else { HeapDataOutputStream hdos = (HeapDataOutputStream)this.part; hdos.sendTo(out); hdos.rewind(); } } } /**
HeapDataOutputStream hdos = (HeapDataOutputStream)this.part; hdos.sendTo(sc, buf); hdos.rewind();
/** * Writes the given object to this stream as a byte array. * The byte array is produced by serializing v. The serialization * is done by calling DataSerializer.writeObject. */ public void writeAsSerializedByteArray(Object v) throws IOException { if (this.ignoreWrites) return; checkIfWritable(); ensureCapacity(5); if (v instanceof HeapDataOutputStream) { HeapDataOutputStream other = (HeapDataOutputStream)v; InternalDataSerializer.writeArrayLength(other.size(), this); other.sendTo((OutputStream)this); other.rewind(); } else { ByteBuffer sizeBuf = this.buffer; int sizePos = sizeBuf.position(); sizeBuf.position(sizePos+5); final int preArraySize = size(); DataSerializer.writeObject(v, this); int arraySize = size() - preArraySize; sizeBuf.put(sizePos, InternalDataSerializer.INT_ARRAY_LEN); sizeBuf.putInt(sizePos+1, arraySize); } }
HeapDataOutputStream hdos = (HeapDataOutputStream)this.part; hdos.sendTo(buf); hdos.rewind();
HeapDataOutputStream hdos = (HeapDataOutputStream)this.part; hdos.sendTo(out, buf); hdos.rewind();
} else { other.sendTo((ByteBufferWriter)this); other.rewind();
public void toData(DataOutput out) throws IOException { if (this.preserializedBuffer != null) { this.preserializedBuffer.rewind(); this.preserializedBuffer.sendTo(out); } else if (this.refCount > 1) { Version v = InternalDataSerializer.getVersionForDataStream(out); HeapDataOutputStream hdos = new HeapDataOutputStream(1024, v); basicToData(hdos); this.preserializedBuffer = hdos; this.preserializedBuffer.sendTo(out); } else { basicToData(out); } } /**
InternalDataSerializer.writeArrayLength(other.size(), this); other.sendTo((ByteBufferWriter)this); other.rewind(); return;
InternalDataSerializer.writeArrayLength(other.size(), this); other.sendTo((OutputStream)this); other.rewind(); return;