incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Teasdale <teasda...@gmail.com>
Subject Double ColumnType and comparing
Date Mon, 14 Mar 2011 00:36:24 GMT
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