io.protostuff.WriteSession Java Examples
The following examples show how to use
io.protostuff.WriteSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Outputs.java From sofa-jraft with Apache License 2.0 | 5 votes |
public static byte[] toByteArray(final Output output) { if (output instanceof WriteSession) { return ((WriteSession) output).toByteArray(); } throw new IllegalArgumentException("Output [" + output.getClass().getName() + "] must be a WriteSession's implementation"); }
Example #2
Source File: Outputs.java From Jupiter with Apache License 2.0 | 5 votes |
public static byte[] toByteArray(Output output) { if (output instanceof WriteSession) { return ((WriteSession) output).toByteArray(); } throw new IllegalArgumentException("Output [" + Reflects.simpleClassName(output) + "] must be a WriteSession's implementation"); }
Example #3
Source File: StringSerializerBenchmark.java From protostuff with Apache License 2.0 | 5 votes |
@Setup public void prepare() throws IOException { sharedBuffer = LinkedBuffer.allocate(512); sharedSession = new WriteSession(sharedBuffer); StringBuilder sb = new StringBuilder(); for (int i = 0; i < stringLength; i++) { sb.append('.'); } s = sb.toString(); }
Example #4
Source File: StringSerializerBenchmark.java From protostuff with Apache License 2.0 | 5 votes |
@Benchmark public byte[] bufferedSerializer() { try { final WriteSession session = new WriteSession(sharedBuffer); StringSerializer.writeUTF8(s, session, sharedBuffer); return session.toByteArray(); } finally { sharedBuffer.clear(); } }
Example #5
Source File: StringSerializerBenchmark.java From protostuff with Apache License 2.0 | 5 votes |
@Benchmark public byte[] bufferedRecycledSerializer() { final WriteSession session = this.sharedSession; try { StringSerializer.writeUTF8(s, session, session.head); return session.toByteArray(); } finally { session.clear(); } }