Cool.

Everything is already available.
I simply have to import MD5Hash and use the to_java_bytes ruby function.

hbase(main):001:0> import org.apache.hadoop.hbase.util.MD5Hash
=> Java::OrgApacheHadoopHbaseUtil::MD5Hash
hbase(main):002:0> put 'test', MD5Hash.getMD5AsHex('row1'.to_java_bytes), 'cf:a', 'value1'
0 row(s) in 0.5880 seconds
hbase(main):004:0> get 'test', 'row1'
COLUMN                                           CELL
0 row(s) in 0.0170 seconds
hbase(main):003:0> get 'test', MD5Hash.getMD5AsHex('row1'.to_java_bytes)
COLUMN                                           CELL
cf:a timestamp=1300287899911, value=value1
1 row(s) in 0.0840 seconds

Many tks,

Eric


On 16/03/2011 15:44, Harsh J wrote:
Using Java classes itself is possible from within HBase shell (since
it is JRuby), but yes some Ruby knowledge should be helpful too!

For instance, I can use java.lang.String by simply importing it:

hbase(main):004:0>  import java.lang.String
=>  Java::JavaLang::String
hbase(main):004:0>  get String.new('test'), String.new('row1')
COLUMN                                 CELL

  f:a                                   timestamp=1300170063837, value=val4

1 row(s) in 0.0420 seconds

On Wed, Mar 16, 2011 at 4:26 PM, Eric Charles
<eric.char...@u-mangate.com>  wrote:
Hi,
I understand from your answer that it's possible but not available.
Did anyone already implemented such a functionality?
If not, where should I begin to look at (hirb.rb, any tutorial,... ?) - I
know nothing about jruby.
Tks,
- Eric

On 16/03/2011 10:39, Harsh J wrote:
(For 2) I think the hash function should work in the shell if it
returns a string type (like what '' defines in-place).

On Wed, Mar 16, 2011 at 2:22 PM, Eric Charles
<eric.char...@u-mangate.com>    wrote:
Hi,

To help avoid hotspots, I'm planning to use hashed keys in some tables.

1. I wonder if this strategy is adviced for range queries (from/to key)
use
case, because the rows will be randomly distributed in different regions.
Will it cause some performance loose?
2. Is it possible to query from hbase shell with something like "get
't1',
@hash('r1')", to let the shell compute the hash for you from the readable
key.
3. There are MD5 and Jenkins classes in hbase.util package. What would
you
advice? what about SHA1?

Tks,
- Eric

PS: I searched the archive but didn't find the answers.







Reply via email to