hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: Using RowMutations to replace all columns of a row
Date Sun, 26 May 2013 15:54:12 GMT
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 <vinodv26@gmail.com> 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 <yuzhihong@gmail.com> 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 <vinodv26@gmail.com> 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
> row
> > > mutation");
> > >
> > >             //add new columns to same column family cf1
> > >             Put put = new Put(row);
> > >             put.add(cf1, Bytes.toBytes("c1"), Bytes.toBytes("new_v1"));
> > >             put.add(cf1, Bytes.toBytes("c11"),
> Bytes.toBytes("new_v11"));
> > >             rm.add(put);
> > >             System.out.println("Added puts of cf1 column family to row
> > > mutation");
> > >
> > >             //atomic mutate the row
> > >             table.mutateRow(rm);
> > >             System.out.println("Mutated row");
> > >
> > >             //now read the column family cf1 back
> > >             Result result = table.get(new Get(row));
> > >             NavigableMap<byte[], byte[]> familyMap =
> > > result.getFamilyMap(cf1);
> > >
> > >             *//column family cf1 should have 2 columns because of the
> Put
> > > above
> > >             //------Following assert fails as cf1 does not exist
> anymore,
> > > why does cf1 not exist anymore?-------
> > >             Assert.assertNotNull(familyMap);*
> > >             Assert.assertEquals(2, familyMap.size());
> > >         } finally {
> > >             table.close();
> > >         }
> > >     }
> > >
> > > }
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://apache-hbase.679495.n3.nabble.com/Using-RowMutations-to-replace-all-columns-of-a-row-tp4045247p4045263.html
> > > Sent from the HBase User mailing list archive at Nabble.com.
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message