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 Threaded View
HBase >> mail # user >> Scanning half a key or value in HBase


Copy link to this message
-
Re: Scanning half a key or value in HBase
2010/8/17 Ryan Rawson <[EMAIL PROTECTED]>:
> Hey,
>
>
> If you are scanning fixed-width keys, eg: binary conversions of longs,
> then the [start,start+1) solution works.
>

Why? It will work for any byte array, if we want to prefix scan. And no matter,
what key encoding we use.

If we look at first email question, we see '<first_half_of_key>%', so
if first_half_of_key = 'foo'
we _should_ get all keys foo, foo:, foo1234, because we want this.

My solution was to convert requested first_half_of_key to byte[] arr = ...
Then do  (pseudocode)
arr = toBytes(first_half_of_key)
arr2 = arr.clone(),
arr2[arr2.length-1]++,
STARTROW = arr,
STOPROW = arr2;

This gives us real stop key, which will be greater, then any key,
prefixed with given prefix
(due of nature of binary comparators, used by hbase).

Or I missed something ?
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