You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by java8964 <ja...@hotmail.com> on 2014/02/24 02:25:01 UTC

Why the put without column in batch doesn't generate any error

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
 		 	   		  

Re: Why the put without column in batch doesn't generate any error

Posted by Ted Yu <yu...@gmail.com>.
I logged HBASE-10600 for this issue.

Cheers


On Sun, Feb 23, 2014 at 7:48 PM, Ted Yu <yu...@gmail.com> wrote:

> In 0.94, HConnectionManager#HConnectionImplementation#processBatch(),
> there is no validity check on the individual element in the list.
> In trunk, there is similar issue.
>
> Cheers
>
>
> On Sun, Feb 23, 2014 at 7:25 PM, java8964 <ja...@hotmail.com> wrote:
>
>> 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
>>
>
>
>

Re: Why the put without column in batch doesn't generate any error

Posted by Ted Yu <yu...@gmail.com>.
In 0.94, HConnectionManager#HConnectionImplementation#processBatch(), there
is no validity check on the individual element in the list.
In trunk, there is similar issue.

Cheers


On Sun, Feb 23, 2014 at 7:25 PM, java8964 <ja...@hotmail.com> wrote:

> 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
>