You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Vivek Mishra <vi...@impetus.co.in> on 2011/06/17 12:03:52 UTC

getFieldValue()


From: Vivek Mishra
Sent: Friday, June 17, 2011 3:25 PM
To: user@cassandra.apache.org
Subject: getFieldValue()

Hi,
I was looking into  getFieldValue method for SuperColumn and SlicePredicate apis.

It looks to me slight confusing as underlying APIs are returning Object and developer can only be aware of type of object either by looking into Cassandra code base or by ClassCastException.

For example,

I need to retrieve column name  and it's value for a SuperColumnFamily "SuperCli" is:


List<KeySlice> keySlices = cassndraClient.get_range_slices(new ColumnParent(
                        "SuperCli"), slicePredicate, keyRange, ConsistencyLevel.ONE);
            System.out.println(keySlices.size()
                        + " No. of rows exist for the column family:" + "SuperCli");
            for( KeySlice slice :keySlices)
            {
                  city = "noida";
System.out.println(new String((byte[]) (slice.getColumns().get(0).getSuper_column().getFieldValue(org.apache.cassandra.thrift.SuperColumn._Fields.NAME))).toString());
            }


Am I doing something wrong or such typecasting is must? Shouldn't we hide this complexity and handle it implicitly in CASSANDRA? Or may be introducing a Helper Class can reduce such amount of code ?



Is it possible to retrieve a specific SuperColumn by specifying it's value in SliceRange query?

I can't see any method with  such search API and I believe it is a real time scenario.

SuperCli is a super column family holding number of dynamic super columns.


________________________________

Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend a live session by Head of Impetus Labs on 'Secrets of Building a Cloud Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud '.

Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus webinar on May 27 by registering at http://www.impetus.com/webinar?eventid=42 .


NOTE: This message may contain information that is confidential, proprietary, privileged or otherwise protected by law. The message is intended solely for the named addressee. If received in error, please destroy and notify the sender. Any use of this email is prohibited when received in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.

Re: getFieldValue()

Posted by "Markus Wiesenbacher | Codefreun.de" <mw...@codefreun.de>.
I see ;)

Von meinem iPhone gesendet

Am 17.06.2011 um 17:55 schrieb Jonathan Ellis <jb...@gmail.com>:

> If you don't get frustrated writing Thrift by hand you are a far, far
> more patient man than I am.
> 
> It's tedious and error-prone to boot.
> 
> On Fri, Jun 17, 2011 at 10:30 AM, Markus Wiesenbacher | Codefreun.de
> <mw...@codefreun.de> wrote:
>> One question regarding point 2: Why should we always use Hector, Thrift is not that bad?
>> 
>> Von meinem iPhone gesendet
>> 
>> Am 17.06.2011 um 17:12 schrieb Jonathan Ellis <jb...@gmail.com>:
>> 
>>> 1. the right way to right that is to just say struct.name, struct.value, etc
>>> 2. why are you writing raw thrift instead of using Hector?
>>> 
>>> On Fri, Jun 17, 2011 at 5:03 AM, Vivek Mishra
>>> <vi...@impetus.co.in> wrote:
>>>> 
>>>> 
>>>> 
>>>> 
>>>> From: Vivek Mishra
>>>> Sent: Friday, June 17, 2011 3:25 PM
>>>> To: user@cassandra.apache.org
>>>> Subject: getFieldValue()
>>>> 
>>>> 
>>>> 
>>>> Hi,
>>>> 
>>>> I was looking into  getFieldValue method for SuperColumn and SlicePredicate
>>>> apis.
>>>> 
>>>> 
>>>> 
>>>> It looks to me slight confusing as underlying APIs are returning Object and
>>>> developer can only be aware of type of object either by looking into
>>>> Cassandra code base or by ClassCastException.
>>>> 
>>>> 
>>>> 
>>>> For example,
>>>> 
>>>> 
>>>> 
>>>> I need to retrieve column name  and it’s value for a SuperColumnFamily
>>>> “SuperCli” is:
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> List<KeySlice> keySlices = cassndraClient.get_range_slices(new ColumnParent(
>>>> 
>>>>                         "SuperCli"), slicePredicate, keyRange,
>>>> ConsistencyLevel.ONE);
>>>> 
>>>>             System.out.println(keySlices.size()
>>>> 
>>>>                         + " No. of rows exist for the column family:" +
>>>> "SuperCli");
>>>> 
>>>>             for( KeySlice slice :keySlices)
>>>> 
>>>>             {
>>>> 
>>>>                   city = "noida";
>>>> 
>>>> System.out.println(new String((byte[])
>>>> (slice.getColumns().get(0).getSuper_column().getFieldValue(org.apache.cassandra.thrift.SuperColumn._Fields.NAME))).toString());
>>>> 
>>>>             }
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Am I doing something wrong or such typecasting is must? Shouldn’t we hide
>>>> this complexity and handle it implicitly in CASSANDRA? Or may be introducing
>>>> a Helper Class can reduce such amount of code ?
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Is it possible to retrieve a specific SuperColumn by specifying it’s value
>>>> in SliceRange query?
>>>> 
>>>> 
>>>> 
>>>> I can’t see any method with  such search API and I believe it is a real time
>>>> scenario.
>>>> 
>>>> 
>>>> 
>>>> SuperCli is a super column family holding number of dynamic super columns.
>>>> 
>>>> 
>>>> 
>>>> ________________________________
>>>> Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend
>>>> a live session by Head of Impetus Labs on ‘Secrets of Building a Cloud
>>>> Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud
>>>> ‘.
>>>> 
>>>> Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
>>>> webinar on May 27 by registering at
>>>> http://www.impetus.com/webinar?eventid=42 .
>>>> 
>>>> 
>>>> NOTE: This message may contain information that is confidential,
>>>> proprietary, privileged or otherwise protected by law. The message is
>>>> intended solely for the named addressee. If received in error, please
>>>> destroy and notify the sender. Any use of this email is prohibited when
>>>> received in error. Impetus does not represent, warrant and/or guarantee,
>>>> that the integrity of this communication has been maintained nor that the
>>>> communication is free of errors, virus, interception or interference.
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> 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: getFieldValue()

