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 2013/01/22 18:43:12 UTC

Possibly unnecessary check in Result.getColumnLatest(byte[] family, byte[] qualifier)

Hi All,

I was looking into the code of Result.getColumnLatest(byte[] family, byte[]
qualifier) in HBase0.94.3 tag.
I feel like the following check is unnecessary on line #245 since we have
already got the right column by preforming binary search previously:
    if (kv.matchingColumn(family, qualifier)) {
      return kv;
    }

Am i missing something over here?
-- 
Thanks & Regards,
Anil Gupta

Re: Possibly unnecessary check in Result.getColumnLatest(byte[] family, byte[] qualifier)

Posted by anil gupta <an...@gmail.com>.
Inline.

On Tue, Jan 22, 2013 at 3:19 PM, Ted Yu <yu...@gmail.com> wrote:

> KeyValue.KVComparator in 0.94 looks similar to that in trunk.
>
> Here is the compare() method:
>
>     public int compare(final KeyValue left, final KeyValue right) {
>
>       int ret = getRawComparator().compare(left.getBuffer(),
>
>           left.getOffset() + ROW_OFFSET, left.getKeyLength(),
>
>           right.getBuffer(), right.getOffset() + ROW_OFFSET,
>
>           right.getKeyLength());
>
>       if (ret != 0) return ret;
>
>       // Negate this comparison so later edits show up first
>
>       return -Longs.compare(left.getMemstoreTS(), right.getMemstoreTS());
>
>     }
>
> I am unable to understand how this relates to the check at line #245 in
http://svn.apache.org/repos/asf/hbase/tags/0.94.3/src/main/java/org/apache/hadoop/hbase/client/Result.java

I mean to say that we should not check for "matchingColumn" since we are
already doing the BinarySearch and getting the position of keyValue. I hope
i am making some sense.

>
> On Tue, Jan 22, 2013 at 2:49 PM, anil gupta <an...@gmail.com> wrote:
>
> > Hi Ted,
> >
> > Maybe it is out of sync with trunk. Here is the svn link for Result.java
> in
> > HBase0.94.3:
> >
> >
> http://svn.apache.org/repos/asf/hbase/tags/0.94.3/src/main/java/org/apache/hadoop/hbase/client/Result.java
> >
> > ~Anil
> >
> >
> > On Tue, Jan 22, 2013 at 10:18 AM, Ted Yu <yu...@gmail.com> wrote:
> >
> > > I am looking at trunk code.
> > >
> > > binarySearch() calls this method:
> > >
> > >     int pos = Arrays.binarySearch(kvs, searchTerm,
> KeyValue.COMPARATOR);
> > > Here is the compare() method of KVComparator:
> > >
> > >     public int compare(final KeyValue left, final KeyValue right) {
> > >
> > >       int ret = getRawComparator().compare(left.getBuffer(),
> > >
> > >           left.getOffset() + ROW_OFFSET, left.getKeyLength(),
> > >
> > >           right.getBuffer(), right.getOffset() + ROW_OFFSET,
> > >
> > >           right.getKeyLength());
> > >
> > >       if (ret != 0) return ret;
> > >
> > >       // Negate this comparison so later edits show up first
> > >
> > >       return -Longs.compare(left.getMemstoreTS(),
> right.getMemstoreTS());
> > >
> > >     }
> > > I don't see duplicate check.
> > >
> > > Cheers
> > >
> > > On Tue, Jan 22, 2013 at 9:43 AM, anil gupta <an...@gmail.com>
> > wrote:
> > >
> > > > Hi All,
> > > >
> > > > I was looking into the code of Result.getColumnLatest(byte[] family,
> > > byte[]
> > > > qualifier) in HBase0.94.3 tag.
> > > > I feel like the following check is unnecessary on line #245 since we
> > have
> > > > already got the right column by preforming binary search previously:
> > > >     if (kv.matchingColumn(family, qualifier)) {
> > > >       return kv;
> > > >     }
> > > >
> > > > Am i missing something over here?
> > > > --
> > > > Thanks & Regards,
> > > > Anil Gupta
> > > >
> > >
> >
> >
> >
> > --
> > Thanks & Regards,
> > Anil Gupta
> >
>



-- 
Thanks & Regards,
Anil Gupta

Re: Possibly unnecessary check in Result.getColumnLatest(byte[] family, byte[] qualifier)

Posted by Ted Yu <yu...@gmail.com>.
KeyValue.KVComparator in 0.94 looks similar to that in trunk.

Here is the compare() method:

    public int compare(final KeyValue left, final KeyValue right) {

      int ret = getRawComparator().compare(left.getBuffer(),

          left.getOffset() + ROW_OFFSET, left.getKeyLength(),

          right.getBuffer(), right.getOffset() + ROW_OFFSET,

          right.getKeyLength());

      if (ret != 0) return ret;

      // Negate this comparison so later edits show up first

      return -Longs.compare(left.getMemstoreTS(), right.getMemstoreTS());

    }


On Tue, Jan 22, 2013 at 2:49 PM, anil gupta <an...@gmail.com> wrote:

