hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From java8964 <java8...@hotmail.com>
Subject Why the put without column in batch doesn't generate any error
Date Mon, 24 Feb 2014 01:25:01 GMT
Hi, 
I found some inconsistent behavior in the HBase, and wonder why.
In the simple Put API call, if there is no content at all with this put, the local side of
the client will throw IllegalArgumentException: No columns to insert to failed the put, as
shown in the example of Lars George Book "HBase: The Definitive Guide, page 92, Example 3-6".
This is a reasonable behavior.
What confuses me is if this happen in a Batch operation, there is no exception throw out in
this case, worst of all, the corresponding result will contain the None keyvalue instance,
which represents successful operation for 'Put' operation. This is kind of inconsistent.
In the following example code running on HBase 0.94.16:
hbase(main):003:0> create 'mydevtable', 'colfam1', 'colfam2'0 row(s) in 1.1620 seconds

        List<Row> batch = new ArrayList<Row>();
        Put put = new Put(Bytes.toBytes("row2"));        put.add(Bytes.toBytes("colfam2"),
Bytes.toBytes("qual1"), Bytes.toBytes("val5"));        batch.add(put);
        Get get1 = new Get(Bytes.toBytes("row1"));        get1.addColumn(Bytes.toBytes("colfam1"),
Bytes.toBytes("qual1"));        batch.add(get1);
        Delete delete = new Delete(Bytes.toBytes("row1"));        delete.deleteColumns(Bytes.toBytes("colfam1"),
Bytes.toBytes("qual2"));        batch.add(delete);
        Put put2 = new Put(Bytes.toBytes("row2"));        batch.add(put2);
        Object[] results = new Object[batch.size()];        try {            table.batch(batch,
results);        } catch (Exception e) {            System.err.println("Error: " + e);   
    }
        for (int i = 0; i < results.length; i++) {            System.out.println("Result["
+ i + "]: " + results[i]);        }
        table.close();
For put2, I expect an Exception should be throw, but no. At least the corresponding Result
object in the array for it should tell me this is a invalid Put, but still nothing. 
here is the output of running above code:
Result[0]: keyvalues=NONEResult[1]: keyvalues=NONEResult[2]: keyvalues=NONEResult[3]: keyvalues=NONE
Process finished with exit code 0
Any thoughts?
Thanks
Yong
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message