Posted by Jonathan Ellis <jb...@gmail.com>.
If you don't get frustrated writing Thrift by hand you are a far, far
more patient man than I am.

It's tedious and error-prone to boot.

On Fri, Jun 17, 2011 at 10:30 AM, Markus Wiesenbacher | Codefreun.de
<mw...@codefreun.de> wrote:
> One question regarding point 2: Why should we always use Hector, Thrift is not that bad?
>
> Von meinem iPhone gesendet
>
> Am 17.06.2011 um 17:12 schrieb Jonathan Ellis <jb...@gmail.com>:
>
>> 1. the right way to right that is to just say struct.name, struct.value, etc
>> 2. why are you writing raw thrift instead of using Hector?
>>
>> On Fri, Jun 17, 2011 at 5:03 AM, Vivek Mishra
>> <vi...@impetus.co.in> wrote:
>>>
>>>
>>>
>>>
>>> From: Vivek Mishra
>>> Sent: Friday, June 17, 2011 3:25 PM
>>> To: user@cassandra.apache.org
>>> Subject: getFieldValue()
>>>
>>>
>>>
>>> Hi,
>>>
>>> I was looking into  getFieldValue method for SuperColumn and SlicePredicate
>>> apis.
>>>
>>>
>>>
>>> It looks to me slight confusing as underlying APIs are returning Object and
>>> developer can only be aware of type of object either by looking into
>>> Cassandra code base or by ClassCastException.
>>>
>>>
>>>
>>> For example,
>>>
>>>
>>>
>>> I need to retrieve column name  and it’s value for a SuperColumnFamily
>>> “SuperCli” is:
>>>
>>>
>>>
>>>
>>>
>>> List<KeySlice> keySlices = cassndraClient.get_range_slices(new ColumnParent(
>>>
>>>                         "SuperCli"), slicePredicate, keyRange,
>>> ConsistencyLevel.ONE);
>>>
>>>             System.out.println(keySlices.size()
>>>
>>>                         + " No. of rows exist for the column family:" +
>>> "SuperCli");
>>>
>>>             for( KeySlice slice :keySlices)
>>>
>>>             {
>>>
>>>                   city = "noida";
>>>
>>> System.out.println(new String((byte[])
>>> (slice.getColumns().get(0).getSuper_column().getFieldValue(org.apache.cassandra.thrift.SuperColumn._Fields.NAME))).toString());
>>>
>>>             }
>>>
>>>
>>>
>>>
>>>
>>> Am I doing something wrong or such typecasting is must? Shouldn’t we hide
>>> this complexity and handle it implicitly in CASSANDRA? Or may be introducing
>>> a Helper Class can reduce such amount of code ?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Is it possible to retrieve a specific SuperColumn by specifying it’s value
>>> in SliceRange query?
>>>
>>>
>>>
>>> I can’t see any method with  such search API and I believe it is a real time
>>> scenario.
>>>
>>>
>>>
>>> SuperCli is a super column family holding number of dynamic super columns.
>>>
>>>
>>>
>>> ________________________________
>>> Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend
>>> a live session by Head of Impetus Labs on ‘Secrets of Building a Cloud
>>> Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud
>>> ‘.
>>>
>>> Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
>>> webinar on May 27 by registering at
>>> http://www.impetus.com/webinar?eventid=42 .
>>>
>>>
>>> NOTE: This message may contain information that is confidential,
>>> proprietary, privileged or otherwise protected by law. The message is
>>> intended solely for the named addressee. If received in error, please
>>> destroy and notify the sender. Any use of this email is prohibited when
>>> received in error. Impetus does not represent, warrant and/or guarantee,
>>> that the integrity of this communication has been maintained nor that the
>>> communication is free of errors, virus, interception or interference.
>>>
>>
>>
>>
>> --
>> 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: getFieldValue()

