hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "@Sanjiv Singh" <sanjiv.is...@gmail.com>
Subject Writing Custom - KeyComparator !!!
Date Wed, 27 Aug 2014 10:09:46 GMT
Hi All,

As we know,  All rows are always sorted lexicographically by their row key.
In lexicographical order, each key is compared at binary level, byte by
byte and from left to right.

See the example below , where row key is some integer value and output of
scan show lexicographical order of rows in table.

hbase(main):001:0> scan 'table1'
1               column=cf1:, timestamp=1297073325971 ...
11             column=cf 1:, timestamp=1297073337383 ...
11000        column=cf1 :, timestamp=1297073340493 ...
2               column=cf1:, timestamp=1297073329851 ...
22             column=cf1:, timestamp=1297073344482 ...
22000        column=cf1:, timestamp=1297073333504 ...
23             column=cf1:, timestamp=1297073349875 ...

I want to see these rows ordered as integer, not the default way. I can pad
keys with '0' to get a proper sorting order(i don't like it).

I wanted to see these rows sorted as integer , not just as output of scan
OR get method , but also to store rows with consecutive integer row keys in
same block.

Now the question is :

   - Can we define our own custom KeyComparator ?
   - If Yes , can we enforce it for PUT method ?  so that rows would be
   stored as new KeyComparator.
   - Can we plug this comparator duriong SCAN method to change order of
   result rows ?

Hope, i have explained the proplem well,  seeking for your valuable
response on it.

Sanjiv Singh
Mob :  +091 9990-447-339

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