hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hamed Madani (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-8782) Thrift2 can not parse values when using framed transport
Date Mon, 24 Jun 2013 02:01:21 GMT

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

Hamed Madani commented on HBASE-8782:
-------------------------------------

Well, I did more digging and found exactly why with framed transport I had to change ByteBuffer.array()
to Bytes.getBytes();

{code}
  public ByteBuffer readBinary() throws TException {
    int size = readI32();
    checkReadLength(size);

    if (trans_.getBytesRemainingInBuffer() >= size) {
      ByteBuffer bb = ByteBuffer.wrap(trans_.getBuffer(), trans_.getBufferPosition(), size);
      trans_.consumeBuffer(size);
      return bb;
    }

    byte[] buf = new byte[size];
    trans_.readAll(buf, 0, size);
    return ByteBuffer.wrap(buf);
  }
{code}

when using framed transport , above function returns a buffer with the same size of the trans_.getBuffer()
and modified 'position' and 'limit' values based on 'size' variable. 

However, when using a Binary protocol .getBytesRemainingInBuffer() will return -1 and function
returns a new buffer with length ='size', position = 0 and limit= size. when Binary protocol
is used, .array() simply returns this small inner array which holds only the relevant bytes,
Which is not the case with framed transport. 

I added the below function to HtableInterface, so that I can just pass the ByteBuffer without
using the .getBytes function . Do you think this solution is a good idea ? 
{code}
  public HTableInterface getTable(ByteBuffer tableName) {
    return getTable(Bytes.toString(tableName.array(), tableName.position(), tableName.remaining()));
  }
{code}


                
> Thrift2 can not parse values when using framed transport
> --------------------------------------------------------
>
>                 Key: HBASE-8782
>                 URL: https://issues.apache.org/jira/browse/HBASE-8782
>             Project: HBase
>          Issue Type: Bug
>          Components: Thrift
>    Affects Versions: 0.95.1
>            Reporter: Hamed Madani
>         Attachments: HBASE_8782.patch
>
>
> ThriftHBaseServiceHandler.java use .array() on table names , and values (family , qualifier
in checkandDelete , etc) which resulted in incorrect values with framed transport. Replacing
.array() with getBytes() fixed this problem. I've attached the patch
> EDIT: updated the patch to cover checkAndPut(), checkAndDelete()

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message