Posted by Sasha Dolgy <sd...@gmail.com>.
A good example for what I understand in using Hector / pycassa / etc.
is, if you wanted to implement connection pooling, you would have to
craft your own solution, versus implementing the solution that is
tested and ready to go, provided by Hector.  Thrift doesn't provide
native connection pooling ...?

There are a few scenarios / examples where using a library that
abstracts the Thrift bindings will make your life easier ... and they
are maintained and up to date generally in alignment with new releases
of Cassandra.  That's a +1 for me ...

Nothing stops you from using Thrift .. depends on how much work you
want to implement yourself.
-sd

On Fri, Jun 17, 2011 at 5:30 PM, Markus Wiesenbacher | Codefreun.de
<mw...@codefreun.de> wrote:
> One question regarding point 2: Why should we always use Hector, Thrift is not that bad?

Re: getFieldValue()

Posted by "Markus Wiesenbacher | Codefreun.de" <mw...@codefreun.de>.
One question regarding point 2: Why should we always use Hector, Thrift is not that bad?

Von meinem iPhone gesendet

Am 17.06.2011 um 17:12 schrieb Jonathan Ellis <jb...@gmail.com>:

> 1. the right way to right that is to just say struct.name, struct.value, etc
> 2. why are you writing raw thrift instead of using Hector?
> 
> On Fri, Jun 17, 2011 at 5:03 AM, Vivek Mishra
> <vi...@impetus.co.in> wrote:
>> 
>> 
>> 
>> 
>> From: Vivek Mishra
>> Sent: Friday, June 17, 2011 3:25 PM
>> To: user@cassandra.apache.org
>> Subject: getFieldValue()
>> 
>> 
>> 
>> Hi,
>> 
>> I was looking into  getFieldValue method for SuperColumn and SlicePredicate
>> apis.
>> 
>> 
>> 
>> It looks to me slight confusing as underlying APIs are returning Object and
>> developer can only be aware of type of object either by looking into
>> Cassandra code base or by ClassCastException.
>> 
>> 
>> 
>> For example,
>> 
>> 
>> 
>> I need to retrieve column name  and it’s value for a SuperColumnFamily
>> “SuperCli” is:
>> 
>> 
>> 
>> 
>> 
>> List<KeySlice> keySlices = cassndraClient.get_range_slices(new ColumnParent(
>> 
>>                         "SuperCli"), slicePredicate, keyRange,
>> ConsistencyLevel.ONE);
>> 
>>             System.out.println(keySlices.size()
>> 
>>                         + " No. of rows exist for the column family:" +
>> "SuperCli");
>> 
>>             for( KeySlice slice :keySlices)
>> 
>>             {
>> 
>>                   city = "noida";
>> 
>> System.out.println(new String((byte[])
>> (slice.getColumns().get(0).getSuper_column().getFieldValue(org.apache.cassandra.thrift.SuperColumn._Fields.NAME))).toString());
>> 
>>             }
>> 
>> 
>> 
>> 
>> 
>> Am I doing something wrong or such typecasting is must? Shouldn’t we hide
>> this complexity and handle it implicitly in CASSANDRA? Or may be introducing
>> a Helper Class can reduce such amount of code ?
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Is it possible to retrieve a specific SuperColumn by specifying it’s value
>> in SliceRange query?
>> 
>> 
>> 
>> I can’t see any method with  such search API and I believe it is a real time
>> scenario.
>> 
>> 
>> 
>> SuperCli is a super column family holding number of dynamic super columns.
>> 
>> 
>> 
>> ________________________________
>> Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend
>> a live session by Head of Impetus Labs on ‘Secrets of Building a Cloud
>> Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud
>> ‘.
>> 
>> Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
>> webinar on May 27 by registering at
>> http://www.impetus.com/webinar?eventid=42 .
>> 
>> 
>> NOTE: This message may contain information that is confidential,
>> proprietary, privileged or otherwise protected by law. The message is
>> intended solely for the named addressee. If received in error, please
>> destroy and notify the sender. Any use of this email is prohibited when
>> received in error. Impetus does not represent, warrant and/or guarantee,
>> that the integrity of this communication has been maintained nor that the
>> communication is free of errors, virus, interception or interference.
>> 
> 
> 
> 
> -- 
> Jonathan Ellis
> Project Chair, Apache Cassandra
> co-founder of DataStax, the source for professional Cassandra support
> http://www.datastax.com

