incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Boxenhorn <da...@taotown.com>
Subject Re: Double ColumnType and comparing
Date Mon, 14 Mar 2011 13:52:29 GMT
I you do it, I'd recommend BigDecimal. It's an exact type, and usually what
you want.

On Mon, Mar 14, 2011 at 3:40 PM, Jonathan Ellis <jbellis@gmail.com> wrote:

> We'd be happy to commit a patch contributing a DoubleType.
>
> On Sun, Mar 13, 2011 at 7:36 PM, Paul Teasdale <teasdalep@gmail.com>
> 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
> >
> >
> >
> >
> >
> >
> >
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of DataStax, the source for professional Cassandra support
> http://www.datastax.com
>

Mime
View raw message