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
Vinod:
Are you able to generate trunk patch for your test ?

Please refer to http://wiki.apache.org/hadoop/Hbase/HowToContribute

Please add license header and remove the following:

 * Created with IntelliJ IDEA.
 * User: vinodvr
 * Date: 26/5/13
 * Time: 7:07 PM

On Sun, May 26, 2013 at 8:02 AM, Vinod V <[EMAIL PROTECTED]> wrote:

> Thanks Ted,
>
> Created a JIRA with attached test case.
>
> https://issues.apache.org/jira/browse/HBASE-8626
>
>
> On Sun, May 26, 2013 at 6:05 PM, Ted Yu <[EMAIL PROTECTED]> wrote:
>
> > There is TestAtomicOperation.java in the code base but obviously it
> doesn't
> > cover your use case.
> >
> > I assume you are using 0.94.x
> > I put your test case
> > in
> >
> src/test/java/org/apache/hadoop/hbase/regionserver/TestHBaseRowMutations.java
> > but found that the test didn't start a cluster.
> > Therefore it got stuck here:
> > at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:126)
> >
> > Do you mind opening a JIRA and attach your test there ?
> >
> > Thanks
> >
> > On Sun, May 26, 2013 at 3:31 AM, Vinod V <[EMAIL PROTECTED]> wrote:
> >
> > > Below is a test case describing the issues I am facing when doing the
> > > following RowMutations:
> > >
> > > 1. Delete a column family of a row
> > > 2. Put new columns and values to the same column family of same row
> > >
> > > Seems like the column family gets deleted fine but the Puts do not
> happen
> > > even though they are part of the same row mutation.
> > >
> > > import junit.framework.Assert;
> > > import org.apache.hadoop.conf.Configuration;
> > > import org.apache.hadoop.hbase.HBaseConfiguration;
> > > import org.apache.hadoop.hbase.HColumnDescriptor;
> > > import org.apache.hadoop.hbase.HTableDescriptor;
> > > import org.apache.hadoop.hbase.TableExistsException;
> > > import org.apache.hadoop.hbase.client.*;
> > > import org.apache.hadoop.hbase.util.Bytes;
> > > import org.junit.Before;
> > > import org.junit.BeforeClass;
> > > import org.junit.Test;
> > >
> > > import java.util.NavigableMap;
> > >
> > > public class TestHBaseRowMutations {
> > >     static String tableName = "nnn";
> > >     static byte[] cf1 = Bytes.toBytes("cf1");
> > >     static byte[] row = Bytes.toBytes("r1");
> > >     static HTablePool hTablePool;
> > >
> > >     @BeforeClass
> > >     public static void beforeClass() throws Exception {
> > >         Configuration config = HBaseConfiguration.create();
> > >         hTablePool = new HTablePool(config, Integer.MAX_VALUE);
> > >         HBaseAdmin admin = new HBaseAdmin(config);
> > >         HTableDescriptor tableDescriptor = new
> > HTableDescriptor(tableName);
> > >         tableDescriptor.addFamily(new HColumnDescriptor(cf1));
> > >         try {
> > >             admin.createTable(tableDescriptor);
> > >         } catch (TableExistsException ignored){}
> > >     }
> > >
> > >     @Before
> > >     public void before() throws Exception {
> > >         HTableInterface table = hTablePool.getTable(tableName);
> > >         try {
> > >             Delete delete = new Delete(row);
> > >             table.delete(delete);
> > >             System.out.println("deleted old row");
> > >
> > >             Put put = new Put(row);
> > >             put.add(cf1, Bytes.toBytes("c1"), Bytes.toBytes("v1"));
> > >             put.add(cf1, Bytes.toBytes("c11"), Bytes.toBytes("v11"));
> > >             table.put(put);
> > >             System.out.println("Created row with seed data");
> > >         } finally {
> > >             table.close();
> > >         }
> > >     }
> > >
> > >
> > >     @Test
> > >     public void testColumnFamilyDeleteRM() throws Exception {
> > >         HTableInterface table = hTablePool.getTable(tableName);
> > >         try {
> > >             RowMutations rm =new RowMutations(row);
> > >
> > >             //delete column family cf1
> > >             Delete delete = new Delete(row);
> > >             delete.deleteFamily(cf1);
> > >             rm.add(delete);
> > >             System.out.println("Added delete of cf1 column family to