hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lars hofhansl <lhofha...@yahoo.com>
Subject Re: Using doubles and longs as ordering row values
Date Tue, 06 Nov 2012 00:01:42 GMT
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 <jbishop.rwc@gmail.com>
To: "user@hbase.apache.org" <user@hbase.apache.org> 
Sent: Monday, November 5, 2012 10:41 AM
Subject: Using doubles and longs as ordering row values

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?


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