You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by anil gupta <an...@gmail.com> on 2014/08/05 06:26:15 UTC

What is replacement of kv.getBuffer() in HBase0.98?

I have been using KeyValues.getBuffer() very heavily in my HBase0.94 code.
This method is not present in 0.98. What is the equivalent of
KeyValues.getBuffer() in Cell?
I am trying to avoid doing ArrayCopy of CF just for doing comparison.

What would be equivalent for this code in 0.98?
Bytes.equals(columnFamily, 0, columnFamily.length, keyvalue.getBuffer(),
keyvalue.getFamilyOffset(),
                                keyvalue.getFamilyLength())))

Maybe this?
Bytes.equals(columnFamily, 0, columnFamily.length, cell.getBuffer(),
cell.getFamilyOffset(),
                                cell.getFamilyLength())))

-- 
Thanks & Regards,
Anil Gupta

Re: What is replacement of kv.getBuffer() in HBase0.98?

Posted by ramkrishna vasudevan <ra...@gmail.com>.
Hi Anil
As we have moved to the concept of Cells getBuffer() no longer applies to
it  But you could use getRowArray, getFamilyArray, getQualifierArray
anything to do what getBuffer() does. It is less intuitive but in terms of
cells we expect the KV to have its individual components backed by
individual byte arrays(row, cf, q, val) etc.

But what I expect is in your code you would try to extract row, cf, qual
etc. by using kv.getBuffer.  The same can be done even now.

For eg, to extract the family out of the row key you could use
cell.getFamilyarray(), cell.getFamilyOffset(), cell.getFamilyLength().
So it would be
Bytes.equals(columnFamily, 0, columnFamily.length, cell.getFamilyArray(),
cell.getFamilyOffset(),
                                cell.getFamilyLength())))

Regards
Ram


On Mon, Aug 4, 2014 at 9:56 PM, anil gupta <an...@gmail.com> wrote:

> Hi Ted,
>
> This will return entire backing bytes array just like keyValue.getBuffer()?
> By the documentation i thought its returning some file name :
> byte[] *getFamilyArray
> <
> https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/Cell.html#getFamilyArray%28%29
> >*
> ()
> Contiguous bytes composed of legal HDFS filename characters which may start
> at any index in the containing array.
>
> IMHO, this method name is not as intuitive as "getBuffer".
>
> Thanks,
> Anil
>
>
>
> On Mon, Aug 4, 2014 at 9:32 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > Take a look at this method in Cell:
> >
> >   byte[] getFamilyArray();
> >
> > Cheers
> >
> >
> > On Mon, Aug 4, 2014 at 9:26 PM, anil gupta <an...@gmail.com>
> wrote:
> >
> > > I have been using KeyValues.getBuffer() very heavily in my HBase0.94
> > code.
> > > This method is not present in 0.98. What is the equivalent of
> > > KeyValues.getBuffer() in Cell?
> > > I am trying to avoid doing ArrayCopy of CF just for doing comparison.
> > >
> > > What would be equivalent for this code in 0.98?
> > > Bytes.equals(columnFamily, 0, columnFamily.length,
> keyvalue.getBuffer(),
> > > keyvalue.getFamilyOffset(),
> > >                                 keyvalue.getFamilyLength())))
> > >
> > > Maybe this?
> > > Bytes.equals(columnFamily, 0, columnFamily.length, cell.getBuffer(),
> > > cell.getFamilyOffset(),
> > >                                 cell.getFamilyLength())))
> > >
> > > --
> > > Thanks & Regards,
> > > Anil Gupta
> > >
> >
>
>
>
> --
> Thanks & Regards,
> Anil Gupta
>

Re: What is replacement of kv.getBuffer() in HBase0.98?

Posted by anil gupta <an...@gmail.com>.
Thanks for clarification, Lars and Ram.
As per Lars comment it seems like this change is meant for long term
strategy where a Row is not backed by a single Byte[].
At present that's the not the case. Hence, i felt that it was less
intuitive.
In long term the new API would make more sense when calling
cell.getFamilyarray() would only provide byte[] from Family.

