/** * @param m Message to get delimited pb serialization of (with pb magic prefix) */ public static byte [] toDelimitedByteArray(final Message m) throws IOException { // Allocate arbitrary big size so we avoid resizing. ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); baos.write(PB_MAGIC); m.writeDelimitedTo(baos); return baos.toByteArray(); }
private static int write(final OutputStream dos, final Message header, final Message param, final ByteBuffer cellBlock, final int totalSize) throws IOException { // I confirmed toBytes does same as DataOutputStream#writeInt. dos.write(Bytes.toBytes(totalSize)); // This allocates a buffer that is the size of the message internally. header.writeDelimitedTo(dos); if (param != null) { param.writeDelimitedTo(dos); } if (cellBlock != null) { dos.write(cellBlock.array(), 0, cellBlock.remaining()); } dos.flush(); return totalSize; }
dos.writeInt(IPCUtil.getTotalSizeWhenWrittenDelimited(requestHeader, call.param)); requestHeader.writeDelimitedTo(dos); call.param.writeDelimitedTo(dos); dos.flush();
/** * @param m Message to get delimited pb serialization of (with pb magic prefix) */ public static byte [] toDelimitedByteArray(final Message m) throws IOException { // Allocate arbitrary big size so we avoid resizing. ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); baos.write(PB_MAGIC); m.writeDelimitedTo(baos); return baos.toByteArray(); }
private static int write(final OutputStream dos, final Message header, final Message param, final ByteBuffer cellBlock, final int totalSize) throws IOException { // I confirmed toBytes does same as DataOutputStream#writeInt. dos.write(Bytes.toBytes(totalSize)); // This allocates a buffer that is the size of the message internally. header.writeDelimitedTo(dos); if (param != null) { param.writeDelimitedTo(dos); } if (cellBlock != null) { dos.write(cellBlock.array(), 0, cellBlock.remaining()); } dos.flush(); return totalSize; }
requestHeader.writeDelimitedTo(bbos); if (call.param != null) { call.param.writeDelimitedTo(bbos);
/** * @param m Message to get delimited pb serialization of (with pb magic prefix) */ public static byte [] toDelimitedByteArray(final Message m) throws IOException { // Allocate arbitrary big size so we avoid resizing. ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); baos.write(ProtobufMagic.PB_MAGIC); m.writeDelimitedTo(baos); return baos.toByteArray(); }
private static int write(final OutputStream dos, final Message header, final Message param, final ByteBuffer cellBlock, final int totalSize) throws IOException { // I confirmed toBytes does same as DataOutputStream#writeInt. dos.write(Bytes.toBytes(totalSize)); // This allocates a buffer that is the size of the message internally. header.writeDelimitedTo(dos); if (param != null) { param.writeDelimitedTo(dos); } if (cellBlock != null) { dos.write(cellBlock.array(), 0, cellBlock.remaining()); } dos.flush(); return totalSize; }
requestHeader.writeDelimitedTo(bbos); if (call.param != null) { call.param.writeDelimitedTo(bbos);
dos.writeInt(IPCUtil.getTotalSizeWhenWrittenDelimited(requestHeader, call.param)); requestHeader.writeDelimitedTo(dos); call.param.writeDelimitedTo(dos); dos.flush();
requestHeader.writeDelimitedTo(bbos); if (call.param != null) { call.param.writeDelimitedTo(bbos);