Thanks Ryan, but I seem to be missing something then. It NPEs for me. When running against 0.89.20100726 and providing a null expected value I get the below stack trace (and works like a champ when I provide a byte[0]. I also don't see the transformation you're referring to in HTable.
(for reference, http://svn.apache.org/viewvc/hbase/branches/0.89.20100726/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?view=markup) java.io.IOException: java.io.IOException: java.lang.NullPointerException at org.apache.hadoop.hbase.regionserver.HRegionServer.convertThrowableToIOE(HRegionServer.java:845) at org.apache.hadoop.hbase.regionserver.HRegionServer.convertThrowableToIOE(HRegionServer.java:835) at org.apache.hadoop.hbase.regionserver.HRegionServer.checkAndMutate(HRegionServer.java:1754) at org.apache.hadoop.hbase.regionserver.HRegionServer.checkAndPut(HRegionServer.java:1773) at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.apache.hadoop.hbase.ipc.HBaseRPC$Server.call(HBaseRPC.java:576) at org.apache.hadoop.hbase.ipc.HBaseServer$Handler.run(HBaseServer.java:919) Caused by: java.lang.NullPointerException at org.apache.hadoop.hbase.regionserver.HRegion.checkAndMutate(HRegion.java:1616) at org.apache.hadoop.hbase.regionserver.HRegionServer.checkAndMutate(HRegionServer.java:1751) ... 6 more On Sat, Aug 14, 2010 at 6:34 PM, Ryan Rawson <[email protected]> wrote: > Nulls end up being transformed into byte[0] in HTable and all is well. > > On Aug 14, 2010 6:33 PM, "John Beatty" <[email protected]> wrote: >> There appears to be a disconnect between the API [1] and the >> implementation [2] of checkAndPut() regarding the expected value >> parameter when the caller wants to make the put conditional on the row >> not existing. The javadoc states that the caller should use a null >> expected value for this purpose, whereas the implementation is >> checking for a 0-length byte[]. If a null expected value is given, >> checkAndPut() will NPE; see HRegion.java:1520 in trunk. >> >> I believe that null, rather than 0-length byte[], should be used for >> requiring row non-existence in checkAndPut(). Besides seeming like the >> right API, a 0-length byte[] is technically a valid row key (and least >> for a little put/get test I did; I found this surprising). >> >> Thoughts? >> >> john >> >> [1] > http://hbase.apache.org/docs/r0.89.20100726/apidocs/org/apache/hadoop/hbase/ipc/HRegionInterface.html#checkAndPut(byte[] > , >> byte[], byte[], byte[], byte[], org.apache.hadoop.hbase.client.Put) >> >> [2] > http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?view=markup >> -- line 1520 >
