Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Using RowMutations to replace all columns of a row

Copy link to this message
Re: Using RowMutations to replace all columns of a row
Over in HBASE-8626, Jean-Marc and Andrew voiced the opinion that the
current behavior may not be a bug.


What do you think ?

On Sat, May 25, 2013 at 4:53 PM, Vinod V <[EMAIL PROTECTED]> wrote:

> I have a HBase table with a single column family and columns are added to
> it over time. These columns are named as the timestamp they were created,
> so unless I query the row I do not know what all columns it has.
> Now given a row, I want to _atomically_ remove all the existing columns of
> this column family and add a new set of columns and values.
> So I thought of using RowMutations like:
> =============> RowMutations mutations = new RowMutations(row);
> //delete the column family
> Delete delete = new Delete(row);
> delete.deleteFamily(cf);
> //add new columns
> Put put = new Put(row);
> put.add(cf, col1, v1);
> put.add(cf, col2, v2);
> //delete column family and add new columns to same family
> mutations.add(delete);
> mutations.add(put);
> table.mutateRow(mutations);
> =============>
> But what this code ends up doing is just deleting the column family, it
> does not add the new columns. Is this behaviour expected?
> If so, then how can I achieve my goal of _atomically_ replacing all columns
> of a column family with a new set of columns?
> Thanks,
> Vinod