Re: getFieldValue()

Posted by Jonathan Ellis <jb...@gmail.com>.
1. the right way to right that is to just say struct.name, struct.value, etc
2. why are you writing raw thrift instead of using Hector?

On Fri, Jun 17, 2011 at 5:03 AM, Vivek Mishra
<vi...@impetus.co.in> wrote:
>
>
>
>
> From: Vivek Mishra
> Sent: Friday, June 17, 2011 3:25 PM
> To: user@cassandra.apache.org
> Subject: getFieldValue()
>
>
>
> Hi,
>
> I was looking into  getFieldValue method for SuperColumn and SlicePredicate
> apis.
>
>
>
> It looks to me slight confusing as underlying APIs are returning Object and
> developer can only be aware of type of object either by looking into
> Cassandra code base or by ClassCastException.
>
>
>
> For example,
>
>
>
> I need to retrieve column name  and it’s value for a SuperColumnFamily
> “SuperCli” is:
>
>
>
>
>
> List<KeySlice> keySlices = cassndraClient.get_range_slices(new ColumnParent(
>
>                         "SuperCli"), slicePredicate, keyRange,
> ConsistencyLevel.ONE);
>
>             System.out.println(keySlices.size()
>
>                         + " No. of rows exist for the column family:" +
> "SuperCli");
>
>             for( KeySlice slice :keySlices)
>
>             {
>
>                   city = "noida";
>
> System.out.println(new String((byte[])
> (slice.getColumns().get(0).getSuper_column().getFieldValue(org.apache.cassandra.thrift.SuperColumn._Fields.NAME))).toString());
>
>             }
>
>
>
>
>
> Am I doing something wrong or such typecasting is must? Shouldn’t we hide
> this complexity and handle it implicitly in CASSANDRA? Or may be introducing
> a Helper Class can reduce such amount of code ?
>
>
>
>
>
>
>
> Is it possible to retrieve a specific SuperColumn by specifying it’s value
> in SliceRange query?
>
>
>
> I can’t see any method with  such search API and I believe it is a real time
> scenario.
>
>
>
> SuperCli is a super column family holding number of dynamic super columns.
>
>
>
> ________________________________
> Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to attend
> a live session by Head of Impetus Labs on ‘Secrets of Building a Cloud
> Vendor Agnostic PetaByte Scale Real-time Secure Web Application on the Cloud
> ‘.
>
> Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetus
> webinar on May 27 by registering at
> http://www.impetus.com/webinar?eventid=42 .
>
>
> NOTE: This message may contain information that is confidential,
> proprietary, privileged or otherwise protected by law. The message is
> intended solely for the named addressee. If received in error, please
> destroy and notify the sender. Any use of this email is prohibited when
> received in error. Impetus does not represent, warrant and/or guarantee,
> that the integrity of this communication has been maintained nor that the
> communication is free of errors, virus, interception or interference.
>



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