Thanks,
Anil Gupta


On Mon, Aug 4, 2014 at 11:53 PM, lars hofhansl <la...@apache.org> wrote:

> Hi Anil,
>
> the point of getFamilyArray() is that it may return the entire buffer, but
> it does not *have* to.
> Everybody should use the new API, so that we can eventually have KeyValues
> (Cells) that do not have be backed by a single byte[].
> (i.e. we can have KeyValues backed by separate row, family, column, value
> arrays)
>
>
> -- Lars
>
>
>
> ________________________________
>  From: anil gupta <an...@gmail.com>
> To: "user@hbase.apache.org" <us...@hbase.apache.org>
> Sent: Monday, August 4, 2014 9:56 PM
> Subject: Re: What is replacement of kv.getBuffer() in HBase0.98?
>
>
> Hi Ted,
>
> This will return entire backing bytes array just like keyValue.getBuffer()?
> By the documentation i thought its returning some file name :
> byte[] *getFamilyArray
> <
> https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/Cell.html#getFamilyArray%28%29
> >*
> ()
> Contiguous bytes composed of legal HDFS filename characters which may start
> at any index in the containing array.
>
> IMHO, this method name is not as intuitive as "getBuffer".
>
> Thanks,
> Anil
>
>
>
> On Mon, Aug 4, 2014 at 9:32 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > Take a look at this method in Cell:
> >
> >   byte[] getFamilyArray();
> >
> > Cheers
> >
> >
> > On Mon, Aug 4, 2014 at 9:26 PM, anil gupta <an...@gmail.com>
> wrote:
> >
> > > I have been using KeyValues.getBuffer() very heavily in my HBase0.94
> > code.
> > > This method is not present in 0.98. What is the equivalent of
> > > KeyValues.getBuffer() in Cell?
> > > I am trying to avoid doing ArrayCopy of CF just for doing comparison.
> > >
> > > What would be equivalent for this code in 0.98?
> > > Bytes.equals(columnFamily, 0, columnFamily.length,
> keyvalue.getBuffer(),
> > > keyvalue.getFamilyOffset(),
> > >                                 keyvalue.getFamilyLength())))
> > >
> > > Maybe this?
> > > Bytes.equals(columnFamily, 0, columnFamily.length, cell.getBuffer(),
> > > cell.getFamilyOffset(),
> > >                                 cell.getFamilyLength())))
> > >
> > > --
> > > Thanks & Regards,
> > > Anil Gupta
>
>
>
> > >
> >
>
>
>
> --
> Thanks & Regards,
> Anil Gupta
>



-- 
Thanks & Regards,
Anil Gupta

Re: What is replacement of kv.getBuffer() in HBase0.98?

Posted by lars hofhansl <la...@apache.org>.
Hi Anil,

the point of getFamilyArray() is that it may return the entire buffer, but it does not *have* to.
Everybody should use the new API, so that we can eventually have KeyValues (Cells) that do not have be backed by a single byte[].
(i.e. we can have KeyValues backed by separate row, family, column, value arrays)


-- Lars



________________________________
 From: anil gupta <an...@gmail.com>
To: "user@hbase.apache.org" <us...@hbase.apache.org> 
Sent: Monday, August 4, 2014 9:56 PM
Subject: Re: What is replacement of kv.getBuffer() in HBase0.98?
 

Hi Ted,

This will return entire backing bytes array just like keyValue.getBuffer()?
By the documentation i thought its returning some file name :
byte[] *getFamilyArray
<https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/Cell.html#getFamilyArray%28%29>*
()
Contiguous bytes composed of legal HDFS filename characters which may start
at any index in the containing array.

IMHO, this method name is not as intuitive as "getBuffer".

Thanks,
Anil



On Mon, Aug 4, 2014 at 9:32 PM, Ted Yu <yu...@gmail.com> wrote:

