You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Roshan Dawrani <ro...@gmail.com> on 2010/12/25 05:44:27 UTC

Newbie question - fetching multiple columns of different datatypes and conversion from byte[]

Hi,

I am new to Cassandra and Hector and have a basic question on fetching
multiple columns of a row that have mixed data types.

So, I am basically doing equivalent of "Select dateCol1, dateCol2,
stringCol1, intCol1 from a_table where key in (?, ?, ?...)"

My question is do I need to do the conversion of columns from byte[] to
Date/String/Int myself after taking out data from the ColumnSlice?

For saving the same data, while adding the columns, I was able to tell which
serializer to use, but slice queries seem to take only one ValueSerializer
for all columns being retrieved. So, if I have got it correctly, I can only
use ByteBufferSerializer in the Hector API slice query call and then do
further data-type specific conversion myself at the app level?

-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani <http://twitter.com/roshandawrani>
Skype: roshandawrani

Re: Newbie question - fetching multiple columns of different datatypes and conversion from byte[]

Posted by Ertio Lew <er...@gmail.com>.
Should the different datatype col values or names be first read as byte 
buffer & then converted to appropriate type using Hector's provided 
serializers api like the way shown below ?

ByteBuffer bb;
..

String s= StringSerializer.get().fromByteBuffer(bb);


Or are there any better ways ?

Re: Newbie question - fetching multiple columns of differentdatatypes and conversion from byte[]

Posted by Roshan Dawrani <ro...@gmail.com>.
Thanks a lot for the references. Will check them out first before asking the
next question.

On Sat, Dec 25, 2010 at 6:46 PM, Nate McCall <na...@riptano.com> wrote:

> See the following PDF for some additional detail on hector:
> http://www.riptano.com/sites/default/files/hector-v2-client-doc.pdf
>
> There is a also a project with some basic stand-alone examples that
> may be helpful:
> https://github.com/zznate/hector-examples
>
> And Riptano maintains a Java port of a Twitter example using Hector:
> https://github.com/riptano/twissjava
>
> On Sat, Dec 25, 2010 at 12:22 AM,  <ro...@gmail.com> wrote:
> > Can you please point me an example of that or some Hector API
> documentation?
> >
> > I am currently using IndexedSliceRangeQuery to filter on a 2ndary index
> and fetching all columns of the matching rows - using range start/end =
> null. Can the option you suggest be used with the 2ndry index filtering? I
> would appreciate very much seeing an example.
> >
> > Does it make any performance difference whether that conversion is done
> by Hector/Cass or by the app?
> >
> > Thanks.
> > Roshan
> > ---------------------------------------------------
> > Sent from BlackBerry
> >
> > -----Original Message-----
> > From: Jonathan Ellis <jb...@gmail.com>
> > Date: Sat, 25 Dec 2010 00:05:44
> > To: user<us...@cassandra.apache.org>
> > Reply-To: user@cassandra.apache.org
> > Subject: Re: Newbie question - fetching multiple columns of different
> >  datatypes and conversion from byte[]
> >
> > Or you can specify the types with the column name instead of doing a
> slice.
> >
> > On Fri, Dec 24, 2010 at 11:23 PM, Nate McCall <na...@riptano.com> wrote:
> >> In the case where you have different value types within the same
> >> slice, yes, you must handle the conversion yourself and
> >> ByteBufferSerializer is the easiest way to do that.
> >>
> >> On Fri, Dec 24, 2010 at 10:44 PM, Roshan Dawrani
> >> <ro...@gmail.com> wrote:
> >>> Hi,
> >>>
> >>> I am new to Cassandra and Hector and have a basic question on fetching
> >>> multiple columns of a row that have mixed data types.
> >>>
> >>> So, I am basically doing equivalent of "Select dateCol1, dateCol2,
> >>> stringCol1, intCol1 from a_table where key in (?, ?, ?...)"
> >>>
> >>> My question is do I need to do the conversion of columns from byte[] to
> >>> Date/String/Int myself after taking out data from the ColumnSlice?
> >>>
> >>> For saving the same data, while adding the columns, I was able to tell
> which
> >>> serializer to use, but slice queries seem to take only one
> ValueSerializer
> >>> for all columns being retrieved. So, if I have got it correctly, I can
> only
> >>> use ByteBufferSerializer in the Hector API slice query call and then do
> >>> further data-type specific conversion myself at the app level?
> >>>
> >>> --
> >>> Roshan
> >>> Blog: http://roshandawrani.wordpress.com/
> >>> Twitter: @roshandawrani
> >>> Skype: roshandawrani
> >>>
> >>
> >
> >
> >
> > --
> > Jonathan Ellis
> > Project Chair, Apache Cassandra
> > co-founder of Riptano, the source for professional Cassandra support
> > http://riptano.com
> >
>



