incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: Double ColumnType and comparing
Date Mon, 14 Mar 2011 01:52:33 GMT
There is nothing in the 0.8 trunk to add double support. 

Could you shift the decimal point and use ints / longs ? Double is not a precise type, so
there is a possibility of the value changing as it's serialised and deserialised around. 

You were on the right track with extending abstract type. You would also need to work out
a precise binary representation for the numbers.

Hope that helps. 
Aaron
On 14 Mar 2011, at 13:36, Paul Teasdale wrote:

> I am quite new to Cassandra and am trying to model a simple Column Family which uses
Doubles as column names:
> 
> Datalines: { // ColumnFamilly
> 	dataline-1:{ // row key
> 		23.5: 'someValue',
> 		23.6: 'someValue',
> 		...
>                4334.99: 'someValue'
> 	},
> 	dataline-2:{
> 		10.5: 'someValue',
> 		12.6: 'someValue',
> 		...
>                23334.99: 'someValue'
> 	},
> 	...
> 	dataline-n:{
> 	10.5: 'someValue',
> 		12.6: 'someValue',
> 		...
>                23334.99: 'someValue'
>           }
> }
> 
> In declaring this column family, I need to specify a 'CompareWith' attribute for a Double
type, but the only available values I found for this attribute are:
> 	
>  * BytesType
>  * AsciiType
>  * UTF8Type
>  * LongType
>  * LexicalUUIDType
>  * TimeUUIDType
> 
> Is there any support anywere for double values (there has to be something)? And if not,
does this mean we need to extend  org.apache.cassandra.db.marshal.AbstractType<Double>?
> 
> package  com.mycom.types;
> 
> class  DoubleType extends org.apache.cassandra.db.marshal.AbstractType<Double>
{
>      public int compare(ByteBuffer o1, ByteBuffer o2){
>        // trivial implementation         
>            Double d1  = o1.getDouble(0);
> 	   Double d2 = o2.getDoube(0);
> 	   return d1.compareTo(d2);
>      }		
>      //...
> }
> 
> And declare the column family:
> 
> <ColumnFamily CompareWith="<com.mycom.types.DoubleType>" Name="Datalines"/>
> 
> Thanks,
> Paul
> 
> 
> 
> 
> 
> 
> 


Mime
View raw message