hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Brown <tombrow...@gmail.com>
Subject Re: Using put for nullifying qualifiers
Date Wed, 23 May 2012 13:39:49 GMT
I didn't mean to set the version to null, I meant to include a revision of
the column whose contents are empty. This empty revision will Still be
returned by any gets on that row, but you can put code into your client
that treats empty values as deleted.

It's a bit of a hack, but it's the best I can come up with.

--Tom

On Wednesday, May 23, 2012, Kristoffer Sjögren wrote:

> Ted: Awesome. I can think of several use cases where this is useful, but im
> pretty stuck on 0.92 right now.
>
> I tried the null-version trick but must be doing something wrong. How do I
> set version to null on a column? Isnt version equal to the timestamp
> (primitive long)?
>
> Setting timestamp to 0 and -1 doesnt work it seems.
>
> HTable t = new HTable(tablename);
> Put p = new Put(r1);
> KeyValue kv1 = new KeyValue(r1, c1, c1, new byte[]{1});
> KeyValue kv2 = new KeyValue(r1, c2, c2, new byte[]{1});
> p.add(kv1);
> p.add(kv2);
> t.put(p);
> t.flushCommits();
> Result res = t.get(new Get(r1));
> byte[] v1 = res.getValue(c1, c1);
> byte[] v2 = res.getValue(c2, c2);
> System.out.println("v1 " + v1[0] + " v2 " + v2[0]);
>
> kv1 = new KeyValue(r1, c1, c1, -1, new byte[]{1});
> p = new Put(r1);
> p.add(kv1);
> t.put(p);
> res = t.get(new Get(r1));
> v1 = res.getValue(c1, c1);
> v2 = res.getValue(c2, c2);
> System.out.println("v1 " + v1[0] + " v2 " + v2[0]);
>
> This prints:
> v1 1 v2 1
> v1 1 v2 1
>
> Any advice?
>
>
> On Tue, May 22, 2012 at 10:45 PM, Ted Yu <yuzhihong@gmail.com<javascript:;>>
> wrote:
>
> > That's right.
> >
> > In HBase 0.94 and trunk, check out the following API in HRegion:
> >  public void mutateRowsWithLocks(Collection<Mutation> mutations,
> >      Collection<byte[]> rowsToLock) throws IOException {
> >
> > It allows you to combine Put's and Delete's for a single region,
> > atomically.
> >
> > On Tue, May 22, 2012 at 1:22 PM, Kristoffer Sjögren <stoffe@gmail.com<javascript:;>
> > >wrote:
> >
> > > Thanks, sounds like that should do it.
> > >
> > > So im guessing it is correct to assume that _all_ KeyValues added to a
> > > _single_ Put operation will either wholely succeed or wholely fail as
> > long
> > > as they belong to the same row?
> > >
> > > On Tue, May 22, 2012 at 8:30 PM, Tom Brown <tombrown52@gmail.com<javascript:;>>
> wrote:
> > >
> > > > I don't think you can include a delete with a put and keep it atomic.
> > > > You could include a null version of the column with your put, though,
> > > > for a similar effect.
> > > >
> > > > --Tom
> > > >
> > > > On Tue, May 22, 2012 at 10:55 AM, Kristoffer Sjögren <
> stoffe@gmail.com <javascript:;>
> > >
> > > > wrote:
> > > > > Hi
> > > > >
> > > > > I'm trying to use Put operations to replace ("set") already
> existing
> > > rows
> > > > > by nullify certain columns and qualifiers as part of an Put
> > operation.
> > > > >
> > > > > The reason I want to do this is 1) keep the operation
> > atomic/consistent
> > > > 2)
> > > > > avoid latency from first doing Delete then Put.
> > > > >
> > > > > Is there some way to do this kind of operation?
> > > > >
> > > > > Cheers,
> > > > > -Kristoffer
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message