> Hi Ted,
>
> Maybe it is out of sync with trunk. Here is the svn link for Result.java in
> HBase0.94.3:
>
> http://svn.apache.org/repos/asf/hbase/tags/0.94.3/src/main/java/org/apache/hadoop/hbase/client/Result.java
>
> ~Anil
>
>
> On Tue, Jan 22, 2013 at 10:18 AM, Ted Yu <yu...@gmail.com> wrote:
>
> > I am looking at trunk code.
> >
> > binarySearch() calls this method:
> >
> >     int pos = Arrays.binarySearch(kvs, searchTerm, KeyValue.COMPARATOR);
> > Here is the compare() method of KVComparator:
> >
> >     public int compare(final KeyValue left, final KeyValue right) {
> >
> >       int ret = getRawComparator().compare(left.getBuffer(),
> >
> >           left.getOffset() + ROW_OFFSET, left.getKeyLength(),
> >
> >           right.getBuffer(), right.getOffset() + ROW_OFFSET,
> >
> >           right.getKeyLength());
> >
> >       if (ret != 0) return ret;
> >
> >       // Negate this comparison so later edits show up first
> >
> >       return -Longs.compare(left.getMemstoreTS(), right.getMemstoreTS());
> >
> >     }
> > I don't see duplicate check.
> >
> > Cheers
> >
> > On Tue, Jan 22, 2013 at 9:43 AM, anil gupta <an...@gmail.com>
> wrote:
> >
> > > Hi All,
> > >
> > > I was looking into the code of Result.getColumnLatest(byte[] family,
> > byte[]
> > > qualifier) in HBase0.94.3 tag.
> > > I feel like the following check is unnecessary on line #245 since we
> have
> > > already got the right column by preforming binary search previously:
> > >     if (kv.matchingColumn(family, qualifier)) {
> > >       return kv;
> > >     }
> > >
> > > Am i missing something over here?
> > > --
> > > Thanks & Regards,
> > > Anil Gupta
> > >
> >
>
>
>
> --
> Thanks & Regards,
> Anil Gupta
>

Re: Possibly unnecessary check in Result.getColumnLatest(byte[] family, byte[] qualifier)

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

Maybe it is out of sync with trunk. Here is the svn link for Result.java in
HBase0.94.3:
http://svn.apache.org/repos/asf/hbase/tags/0.94.3/src/main/java/org/apache/hadoop/hbase/client/Result.java

~Anil


On Tue, Jan 22, 2013 at 10:18 AM, Ted Yu <yu...@gmail.com> wrote:

> I am looking at trunk code.
>
> binarySearch() calls this method:
>
>     int pos = Arrays.binarySearch(kvs, searchTerm, KeyValue.COMPARATOR);
> Here is the compare() method of KVComparator:
>
>     public int compare(final KeyValue left, final KeyValue right) {
>
>       int ret = getRawComparator().compare(left.getBuffer(),
>
>           left.getOffset() + ROW_OFFSET, left.getKeyLength(),
>
>           right.getBuffer(), right.getOffset() + ROW_OFFSET,
>
>           right.getKeyLength());
>
>       if (ret != 0) return ret;
>
>       // Negate this comparison so later edits show up first
>
>       return -Longs.compare(left.getMemstoreTS(), right.getMemstoreTS());
>
>     }
> I don't see duplicate check.
>
> Cheers
>
> On Tue, Jan 22, 2013 at 9:43 AM, anil gupta <an...@gmail.com> wrote:
>
> > Hi All,
> >
> > I was looking into the code of Result.getColumnLatest(byte[] family,
> byte[]
> > qualifier) in HBase0.94.3 tag.
> > I feel like the following check is unnecessary on line #245 since we have
> > already got the right column by preforming binary search previously:
> >     if (kv.matchingColumn(family, qualifier)) {
> >       return kv;
> >     }
> >
> > Am i missing something over here?
> > --
> > Thanks & Regards,
> > Anil Gupta
> >
>



-- 
Thanks & Regards,
Anil Gupta

Re: Possibly unnecessary check in Result.getColumnLatest(byte[] family, byte[] qualifier)

Posted by Ted Yu <yu...@gmail.com>.
I am looking at trunk code.

binarySearch() calls this method:

    int pos = Arrays.binarySearch(kvs, searchTerm, KeyValue.COMPARATOR);
Here is the compare() method of KVComparator:

    public int compare(final KeyValue left, final KeyValue right) {

      int ret = getRawComparator().compare(left.getBuffer(),

          left.getOffset() + ROW_OFFSET, left.getKeyLength(),

          right.getBuffer(), right.getOffset() + ROW_OFFSET,

          right.getKeyLength());

      if (ret != 0) return ret;

      // Negate this comparison so later edits show up first

      return -Longs.compare(left.getMemstoreTS(), right.getMemstoreTS());

    }
I don't see duplicate check.

Cheers

On Tue, Jan 22, 2013 at 9:43 AM, anil gupta <an...@gmail.com> wrote:

> Hi All,
>
> I was looking into the code of Result.getColumnLatest(byte[] family, byte[]
> qualifier) in HBase0.94.3 tag.
> I feel like the following check is unnecessary on line #245 since we have
> already got the right column by preforming binary search previously:
>     if (kv.matchingColumn(family, qualifier)) {
>       return kv;
>     }
>
> Am i missing something over here?
> --
> Thanks & Regards,
> Anil Gupta
>