Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

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


+
Vinod V 2013-05-25, 23:53
+
Vinod V 2013-05-26, 10:31
Copy link to this message
-
Re: Using RowMutations to replace all columns of a row
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 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,
+
Vinod V 2013-05-26, 15:02
+
Ted Yu 2013-05-26, 15:54
+
Vinod V 2013-05-26, 17:11
+
Ted Yu 2013-05-28, 14:42
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB