[ 
https://issues.apache.org/jira/browse/THRIFT-3432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15043603#comment-15043603
 ] 

ASF GitHub Bot commented on THRIFT-3432:
----------------------------------------

Github user nsuke commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/705#discussion_r46765176
  
    --- Diff: lib/java/src/org/apache/thrift/transport/TByteBuffer.java ---
    @@ -0,0 +1,88 @@
    +package org.apache.thrift.transport;
    +
    +import java.nio.BufferOverflowException;
    +import java.nio.BufferUnderflowException;
    +import java.nio.ByteBuffer;
    +
    +/**
    + * ByteBuffer-backed implementation of TTransport.
    + */
    +public class TByteBuffer extends TTransport {
    +  private ByteBuffer byteBuffer;
    +
    +  /**
    +   * Creates a new TByteBuffer wrapping a given NIO ByteBuffer.
    +   */
    +  public TByteBuffer(ByteBuffer byteBuffer) {
    +    this.byteBuffer = byteBuffer;
    +  }
    +
    +  /**
    +   * Resets the underlying NIO ByteBuffer.
    +   */
    +  public void reset(ByteBuffer byteBuffer) {
    --- End diff --
    
    Shouldn't this and nioBuffer be simple setter/getter  ?
    Since we have flip(), reset() can be misleading.


> Add a TByteBuffer transport to the Java library
> -----------------------------------------------
>
>                 Key: THRIFT-3432
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3432
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Library
>    Affects Versions: 0.9.3
>            Reporter: Tom Lee
>            Priority: Minor
>
> A bounded alternative to TMemoryBuffer that uses java.nio.ByteBuffer under 
> the hood.
> This is useful both to set sane constraints on maximum message size in a 
> transport-agnostic manner but also because direct buffers can be used to 
> serialize Thrift off-heap, avoiding allocations (thus reducing GC frequency 
> and potentially live set size)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to