Java Code Examples for org.apache.thrift.transport.TMemoryBuffer#length()

The following examples show how to use org.apache.thrift.transport.TMemoryBuffer#length() . 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: ThriftJacksonSerializers.java    From armeria with Apache License 2.0 5 votes vote down vote up
private static String serializeTBaseLike(Consumer<TProtocol> writer, boolean useNamedEnums) {
    final TMemoryBuffer buffer = new TMemoryBuffer(1024);
    final TProtocolFactory factory = useNamedEnums ? ThriftProtocolFactories.TEXT_NAMED_ENUM
                                                   : ThriftProtocolFactories.TEXT;
    final TProtocol protocol = factory.getProtocol(buffer);
    writer.accept(protocol);
    return new String(buffer.getArray(), 0, buffer.length());
}
 
Example 2
Source File: ThriftIDLSerializer.java    From octo-rpc with Apache License 2.0 4 votes vote down vote up
private byte[] getActualBytes(TMemoryBuffer memoryBuffer) {
    byte[] actualBytes = new byte[memoryBuffer.length()];
    System.arraycopy(memoryBuffer.getArray(), 0, actualBytes, 0, memoryBuffer.length());
    return actualBytes;
}