hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Stein <charmal...@allthingshadoop.com>
Subject Re: checkAndPut behavior question
Date Wed, 28 Dec 2011 03:13:39 GMT
sure, of course

the sample code I am using (
https://github.com/dolhana/hbase-scala-sample/blob/master/src/main/scala/me/handol/scala/HBaseSample.scala
)
has this up at the top

val admin = new HBaseAdmin(conf)
if (admin.tableExists("mytable"))
   admin.disableTable("mytable")
admin.deleteTable("mytable")

so while I am implementing checkAndPut myself hacking on the existing
sample code when the app starts again it first deleted the table (so it is
not there when it runs the first time and always re-creates it)

once I stopped deleting the table ... and creating it

then all was well =8^/ checkAndPut always sees the value there

On Tue, Dec 27, 2011 at 9:42 PM, Harsh J <harsh@cloudera.com> wrote:

> Hey Joe,
>
> Perhaps in spirit of http://xkcd.com/979/ you'd like to share the answer
> as well, for folks who won't immediately understand what the problem was? :)
>
> On 28-Dec-2011, at 3:37 AM, Joe Stein wrote:
>
> > figured this one out too, never mind.
> >
> > hoping to publish a getting started for scala devs with relative
> functions
> > in a tes framework and the rest, lowering the curve to getting going
> >
> > cheers
> >
> > On Tue, Dec 27, 2011 at 3:50 PM, Joe Stein
> > <charmalloc@allthingshadoop.com>wrote:
> >
> >> So I have this code which when runs is doing what I expect from a new
> row
> >>
> >>    val table = new HTable(conf, "mytable")
> >>
> >>    val theput= new Put(Bytes.toBytes("rowkey1"))
> >>
> >>
> >>
> theput.add(Bytes.toBytes("ids"),Bytes.toBytes("id2"),Bytes.toBytes("one"))
> >>
> >>    println("check and put 1" +
> >>
> table.checkAndPut(Bytes.toBytes("rowkey1"),Bytes.toBytes("ids"),Bytes.toBytes("id2"),null,theput))
> >>
> >>    println("check and put 2" +
> >>
> table.checkAndPut(Bytes.toBytes("rowkey1"),Bytes.toBytes("ids"),Bytes.toBytes("id2"),null,theput))
> >>
> >> check and put 1true
> >> check and put 2false
> >>
> >> when I run my test app again, I would expect false and false (since the
> >> row already has the column there)
> >>
> >> check and put 1true
> >> check and put 2false
> >>
> >> I don't understand I thought it would be
> >>
> >> check and put 1false
> >> check and put 2false
> >>
> >> hbase(main):012:0> scan 'mytable'
> >> ROW                                                 COLUMN+CELL
> >>
> >>
> >> rowkey1                                            column=ids:id2,
> >> timestamp=1325018846038, value=one
> >>
> >> 1 row(s) in 1.1010 seconds
> >>
> >>
> >> --
> >>
> >> /*
> >> Joe Stein
> >> http://www.linkedin.com/in/charmalloc
> >> Twitter: @allthingshadoop <http://twitter.com/#!/allthingshadoop>
> >> */
> >>
> >
> >
> >
> > --
> >
> > /*
> > Joe Stein
> > http://www.linkedin.com/in/charmalloc
> > Twitter: @allthingshadoop <http://twitter.com/#!/allthingshadoop>
> > */
>
>


-- 

/*
Joe Stein
http://www.linkedin.com/in/charmalloc
Twitter: @allthingshadoop <http://twitter.com/#!/allthingshadoop>
*/

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