You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Yuhan Zhang <yz...@onescreen.com> on 2012/08/27 23:49:56 UTC

cassandra twitter ruby client

Hi all,

I'm playing with cassandra's ruby client written by twitter,  trying to
perform a simple get.

but looks like it assumed the value types to be uft8 string. however, my
values are in double (keyed and column names are utf8types).
The values that I got are like:
{"Top":"?\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000", ... }

how do I pass double serializer to the api client?


Thank you.

Yuhan

Re: cassandra twitter ruby client

Posted by Yuhan Zhang <yz...@onescreen.com>.
Hi Peter,

works well. Thanks for lot!  :D   will check out cassandra-cql.

Yuhan

On Mon, Aug 27, 2012 at 3:34 PM, Peter Sanford
<ps...@nearbuysystems.com>wrote:

> That library requires you to serialize and deserialize the data
> yourself. So to insert a ruby Float you would
>
>   value = 28.21
>   [value].pack('G')
>   @client.insert(:somecf, 'key', {'floatval' => [value].pack('G')})
>
> and to read it back out:
>
>   value = @client.get(:somecf, 'key', ['floatval']).unpack('G')[0]
>
> Note that the cassandra-cql library will do (most) typecasts for you.
>
> -psanford
>
> On Mon, Aug 27, 2012 at 2:49 PM, Yuhan Zhang <yz...@onescreen.com> wrote:
> > Hi all,
> >
> > I'm playing with cassandra's ruby client written by twitter,  trying to
> > perform a simple get.
> >
> > but looks like it assumed the value types to be uft8 string. however, my
> > values are in double (keyed and column names are utf8types).
> > The values that I got are like:
> > {"Top":"?\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000", ... }
> >
> > how do I pass double serializer to the api client?
> >
> >
> > Thank you.
> >
> > Yuhan
>

Re: cassandra twitter ruby client

Posted by Peter Sanford <ps...@nearbuysystems.com>.
That library requires you to serialize and deserialize the data
yourself. So to insert a ruby Float you would

  value = 28.21
  [value].pack('G')
  @client.insert(:somecf, 'key', {'floatval' => [value].pack('G')})

and to read it back out:

  value = @client.get(:somecf, 'key', ['floatval']).unpack('G')[0]

Note that the cassandra-cql library will do (most) typecasts for you.

-psanford

On Mon, Aug 27, 2012 at 2:49 PM, Yuhan Zhang <yz...@onescreen.com> wrote:
> Hi all,
>
> I'm playing with cassandra's ruby client written by twitter,  trying to
> perform a simple get.
>
> but looks like it assumed the value types to be uft8 string. however, my
> values are in double (keyed and column names are utf8types).
> The values that I got are like:
> {"Top":"?\ufffd\ufffd\ufffd\u0000\u0000\u0000\u0000", ... }
>
> how do I pass double serializer to the api client?
>
>
> Thank you.
>
> Yuhan