You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Sameer Farooqui <ca...@gmail.com> on 2011/07/18 23:16:13 UTC

Is there a way to read a Double value from the CLI?

I wrote some data to a standard column family (using Hector) with ASCII
row-key, Long column name and Double column value.

The CLI doesn't seem to have a double data type to interpret the column
value for display.

[default@DemoKS] get DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
as LongType;
=> (column=0000124597556740, value=4629084924887308954,
timestamp=1310144024947000)

But that value is not exactly correct. It should be: 29.813332976331914


This is how I do the read in Hector:

        ColumnQuery<String, Long, Double> columnQuery =
HFactory.createColumnQuery(keyspace, ss, ls, ds);


columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);

        QueryResult<HColumn<Long, Double>> result = columnQuery.execute();

        System.out.println("Query result: " + result.get());


Is there a equivalent for that in Cassandra CLI?

- Sameer

Re: Is there a way to read a Double value from the CLI?

Posted by Sameer Farooqui <ca...@gmail.com>.
k, thanks for the clarification Nate.


On Tue, Jul 19, 2011 at 10:14 AM, Nate McCall <na...@datastax.com> wrote:

> The DoubleSerializer in Hector predates Cassandra's DoubleType and was
> thus designed to stick values in a LongType or BytesType comparator.
> Because of this, we are calling Double.doubleToRawLongBits and
> Double.longBitsToDouble underneath, so this may not be what you
> expect.
>
> I'll add another serializer(s) for the new set of types.
>
> Now if only we had a client mailing list to which client-impacting
> changes could be sent ...  :-)
>
> On Mon, Jul 18, 2011 at 4:50 PM, Jonathan Ellis <jb...@gmail.com> wrote:
> > org.apache.cassandra.db.marshal.DoubleType should work, then.  the
> > cast shouldn't be necessary if the doubletype is actually in the
> > schema either.
> >
> > On Mon, Jul 18, 2011 at 4:34 PM, Sameer Farooqui
> > <ca...@gmail.com> wrote:
> >> Yup, Jonathan, I was just temporarily returning the value as LongType
> b/c I
> >> couldn't find a DoubleType. Since LongType returned something, I know
> that
> >> the data is there.
> >>
> >> Thanks for that link, Jeremy. I'm guessing DoubleType hasn't found its
> way
> >> into the CLI yet, b/c I tried this and got an error:
> >>
> >> [default@DemoKS] get
> DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
> >> as DoubleType;
> >> Unknown comparator 'DoubleType'. Available functions: bytes, integer,
> long,
> >> lexicaluuid, timeuuid, utf8, ascii, countercolumn.
> >>
> >>
> >>
> >>
> >> On Mon, Jul 18, 2011 at 2:28 PM, Jonathan Ellis <jb...@gmail.com>
> wrote:
> >>>
> >>> "get X as LongType" will give you the bytes in that column value
> >>> interpreted as a long.
> >>>
> >>> So it did exactly what you asked it to do :)
> >>>
> >>> On Mon, Jul 18, 2011 at 4:16 PM, Sameer Farooqui
> >>> <ca...@gmail.com> wrote:
> >>> > I wrote some data to a standard column family (using Hector) with
> ASCII
> >>> > row-key, Long column name and Double column value.
> >>> >
> >>> > The CLI doesn't seem to have a double data type to interpret the
> column
> >>> > value for display.
> >>> >
> >>> > [default@DemoKS] get
> >>> > DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
> >>> > as LongType;
> >>> > => (column=0000124597556740, value=4629084924887308954,
> >>> > timestamp=1310144024947000)
> >>> >
> >>> > But that value is not exactly correct. It should be:
> 29.813332976331914
> >>> >
> >>> >
> >>> > This is how I do the read in Hector:
> >>> >
> >>> >         ColumnQuery<String, Long, Double> columnQuery =
> >>> > HFactory.createColumnQuery(keyspace, ss, ls, ds);
> >>> >
> >>> >
> >>> >
> >>> >
> columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);
> >>> >
> >>> >         QueryResult<HColumn<Long, Double>> result =
> >>> > columnQuery.execute();
> >>> >
> >>> >         System.out.println("Query result: " + result.get());
> >>> >
> >>> >
> >>> > Is there a equivalent for that in Cassandra CLI?
> >>> >
> >>> > - Sameer
> >>> >
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Jonathan Ellis
> >>> Project Chair, Apache Cassandra
> >>> co-founder of DataStax, the source for professional Cassandra support
> >>> http://www.datastax.com
> >>
> >>
> >
> >
> >
> > --
> > Jonathan Ellis
> > Project Chair, Apache Cassandra
> > co-founder of DataStax, the source for professional Cassandra support
> > http://www.datastax.com
> >
>

Re: Is there a way to read a Double value from the CLI?

Posted by Nate McCall <na...@datastax.com>.
The DoubleSerializer in Hector predates Cassandra's DoubleType and was
thus designed to stick values in a LongType or BytesType comparator.
Because of this, we are calling Double.doubleToRawLongBits and
Double.longBitsToDouble underneath, so this may not be what you
expect.

I'll add another serializer(s) for the new set of types.