-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani <http://twitter.com/roshandawrani>
Skype: roshandawrani

Re: Newbie question - fetching multiple columns of differentdatatypes and conversion from byte[]

Posted by Nate McCall <na...@riptano.com>.
See the following PDF for some additional detail on hector:
http://www.riptano.com/sites/default/files/hector-v2-client-doc.pdf

There is a also a project with some basic stand-alone examples that
may be helpful:
https://github.com/zznate/hector-examples

And Riptano maintains a Java port of a Twitter example using Hector:
https://github.com/riptano/twissjava

On Sat, Dec 25, 2010 at 12:22 AM,  <ro...@gmail.com> wrote:
> Can you please point me an example of that or some Hector API documentation?
>
> I am currently using IndexedSliceRangeQuery to filter on a 2ndary index and fetching all columns of the matching rows - using range start/end = null. Can the option you suggest be used with the 2ndry index filtering? I would appreciate very much seeing an example.
>
> Does it make any performance difference whether that conversion is done by Hector/Cass or by the app?
>
> Thanks.
> Roshan
> ---------------------------------------------------
> Sent from BlackBerry
>
> -----Original Message-----
> From: Jonathan Ellis <jb...@gmail.com>
> Date: Sat, 25 Dec 2010 00:05:44
> To: user<us...@cassandra.apache.org>
> Reply-To: user@cassandra.apache.org
> Subject: Re: Newbie question - fetching multiple columns of different
>  datatypes and conversion from byte[]
>
> Or you can specify the types with the column name instead of doing a slice.
>
> On Fri, Dec 24, 2010 at 11:23 PM, Nate McCall <na...@riptano.com> wrote:
>> In the case where you have different value types within the same
>> slice, yes, you must handle the conversion yourself and
>> ByteBufferSerializer is the easiest way to do that.
>>
>> On Fri, Dec 24, 2010 at 10:44 PM, Roshan Dawrani
>> <ro...@gmail.com> wrote:
>>> Hi,
>>>
>>> I am new to Cassandra and Hector and have a basic question on fetching
>>> multiple columns of a row that have mixed data types.
>>>
>>> So, I am basically doing equivalent of "Select dateCol1, dateCol2,
>>> stringCol1, intCol1 from a_table where key in (?, ?, ?...)"
>>>
>>> My question is do I need to do the conversion of columns from byte[] to
>>> Date/String/Int myself after taking out data from the ColumnSlice?
>>>
>>> For saving the same data, while adding the columns, I was able to tell which
>>> serializer to use, but slice queries seem to take only one ValueSerializer
>>> for all columns being retrieved. So, if I have got it correctly, I can only
>>> use ByteBufferSerializer in the Hector API slice query call and then do
>>> further data-type specific conversion myself at the app level?
>>>
>>> --
>>> Roshan
>>> Blog: http://roshandawrani.wordpress.com/
>>> Twitter: @roshandawrani
>>> Skype: roshandawrani
>>>
>>
>
>
>
> --
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of Riptano, the source for professional Cassandra support
> http://riptano.com
>

Re: Newbie question - fetching multiple columns of differentdatatypes and conversion from byte[]

Posted by ro...@gmail.com.
Can you please point me an example of that or some Hector API documentation?

I am currently using IndexedSliceRangeQuery to filter on a 2ndary index and fetching all columns of the matching rows - using range start/end = null. Can the option you suggest be used with the 2ndry index filtering? I would appreciate very much seeing an example.

Does it make any performance difference whether that conversion is done by Hector/Cass or by the app?

Thanks.
Roshan
---------------------------------------------------
Sent from BlackBerry

-----Original Message-----
From: Jonathan Ellis <jb...@gmail.com>
Date: Sat, 25 Dec 2010 00:05:44 
To: user<us...@cassandra.apache.org>
Reply-To: user@cassandra.apache.org
Subject: Re: Newbie question - fetching multiple columns of different
 datatypes and conversion from byte[]

