FAQ
Hello.

I'm testing hbase transaction module. but it's little bit strange.

Can I delete a row all (with all family,columns and key also) ?

This transaction code is

Delete : delete row
Put : recreate same row key.
commit : ok do it.

but, I couldn't get new row data.

Is there the way recreate row key in transaction mode ?

I have another question.

If I use transaction, is it row locking or table locking ??

======================================================

My transaction class, is written as followed:

public void testTransaction() throws IOException {
// byte[] key0 = Bytes.toBytes("key-29");
byte[] key = Bytes.toBytes("key-30");
getRow(key);
TransactionManager tran = new TransactionManager(config);
TransactionState state=null;
TransactionalTable table = null;
try{
// table locking.
state = tran.beginTransaction();
table = new TransactionalTable(config,TABLE);
table.setAutoFlush(false);
Delete del = new Delete(key); // delete row with all families.
table.delete(state,del);
Get get = new Get(key);
Result result = table.get(state,get);
log.debug("result={}",result);
Put p = new Put(key);
p.add(COL_FAMILY_USER_B, ("name").getBytes(), ("macula500").getBytes());
p.add(COL_FAMILY_USER_B, ("age").getBytes(), ("500").getBytes());

table.put(state,p);
tran.tryCommit(state); // prepare & do commit.
log.debug("transaction test finished.");
}catch(Exception e){
e.printStackTrace();
if(tran!=null) tran.abort(state);
log.debug("transaction commit failed.");
} finally{
if(table!=null) table.close();
}
// getRow(key0);
getRow(key);
}

Thanks.
Tost

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categorieshbase, hadoop
postedJan 11, '11 at 12:53a
activeJan 11, '11 at 12:53a
posts1
users1
websitehbase.apache.org

1 user in discussion

Tost: 1 post

People

Translate

site design / logo © 2019 Grokbase