Now if only we had a client mailing list to which client-impacting
changes could be sent ...  :-)

On Mon, Jul 18, 2011 at 4:50 PM, Jonathan Ellis <jb...@gmail.com> wrote:
> org.apache.cassandra.db.marshal.DoubleType should work, then.  the
> cast shouldn't be necessary if the doubletype is actually in the
> schema either.
>
> On Mon, Jul 18, 2011 at 4:34 PM, Sameer Farooqui
> <ca...@gmail.com> wrote:
>> Yup, Jonathan, I was just temporarily returning the value as LongType b/c I
>> couldn't find a DoubleType. Since LongType returned something, I know that
>> the data is there.
>>
>> Thanks for that link, Jeremy. I'm guessing DoubleType hasn't found its way
>> into the CLI yet, b/c I tried this and got an error:
>>
>> [default@DemoKS] get DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
>> as DoubleType;
>> Unknown comparator 'DoubleType'. Available functions: bytes, integer, long,
>> lexicaluuid, timeuuid, utf8, ascii, countercolumn.
>>
>>
>>
>>
>> On Mon, Jul 18, 2011 at 2:28 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>>
>>> "get X as LongType" will give you the bytes in that column value
>>> interpreted as a long.
>>>
>>> So it did exactly what you asked it to do :)
>>>
>>> On Mon, Jul 18, 2011 at 4:16 PM, Sameer Farooqui
>>> <ca...@gmail.com> wrote:
>>> > I wrote some data to a standard column family (using Hector) with ASCII
>>> > row-key, Long column name and Double column value.
>>> >
>>> > The CLI doesn't seem to have a double data type to interpret the column
>>> > value for display.
>>> >
>>> > [default@DemoKS] get
>>> > DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
>>> > as LongType;
>>> > => (column=0000124597556740, value=4629084924887308954,
>>> > timestamp=1310144024947000)
>>> >
>>> > But that value is not exactly correct. It should be: 29.813332976331914
>>> >
>>> >
>>> > This is how I do the read in Hector:
>>> >
>>> >         ColumnQuery<String, Long, Double> columnQuery =
>>> > HFactory.createColumnQuery(keyspace, ss, ls, ds);
>>> >
>>> >
>>> >
>>> > columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);
>>> >
>>> >         QueryResult<HColumn<Long, Double>> result =
>>> > columnQuery.execute();
>>> >
>>> >         System.out.println("Query result: " + result.get());
>>> >
>>> >
>>> > Is there a equivalent for that in Cassandra CLI?
>>> >
>>> > - Sameer
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Jonathan Ellis
>>> Project Chair, Apache Cassandra
>>> co-founder of DataStax, the source for professional Cassandra support
>>> http://www.datastax.com
>>
>>
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of DataStax, the source for professional Cassandra support
> http://www.datastax.com
>

Re: Is there a way to read a Double value from the CLI?

Posted by Jonathan Ellis <jb...@gmail.com>.
org.apache.cassandra.db.marshal.DoubleType should work, then.  the
cast shouldn't be necessary if the doubletype is actually in the
schema either.

On Mon, Jul 18, 2011 at 4:34 PM, Sameer Farooqui
<ca...@gmail.com> wrote:
> Yup, Jonathan, I was just temporarily returning the value as LongType b/c I
> couldn't find a DoubleType. Since LongType returned something, I know that
> the data is there.
>
> Thanks for that link, Jeremy. I'm guessing DoubleType hasn't found its way
> into the CLI yet, b/c I tried this and got an error:
>
> [default@DemoKS] get DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
> as DoubleType;
> Unknown comparator 'DoubleType'. Available functions: bytes, integer, long,
> lexicaluuid, timeuuid, utf8, ascii, countercolumn.
>
>
>
>
> On Mon, Jul 18, 2011 at 2:28 PM, Jonathan Ellis <jb...@gmail.com> wrote:
>>
>> "get X as LongType" will give you the bytes in that column value
>> interpreted as a long.
>>
>> So it did exactly what you asked it to do :)
>>
>> On Mon, Jul 18, 2011 at 4:16 PM, Sameer Farooqui
>> <ca...@gmail.com> wrote:
>> > I wrote some data to a standard column family (using Hector) with ASCII
>> > row-key, Long column name and Double column value.
>> >
>> > The CLI doesn't seem to have a double data type to interpret the column
>> > value for display.
>> >
>> > [default@DemoKS] get
>> > DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
>> > as LongType;
>> > => (column=0000124597556740, value=4629084924887308954,
>> > timestamp=1310144024947000)
>> >
>> > But that value is not exactly correct. It should be: 29.813332976331914
>> >
>> >
>> > This is how I do the read in Hector:
>> >
>> >         ColumnQuery<String, Long, Double> columnQuery =
>> > HFactory.createColumnQuery(keyspace, ss, ls, ds);
>> >
>> >
>> >
>> > columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);
>> >
>> >         QueryResult<HColumn<Long, Double>> result =
>> > columnQuery.execute();
>> >
>> >         System.out.println("Query result: " + result.get());
>> >
>> >
>> > Is there a equivalent for that in Cassandra CLI?
>> >
>> > - Sameer
>> >
>> >
>>
>>
>>
>> --
>> Jonathan Ellis
>> Project Chair, Apache Cassandra
>> co-founder of DataStax, the source for professional Cassandra support
>> http://www.datastax.com
>
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of DataStax, the source for professional Cassandra support
http://www.datastax.com