Or you can specify the types with the column name instead of doing a slice.

On Fri, Dec 24, 2010 at 11:23 PM, Nate McCall <na...@riptano.com> wrote:
> In the case where you have different value types within the same
> slice, yes, you must handle the conversion yourself and
> ByteBufferSerializer is the easiest way to do that.
>
> On Fri, Dec 24, 2010 at 10:44 PM, Roshan Dawrani
> <ro...@gmail.com> wrote:
>> Hi,
>>
>> I am new to Cassandra and Hector and have a basic question on fetching
>> multiple columns of a row that have mixed data types.
>>
>> So, I am basically doing equivalent of "Select dateCol1, dateCol2,
>> stringCol1, intCol1 from a_table where key in (?, ?, ?...)"
>>
>> My question is do I need to do the conversion of columns from byte[] to
>> Date/String/Int myself after taking out data from the ColumnSlice?
>>
>> For saving the same data, while adding the columns, I was able to tell which
>> serializer to use, but slice queries seem to take only one ValueSerializer
>> for all columns being retrieved. So, if I have got it correctly, I can only
>> use ByteBufferSerializer in the Hector API slice query call and then do
>> further data-type specific conversion myself at the app level?
>>
>> --
>> Roshan
>> Blog: http://roshandawrani.wordpress.com/
>> Twitter: @roshandawrani
>> Skype: roshandawrani
>>
>



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

Re: Newbie question - fetching multiple columns of different datatypes and conversion from byte[]

Posted by Jonathan Ellis <jb...@gmail.com>.
Or you can specify the types with the column name instead of doing a slice.

On Fri, Dec 24, 2010 at 11:23 PM, Nate McCall <na...@riptano.com> wrote:
> In the case where you have different value types within the same
> slice, yes, you must handle the conversion yourself and
> ByteBufferSerializer is the easiest way to do that.
>
> On Fri, Dec 24, 2010 at 10:44 PM, Roshan Dawrani
> <ro...@gmail.com> wrote:
>> Hi,
>>
>> I am new to Cassandra and Hector and have a basic question on fetching
>> multiple columns of a row that have mixed data types.
>>
>> So, I am basically doing equivalent of "Select dateCol1, dateCol2,
>> stringCol1, intCol1 from a_table where key in (?, ?, ?...)"
>>
>> My question is do I need to do the conversion of columns from byte[] to
>> Date/String/Int myself after taking out data from the ColumnSlice?
>>
>> For saving the same data, while adding the columns, I was able to tell which
>> serializer to use, but slice queries seem to take only one ValueSerializer
>> for all columns being retrieved. So, if I have got it correctly, I can only
>> use ByteBufferSerializer in the Hector API slice query call and then do
>> further data-type specific conversion myself at the app level?
>>
>> --
>> Roshan
>> Blog: http://roshandawrani.wordpress.com/
>> Twitter: @roshandawrani
>> Skype: roshandawrani
>>
>



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

Re: Newbie question - fetching multiple columns of different datatypes and conversion from byte[]

Posted by Nate McCall <na...@riptano.com>.
In the case where you have different value types within the same
slice, yes, you must handle the conversion yourself and
ByteBufferSerializer is the easiest way to do that.

On Fri, Dec 24, 2010 at 10:44 PM, Roshan Dawrani
<ro...@gmail.com> wrote:
> Hi,
>
> I am new to Cassandra and Hector and have a basic question on fetching
> multiple columns of a row that have mixed data types.
>
> So, I am basically doing equivalent of "Select dateCol1, dateCol2,
> stringCol1, intCol1 from a_table where key in (?, ?, ?...)"
>
> My question is do I need to do the conversion of columns from byte[] to
> Date/String/Int myself after taking out data from the ColumnSlice?
>
> For saving the same data, while adding the columns, I was able to tell which
> serializer to use, but slice queries seem to take only one ValueSerializer
> for all columns being retrieved. So, if I have got it correctly, I can only
> use ByteBufferSerializer in the Hector API slice query call and then do
> further data-type specific conversion myself at the app level?
>
> --
> Roshan
> Blog: http://roshandawrani.wordpress.com/
> Twitter: @roshandawrani
> Skype: roshandawrani
>