Java Code Examples for io.protostuff.WriteSession
The following examples show how to use
io.protostuff.WriteSession.
These examples are extracted from open source projects.
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 Project: sofa-jraft Author: sofastack File: Outputs.java License: 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 Project: Jupiter Author: fengjiachun File: Outputs.java License: 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 Project: protostuff Author: protostuff File: StringSerializerBenchmark.java License: 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 Project: protostuff Author: protostuff File: StringSerializerBenchmark.java License: 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 Project: protostuff Author: protostuff File: StringSerializerBenchmark.java License: 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(); } }