You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by Rob Roland <ro...@simplymeasured.com> on 2013/07/03 01:11:44 UTC

checkAndPut with comparators

Hi,

I see that in HBASE-3468, we gained the ability to do a checkAndPut with a
comparator, but it doesn't look straightforward to use from a client
perspective.

I'd like to create/submit a patch that would do the following:

Add new WritableByteArrayComparator instances - LongComparator,
IntComparator, DoubleComparator, FloatComparator, ShortComparator,
StringComparator. Pretty much helpers for everything that the Bytes class
can convert to a byte[].

Add a method to HTableInterface / HTable:

    boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
                        final CompareFilter.CompareOp compareOp,
                        final WritableByteArrayComparable comparator,
                        Put put) throws IOException;

and the corresponding delete:

    boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
                        final CompareFilter.CompareOp compareOp,
                        final WritableByteArrayComparable comparator,
                        Delete delete) throws IOException;

Before I get started on that, have I missed anything?

I'm looking at the code in trunk and it's a bit different than the last
time I submitted a patch, so this is going to take a bit. :)

Thanks,

Rob Roland

Re: checkAndPut with comparators

Posted by Stack <st...@duboce.net>.
On Tue, Jul 2, 2013 at 4:47 PM, Rob Roland <ro...@simplymeasured.com> wrote:

> Ahh, okay. Sounds like the rest still applies, though, with wanting to
> expose this to the client APIs in an easier-to-use fashion?
>
> I'd also want to backport this patch to the 0.94.x series so I could
> actually use it in production also :)
>
> I do see the ComparatorProtos (and the various .proto files) in the
> hbase-protocol submodule. Is there a trick to regenerating them? Do I just
> need to run protoc manually? Not an issue if that's the case. I wired up my
> Maven pom in an internal project to call protoc for me during a build.
>
> Thanks,
>
> Rob
>
>
Hey Rob.

We are trying to move off Writables.

You should check out the valiant effort by our LarsH here:
https://issues.apache.org/jira/browse/HBASE-5923  It is related.

For pb generation, see hbase-protocol/src/main/protobuf/README.txt

Thanks,
St.Ack

Re: checkAndPut with comparators

Posted by Ted Yu <yu...@gmail.com>.
Under hbase-protocol directory, run the following for the .proto file:

protoc -Isrc/main/protobuf --java_out=src/main/java $PROTO_FILE

See the hbase-protocol/src/main/protobuf/README.txt

Cheers

On Tue, Jul 2, 2013 at 4:47 PM, Rob Roland <ro...@simplymeasured.com> wrote:

> Ahh, okay. Sounds like the rest still applies, though, with wanting to
> expose this to the client APIs in an easier-to-use fashion?
>
> I'd also want to backport this patch to the 0.94.x series so I could
> actually use it in production also :)
>
> I do see the ComparatorProtos (and the various .proto files) in the
> hbase-protocol submodule. Is there a trick to regenerating them? Do I just
> need to run protoc manually? Not an issue if that's the case. I wired up my
> Maven pom in an internal project to call protoc for me during a build.
>
> Thanks,
>
> Rob
>
> On Tue, Jul 2, 2013 at 4:42 PM, Ted Yu <yu...@gmail.com> wrote:
>
> > From HRegionServer#mutate(), you can find:
> >
> >           CompareOp compareOp =
> > CompareOp.valueOf(condition.getCompareType().name());
> >
> >           ByteArrayComparable comparator =
> >
> >             ProtobufUtil.toComparator(condition.getComparator());
> >
> > ...
> >
> >             boolean result = region.checkAndMutate(row, family,
> >
> >               qualifier, compareOp, comparator, put, true);
> >
> > WritableByteArrayComparator is no longer used.
> >
> > Cheers
> > On Tue, Jul 2, 2013 at 4:11 PM, Rob Roland <ro...@simplymeasured.com>
> wrote:
> >
> > > Hi,
> > >
> > > I see that in HBASE-3468, we gained the ability to do a checkAndPut
> with
> > a
> > > comparator, but it doesn't look straightforward to use from a client
> > > perspective.
> > >
> > > I'd like to create/submit a patch that would do the following:
> > >
> > > Add new WritableByteArrayComparator instances - LongComparator,
> > > IntComparator, DoubleComparator, FloatComparator, ShortComparator,
> > > StringComparator. Pretty much helpers for everything that the Bytes
> class
> > > can convert to a byte[].
> > >
> > > Add a method to HTableInterface / HTable:
> > >
> > >     boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
> > >                         final CompareFilter.CompareOp compareOp,
> > >                         final WritableByteArrayComparable comparator,
> > >                         Put put) throws IOException;
> > >
> > > and the corresponding delete:
> > >
> > >     boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
> > >                         final CompareFilter.CompareOp compareOp,
> > >                         final WritableByteArrayComparable comparator,
> > >                         Delete delete) throws IOException;
> > >
> > > Before I get started on that, have I missed anything?
> > >
> > > I'm looking at the code in trunk and it's a bit different than the last
> > > time I submitted a patch, so this is going to take a bit. :)
> > >
> > > Thanks,
> > >
> > > Rob Roland
> > >
> >
>

