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 >> Using doubles and longs as ordering row values


Copy link to this message
-
Re: Using doubles and longs as ordering row values
Have a look at the lily library. It has code to encode Longs/Doubles into bytes such that resulting bytes sort as expected based on the numbers.

-- Lars

________________________________
 From: Jonathan Bishop <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Sent: Monday, November 5, 2012 10:41 AM
Subject: Using doubles and longs as ordering row values
 
Hi,

In my application my row values are doubles. I would like my scans to
traverse the rows in order of increasing values.

But if I simply use

double d  = ....
byte[] row = Bytes.toBytes(d);

I will get an ordering which is based on the byte values of doubles, not on
the value of the doubles themselves.

I see also that integer values have the same issue due to the first bit
being the sign bit. So negative values will come after positive values.

Any suggestions?

Thanks,

Jon
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