> Take a look at this method in Cell:
>
>   byte[] getFamilyArray();
>
> Cheers
>
>
> On Mon, Aug 4, 2014 at 9:26 PM, anil gupta <an...@gmail.com> wrote:
>
> > I have been using KeyValues.getBuffer() very heavily in my HBase0.94
> code.
> > This method is not present in 0.98. What is the equivalent of
> > KeyValues.getBuffer() in Cell?
> > I am trying to avoid doing ArrayCopy of CF just for doing comparison.
> >
> > What would be equivalent for this code in 0.98?
> > Bytes.equals(columnFamily, 0, columnFamily.length, keyvalue.getBuffer(),
> > keyvalue.getFamilyOffset(),
> >                                 keyvalue.getFamilyLength())))
> >
> > Maybe this?
> > Bytes.equals(columnFamily, 0, columnFamily.length, cell.getBuffer(),
> > cell.getFamilyOffset(),
> >                                 cell.getFamilyLength())))
> >
> > --
> > Thanks & Regards,
> > Anil Gupta



> >
>



-- 
Thanks & Regards,
Anil Gupta

Re: What is replacement of kv.getBuffer() in HBase0.98?

Posted by anil gupta <an...@gmail.com>.
Hi Ted,

This will return entire backing bytes array just like keyValue.getBuffer()?
By the documentation i thought its returning some file name :
byte[] *getFamilyArray
<https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/Cell.html#getFamilyArray%28%29>*
()
Contiguous bytes composed of legal HDFS filename characters which may start
at any index in the containing array.

IMHO, this method name is not as intuitive as "getBuffer".

Thanks,
Anil



On Mon, Aug 4, 2014 at 9:32 PM, Ted Yu <yu...@gmail.com> wrote:

> Take a look at this method in Cell:
>
>   byte[] getFamilyArray();
>
> Cheers
>
>
> On Mon, Aug 4, 2014 at 9:26 PM, anil gupta <an...@gmail.com> wrote:
>
> > I have been using KeyValues.getBuffer() very heavily in my HBase0.94
> code.
> > This method is not present in 0.98. What is the equivalent of
> > KeyValues.getBuffer() in Cell?
> > I am trying to avoid doing ArrayCopy of CF just for doing comparison.
> >
> > What would be equivalent for this code in 0.98?
> > Bytes.equals(columnFamily, 0, columnFamily.length, keyvalue.getBuffer(),
> > keyvalue.getFamilyOffset(),
> >                                 keyvalue.getFamilyLength())))
> >
> > Maybe this?
> > Bytes.equals(columnFamily, 0, columnFamily.length, cell.getBuffer(),
> > cell.getFamilyOffset(),
> >                                 cell.getFamilyLength())))
> >
> > --
> > Thanks & Regards,
> > Anil Gupta
> >
>



-- 
Thanks & Regards,
Anil Gupta

Re: What is replacement of kv.getBuffer() in HBase0.98?

Posted by Ted Yu <yu...@gmail.com>.
Take a look at this method in Cell:

  byte[] getFamilyArray();

Cheers


On Mon, Aug 4, 2014 at 9:26 PM, anil gupta <an...@gmail.com> wrote:

> I have been using KeyValues.getBuffer() very heavily in my HBase0.94 code.
> This method is not present in 0.98. What is the equivalent of
> KeyValues.getBuffer() in Cell?
> I am trying to avoid doing ArrayCopy of CF just for doing comparison.
>
> What would be equivalent for this code in 0.98?
> Bytes.equals(columnFamily, 0, columnFamily.length, keyvalue.getBuffer(),
> keyvalue.getFamilyOffset(),
>                                 keyvalue.getFamilyLength())))
>
> Maybe this?
> Bytes.equals(columnFamily, 0, columnFamily.length, cell.getBuffer(),
> cell.getFamilyOffset(),
>                                 cell.getFamilyLength())))
>
> --
> Thanks & Regards,
> Anil Gupta
>