You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Sean Bridges (JIRA)" <ji...@apache.org> on 2011/01/17 20:07:44 UTC

[jira] Issue Comment Edited: (THRIFT-883) Extend ByteBuffer support to non-array-backed ByteBuffers

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

Sean Bridges edited comment on THRIFT-883 at 1/17/11 2:05 PM:
--------------------------------------------------------------

What will thrift policy with mutating the position and mark fields on a ByteBuffer be when non array backed ByteBuffers are supported.

For example, is this code that retries a thrift operation multiple times correct,

{code}
ByteBuffer buf = ...;
SomeThriftObject t = ...;
t.setBinaryField(buf);

for(int i =1; i < 5; i++) {
  //will this modify postion() on buf? 
  //will it call rewind() on buf before reading?
  someThriftClient.doSomething(t);
  break;
}
{code}

I don't see a good api to bulk copy from a ByteBuffer that is not backed by an array unless you change the position variable.  

Perhaps Thrift always calls rewind() on the ByteBuffer before reading from it.

      was (Author: sgbridges):
    What will thrift policy with mutating the position and mark fields on a ByteBuffer be when non array backed ByteBuffers are supported.

For example, is this code that retries a thrift operation multiple times correct,

ByteBuffer buf = ...;
SomeThriftObject t = ...;
t.setBinaryField(buf);

for(int i =1; i < 5; i++) {
  //will this modify postion() on buf? 
  //will it call rewind() on buf before reading?
  someThriftClient.doSomething(t);
  break;
}

I don't see a good api to bulk copy from a ByteBuffer that is not backed by an array unless you change the position variable.  

Perhaps Thrift always calls rewind() on the ByteBuffer before reading from it.
  
> Extend ByteBuffer support to non-array-backed ByteBuffers
> ---------------------------------------------------------
>
>                 Key: THRIFT-883
>                 URL: https://issues.apache.org/jira/browse/THRIFT-883
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Java - Library
>    Affects Versions: 0.4
>            Reporter: Bryan Duxbury
>            Assignee: Bryan Duxbury
>             Fix For: 0.7
>
>         Attachments: TBinaryProtocol-writeBinary.patch
>
>
> Binary fields are backed by ByteBuffers that wrap byte arrays, and all the protocol code assumes that every ByteBuffer is of this type. However, now that the structs setters allow ByteBuffer arguments, it would be nice to support other kinds of ByteBuffers, like those that are allocated direct.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.