@Benchmark public void generated_serialize_1_int_field() throws Exception { try { ProtobufIOUtil.writeTo(buffer, generatedInt1, generatedInt1Schema); } finally { buffer.clear(); } }
@Benchmark public void runtime_serialize_10_int_fields() throws Exception { try { ProtobufIOUtil.writeTo(buffer, int10, int10RuntimeSchema); } finally { buffer.clear(); } }
@Benchmark public void runtime_sparse_serialize_10_int_fields() throws Exception { try { ProtobufIOUtil.writeTo(buffer, sparseInt10, sparseInt10RuntimeSchema); } finally { buffer.clear(); } }
@Benchmark public void generated_serialize_10_int_field() throws Exception { try { ProtobufIOUtil.writeTo(buffer, generatedInt10, generatedInt10Schema); } finally { buffer.clear(); } }
@Benchmark public void runtime_sparse_serialize_1_int_field() throws Exception { try { ProtobufIOUtil.writeTo(buffer, sparseInt1, sparseInt1RuntimeSchema); } finally { buffer.clear(); } }
@Benchmark public void runtime_serialize_1_int_field() throws Exception { try { ProtobufIOUtil.writeTo(buffer, int1, int1RuntimeSchema); } finally { buffer.clear(); } }
@Override protected <T> void writeTo(OutputStream out, T message, Schema<T> schema) throws IOException { ProtobufIOUtil.writeTo(out, message, schema, buf()); }
@Override protected <T> void writeTo(OutputStream out, T message, Schema<T> schema) throws IOException { ProtobufIOUtil.writeTo(out, message, schema, buf()); }
@Override protected <T> void writeTo(OutputStream out, T message, Schema<T> schema) throws IOException { ProtobufIOUtil.writeTo(out, message, schema, buf()); }
@Override protected <T> void writeTo(OutputStream out, T message, Schema<T> schema) throws IOException { ProtobufIOUtil.writeTo(out, message, schema, buf()); }
@Override protected <T> void writeTo(OutputStream out, T message, Schema<T> schema) throws IOException { ProtobufIOUtil.writeTo(out, message, schema, buf()); }
ProtobufIOUtil.writeTo(controlStream, msg, sch, linkedBuffer);
static void verifyProtobuf(PojoWithInts p) throws IOException { Schema<PojoWithInts> schema = PojoWithInts.getSchema(); byte[] data = ProtobufIOUtil.toByteArray(p, schema, buf()); PojoWithInts pFromByteArray = new PojoWithInts(); ProtobufIOUtil.mergeFrom(data, pFromByteArray, schema); assertEquals(p, pFromByteArray); ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufIOUtil.writeTo(out, p, schema, buf()); byte[] dataFromStream = out.toByteArray(); assertTrue(Arrays.equals(data, dataFromStream)); ByteArrayInputStream in = new ByteArrayInputStream(data); PojoWithInts pFromStream = new PojoWithInts(); ProtobufIOUtil.mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); }
public void testInheritanceProtobuf() throws IOException { if (skipTests) { System.err .println("RuntimeSchema.MORPH_NON_FINAL_POJOS was not enabled."); return; } System.err.println("executing inheritance test for protobuf ... "); Schema<InputSystem> schema = RuntimeSchema.getSchema(InputSystem.class); InputSystem sys = new InputSystem(); KeyBoard kb = new KeyBoard(); Mouse ms = new Mouse(); kb.setName("Test"); kb.setNumberOfKeys(10); ms.setName("Test1"); ms.setNumberOfButtons(2); List<InputDevice> devices = new ArrayList<InputDevice>(); devices.add(ms); devices.add(kb); sys.setInputDevices(devices); ByteArrayOutputStream out = new ByteArrayOutputStream(); ProtobufIOUtil.writeTo(out, sys, schema, buf()); byte[] listData = out.toByteArray(); InputSystem deserSystem = new InputSystem(); ByteArrayInputStream in = new ByteArrayInputStream(listData); ProtobufIOUtil.mergeFrom(in, deserSystem, schema, buf()); assertEquals(sys, deserSystem); }
protected <T> int writeObject(LinkedBuffer buffer, T object, Schema<T> schema) { return ProtobufIOUtil.writeTo(buffer, object, schema); }
@Override public void encode(OutputStream stream, Object value) throws IOException { Schema schema = RuntimeSchema.getSchema(value.getClass()); try (RecyclableLinkedBuffer rlb = recyclableLinkedBuffer.get()) { ProtobufIOUtil.writeTo(stream, value, schema, rlb.buffer()); } }
YamlIOUtil.writeTo(out, message, schema, buffer); } else if ("application/x-protobuf".equals(media.toString())) { ProtobufIOUtil.writeTo(out, message, schema, buffer); } else if ("application/x-protostuff".equals(media.toString())) { ProtostuffIOUtil.writeTo(out, message, schema, buffer);
Message<Object> pb = (Message<Object>) page; Schema<Object> pbSchema = pb.cachedSchema(); ProtobufIOUtil.writeTo(countingStream, page, pbSchema, buffer); buffer.clear(); break;