Re: Is there a way to read a Double value from the CLI?

Posted by Sameer Farooqui <ca...@gmail.com>.
Yup, Jonathan, I was just temporarily returning the value as LongType b/c I
couldn't find a DoubleType. Since LongType returned something, I know that
the data is there.

Thanks for that link, Jeremy. I'm guessing DoubleType hasn't found its way
into the CLI yet, b/c I tried this and got an error:

[default@DemoKS] get DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
as DoubleType;
Unknown comparator 'DoubleType'. Available functions: bytes, integer, long,
lexicaluuid, timeuuid, utf8, ascii, countercolumn.




On Mon, Jul 18, 2011 at 2:28 PM, Jonathan Ellis <jb...@gmail.com> wrote:

> "get X as LongType" will give you the bytes in that column value
> interpreted as a long.
>
> So it did exactly what you asked it to do :)
>
> On Mon, Jul 18, 2011 at 4:16 PM, Sameer Farooqui
> <ca...@gmail.com> wrote:
> > I wrote some data to a standard column family (using Hector) with ASCII
> > row-key, Long column name and Double column value.
> >
> > The CLI doesn't seem to have a double data type to interpret the column
> > value for display.
> >
> > [default@DemoKS] get
> DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
> > as LongType;
> > => (column=0000124597556740, value=4629084924887308954,
> > timestamp=1310144024947000)
> >
> > But that value is not exactly correct. It should be: 29.813332976331914
> >
> >
> > This is how I do the read in Hector:
> >
> >         ColumnQuery<String, Long, Double> columnQuery =
> > HFactory.createColumnQuery(keyspace, ss, ls, ds);
> >
> >
> >
> columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);
> >
> >         QueryResult<HColumn<Long, Double>> result =
> columnQuery.execute();
> >
> >         System.out.println("Query result: " + result.get());
> >
> >
> > Is there a equivalent for that in Cassandra CLI?
> >
> > - Sameer
> >
> >
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of DataStax, the source for professional Cassandra support
> http://www.datastax.com
>

Re: Is there a way to read a Double value from the CLI?

Posted by Jonathan Ellis <jb...@gmail.com>.
"get X as LongType" will give you the bytes in that column value
interpreted as a long.

So it did exactly what you asked it to do :)

On Mon, Jul 18, 2011 at 4:16 PM, Sameer Farooqui
<ca...@gmail.com> wrote:
> I wrote some data to a standard column family (using Hector) with ASCII
> row-key, Long column name and Double column value.
>
> The CLI doesn't seem to have a double data type to interpret the column
> value for display.
>
> [default@DemoKS] get DemoCF[ascii('ABC_100000000020')][long(20090101000000)]
> as LongType;
> => (column=0000124597556740, value=4629084924887308954,
> timestamp=1310144024947000)
>
> But that value is not exactly correct. It should be: 29.813332976331914
>
>
> This is how I do the read in Hector:
>
>         ColumnQuery<String, Long, Double> columnQuery =
> HFactory.createColumnQuery(keyspace, ss, ls, ds);
>
>
> columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);
>
>         QueryResult<HColumn<Long, Double>> result = columnQuery.execute();
>
>         System.out.println("Query result: " + result.get());
>
>
> Is there a equivalent for that in Cassandra CLI?
>
> - Sameer
>
>



-- 
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of DataStax, the source for professional Cassandra support
http://www.datastax.com

Re: Is there a way to read a Double value from the CLI?

Posted by Jeremy Hanna <je...@gmail.com>.
I know additional types have been added as of 0.8.1:
https://issues.apache.org/jira/browse/CASSANDRA-2530

However, I'm not sure how those have propagated up to validators, the CLI, and hector though.

On Jul 18, 2011, at 4:16 PM, Sameer Farooqui wrote:

> I wrote some data to a standard column family (using Hector) with ASCII row-key, Long column name and Double column value.
> 
> The CLI doesn't seem to have a double data type to interpret the column value for display.
> 
> [default@DemoKS] get DemoCF[ascii('ABC_100000000020')][long(20090101000000)] as LongType;
> => (column=0000124597556740, value=4629084924887308954, timestamp=1310144024947000)
> 
> But that value is not exactly correct. It should be: 29.813332976331914
> 
> 
> This is how I do the read in Hector:
> 
>         ColumnQuery<String, Long, Double> columnQuery = HFactory.createColumnQuery(keyspace, ss, ls, ds);
>                                         
>         columnQuery.setColumnFamily("DemoCF").setKey("ABC_100000000020").setName(20090101000000L);
>         
>         QueryResult<HColumn<Long, Double>> result = columnQuery.execute(); 
>         
>         System.out.println("Query result: " + result.get());
> 
> 
> Is there a equivalent for that in Cassandra CLI?
> 
> - Sameer
>