Re: checkAndPut with comparators

Posted by Rob Roland <ro...@simplymeasured.com>.
Ahh, okay. Sounds like the rest still applies, though, with wanting to
expose this to the client APIs in an easier-to-use fashion?

I'd also want to backport this patch to the 0.94.x series so I could
actually use it in production also :)

I do see the ComparatorProtos (and the various .proto files) in the
hbase-protocol submodule. Is there a trick to regenerating them? Do I just
need to run protoc manually? Not an issue if that's the case. I wired up my
Maven pom in an internal project to call protoc for me during a build.

Thanks,

Rob

On Tue, Jul 2, 2013 at 4:42 PM, Ted Yu <yu...@gmail.com> wrote:

> From HRegionServer#mutate(), you can find:
>
>           CompareOp compareOp =
> CompareOp.valueOf(condition.getCompareType().name());
>
>           ByteArrayComparable comparator =
>
>             ProtobufUtil.toComparator(condition.getComparator());
>
> ...
>
>             boolean result = region.checkAndMutate(row, family,
>
>               qualifier, compareOp, comparator, put, true);
>
> WritableByteArrayComparator is no longer used.
>
> Cheers
> On Tue, Jul 2, 2013 at 4:11 PM, Rob Roland <ro...@simplymeasured.com> wrote:
>
> > Hi,
> >
> > I see that in HBASE-3468, we gained the ability to do a checkAndPut with
> a
> > comparator, but it doesn't look straightforward to use from a client
> > perspective.
> >
> > I'd like to create/submit a patch that would do the following:
> >
> > Add new WritableByteArrayComparator instances - LongComparator,
> > IntComparator, DoubleComparator, FloatComparator, ShortComparator,
> > StringComparator. Pretty much helpers for everything that the Bytes class
> > can convert to a byte[].
> >
> > Add a method to HTableInterface / HTable:
> >
> >     boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
> >                         final CompareFilter.CompareOp compareOp,
> >                         final WritableByteArrayComparable comparator,
> >                         Put put) throws IOException;
> >
> > and the corresponding delete:
> >
> >     boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
> >                         final CompareFilter.CompareOp compareOp,
> >                         final WritableByteArrayComparable comparator,
> >                         Delete delete) throws IOException;
> >
> > Before I get started on that, have I missed anything?
> >
> > I'm looking at the code in trunk and it's a bit different than the last
> > time I submitted a patch, so this is going to take a bit. :)
> >
> > Thanks,
> >
> > Rob Roland
> >
>

Re: checkAndPut with comparators

Posted by Ted Yu <yu...@gmail.com>.
>From HRegionServer#mutate(), you can find:

          CompareOp compareOp =
CompareOp.valueOf(condition.getCompareType().name());

          ByteArrayComparable comparator =

            ProtobufUtil.toComparator(condition.getComparator());

...

            boolean result = region.checkAndMutate(row, family,

              qualifier, compareOp, comparator, put, true);

WritableByteArrayComparator is no longer used.

Cheers
On Tue, Jul 2, 2013 at 4:11 PM, Rob Roland <ro...@simplymeasured.com> wrote:

> Hi,
>
> I see that in HBASE-3468, we gained the ability to do a checkAndPut with a
> comparator, but it doesn't look straightforward to use from a client
> perspective.
>
> I'd like to create/submit a patch that would do the following:
>
> Add new WritableByteArrayComparator instances - LongComparator,
> IntComparator, DoubleComparator, FloatComparator, ShortComparator,
> StringComparator. Pretty much helpers for everything that the Bytes class
> can convert to a byte[].
>
> Add a method to HTableInterface / HTable:
>
>     boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier,
>                         final CompareFilter.CompareOp compareOp,
>                         final WritableByteArrayComparable comparator,
>                         Put put) throws IOException;
>
> and the corresponding delete:
>
>     boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier,
>                         final CompareFilter.CompareOp compareOp,
>                         final WritableByteArrayComparable comparator,
>                         Delete delete) throws IOException;
>
> Before I get started on that, have I missed anything?
>
> I'm looking at the code in trunk and it's a bit different than the last
> time I submitted a patch, so this is going to take a bit. :)
>
> Thanks,
>
> Rob Roland
>