You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Pinak Pani <ni...@gmail.com> on 2013/08/15 17:38:15 UTC

How to create counter column family via Pycassa?

I do not find a way to create a counter column family in Pycassa.
This[1] does not help.

Appreciate if someone can help me.

Thanks

1.
http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family

Re: How to create counter column family via Pycassa?

Posted by Kumar Ranjan <wi...@gmail.com>.
This works, When I remove the comparator_type

validators = {

        'tid':           'IntegerType',

        'approved':      'BooleanType',

        'text':          'UTF8Type',

        'favorite_count':'IntegerType',

        'retweet_count': 'IntegerType',

        'expanded_url':  'UTF8Type',

        'tuid':          'LongType',

        'screen_name':   'UTF8Type',

        'profile_image': 'UTF8Type',

        'embedly_data':  'BytesType',

        'created_at':    'UTF8Type',

}


SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search',
default_validation_class='UTF8Type', key_validation_class='UTF8Type',
column_validation_classes=validators)




On Wed, Dec 11, 2013 at 12:23 PM, Kumar Ranjan <wi...@gmail.com> wrote:

> I am using ccm cassandra version
>
> *1.2.11*
>
>
> On Wed, Dec 11, 2013 at 12:19 PM, Kumar Ranjan <wi...@gmail.com>wrote:
>
>> validators = {
>>
>>     'approved':      'BooleanType',
>>
>>     'text':          'UTF8Type',
>>
>>     'favorite_count':'IntegerType',
>>
>>     'retweet_count': 'IntegerType',
>>
>>     'expanded_url':  'UTF8Type',
>>
>>     'tuid':          'LongType',
>>
>>     'screen_name':   'UTF8Type',
>>
>>     'profile_image': 'UTF8Type',
>>
>>     'embedly_data':  'CompositeType',
>>
>>     'created_at':    'UTF8Type',
>>
>> }
>>
>> SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
>> comparator_type='CompositeType', default_validation_class='UTF8Type',
>> key_validation_class='UTF8Type', column_validation_classes=validators)
>>
>>
>> throws:
>>
>> *InvalidRequestException*: InvalidRequestException(why='Invalid
>> definition for comparator org.apache.cassandra.db.marshal.CompositeType.
>>
>>  Can you please explain why?
>>
>>
>> On Wed, Dec 11, 2013 at 12:08 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>>
>>> What options are available depends on what version of Cassandra you're
>>> using.
>>>
>>> You can specify the row key type with 'key_validation_class'.
>>>
>>> For column types, use 'column_validation_classes', which is a dict
>>> mapping column names to types.  For example:
>>>
>>> sys.create_column_family('mykeyspace', 'users',
>>> column_validation_classes={'username': UTF8Type, 'age': IntegerType})
>>>
>>>
>>> On Wed, Dec 11, 2013 at 10:32 AM, Kumar Ranjan <wi...@gmail.com>wrote:
>>>
>>>> What are the all possible values for cf_kwargs ??
>>>>
>>>> SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
>>>> comparator_type=UTF8Type, ???? )
>>>>
>>>> ???? - Here I want to specify, Column data types and row key type. How
>>>> can I do that ?
>>>>
>>>>
>>>> On Thu, Aug 15, 2013 at 12:30 PM, Tyler Hobbs <ty...@datastax.com>wrote:
>>>>
>>>>> The column_validation_classes arg is just for defining individual
>>>>> column types.  Glad you got it figured out, though.
>>>>>
>>>>>
>>>>> On Thu, Aug 15, 2013 at 11:23 AM, Pinak Pani <
>>>>> nishant.has.a.question@gmail.com> wrote:
>>>>>
>>>>>> Thanks for quick reply. Apparantly, I was trying this to get working
>>>>>>
>>>>>> cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
>>>>>> sys.create_column_family('my_ks', 'vote_count',
>>>>>> column_validation_classes=cf_kwargs)  #1
>>>>>>
>>>>>> But this works:
>>>>>>
>>>>>> sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2
>>>>>>
>>>>>> I thought #1 should work.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com>wrote:
>>>>>>
>>>>>>> The only thing that makes a CF a counter CF is that the default
>>>>>>> validation class is CounterColumnType, which you can set through
>>>>>>> SystemManager.create_column_family().
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
>>>>>>> nishant.has.a.question@gmail.com> wrote:
>>>>>>>
>>>>>>>> I do not find a way to create a counter column family in Pycassa.
>>>>>>>> This[1] does not help.
>>>>>>>>
>>>>>>>> Appreciate if someone can help me.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>>  1.
>>>>>>>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Tyler Hobbs
>>>>>>> DataStax <http://datastax.com/>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Tyler Hobbs
>>>>> DataStax <http://datastax.com/>
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Tyler Hobbs
>>> DataStax <http://datastax.com/>
>>>
>>
>>
>

Re: How to create counter column family via Pycassa?

Posted by Kumar Ranjan <wi...@gmail.com>.
I am using ccm cassandra version

*1.2.11*


On Wed, Dec 11, 2013 at 12:19 PM, Kumar Ranjan <wi...@gmail.com> wrote:

> validators = {
>
>     'approved':      'BooleanType',
>
>     'text':          'UTF8Type',
>
>     'favorite_count':'IntegerType',
>
>     'retweet_count': 'IntegerType',
>
>     'expanded_url':  'UTF8Type',
>
>     'tuid':          'LongType',
>
>     'screen_name':   'UTF8Type',
>
>     'profile_image': 'UTF8Type',
>
>     'embedly_data':  'CompositeType',
>
>     'created_at':    'UTF8Type',
>
> }
>
> SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
> comparator_type='CompositeType', default_validation_class='UTF8Type',
> key_validation_class='UTF8Type', column_validation_classes=validators)
>
>
> throws:
>
> *InvalidRequestException*: InvalidRequestException(why='Invalid
> definition for comparator org.apache.cassandra.db.marshal.CompositeType.
>
>  Can you please explain why?
>
>
> On Wed, Dec 11, 2013 at 12:08 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>
>> What options are available depends on what version of Cassandra you're
>> using.
>>
>> You can specify the row key type with 'key_validation_class'.
>>
>> For column types, use 'column_validation_classes', which is a dict
>> mapping column names to types.  For example:
>>
>> sys.create_column_family('mykeyspace', 'users',
>> column_validation_classes={'username': UTF8Type, 'age': IntegerType})
>>
>>
>> On Wed, Dec 11, 2013 at 10:32 AM, Kumar Ranjan <wi...@gmail.com>wrote:
>>
>>> What are the all possible values for cf_kwargs ??
>>>
>>> SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
>>> comparator_type=UTF8Type, ???? )
>>>
>>> ???? - Here I want to specify, Column data types and row key type. How
>>> can I do that ?
>>>
>>>
>>> On Thu, Aug 15, 2013 at 12:30 PM, Tyler Hobbs <ty...@datastax.com>wrote:
>>>
>>>> The column_validation_classes arg is just for defining individual
>>>> column types.  Glad you got it figured out, though.
>>>>
>>>>
>>>> On Thu, Aug 15, 2013 at 11:23 AM, Pinak Pani <
>>>> nishant.has.a.question@gmail.com> wrote:
>>>>
>>>>> Thanks for quick reply. Apparantly, I was trying this to get working
>>>>>
>>>>> cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
>>>>> sys.create_column_family('my_ks', 'vote_count',
>>>>> column_validation_classes=cf_kwargs)  #1
>>>>>
>>>>> But this works:
>>>>>
>>>>> sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2
>>>>>
>>>>> I thought #1 should work.
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com>wrote:
>>>>>
>>>>>> The only thing that makes a CF a counter CF is that the default
>>>>>> validation class is CounterColumnType, which you can set through
>>>>>> SystemManager.create_column_family().
>>>>>>
>>>>>>
>>>>>> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
>>>>>> nishant.has.a.question@gmail.com> wrote:
>>>>>>
>>>>>>> I do not find a way to create a counter column family in Pycassa.
>>>>>>> This[1] does not help.
>>>>>>>
>>>>>>> Appreciate if someone can help me.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>>  1.
>>>>>>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Tyler Hobbs
>>>>>> DataStax <http://datastax.com/>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Tyler Hobbs
>>>> DataStax <http://datastax.com/>
>>>>
>>>
>>>
>>
>>
>> --
>> Tyler Hobbs
>> DataStax <http://datastax.com/>
>>
>
>

Re: How to create counter column family via Pycassa?

Posted by Kumar Ranjan <wi...@gmail.com>.
validators = {

    'approved':      'BooleanType',

    'text':          'UTF8Type',

    'favorite_count':'IntegerType',

    'retweet_count': 'IntegerType',

    'expanded_url':  'UTF8Type',

    'tuid':          'LongType',

    'screen_name':   'UTF8Type',

    'profile_image': 'UTF8Type',

    'embedly_data':  'CompositeType',

    'created_at':    'UTF8Type',

}

SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
comparator_type='CompositeType', default_validation_class='UTF8Type',
key_validation_class='UTF8Type', column_validation_classes=validators)


throws:

*InvalidRequestException*: InvalidRequestException(why='Invalid definition
for comparator org.apache.cassandra.db.marshal.CompositeType.

 Can you please explain why?


On Wed, Dec 11, 2013 at 12:08 PM, Tyler Hobbs <ty...@datastax.com> wrote:

> What options are available depends on what version of Cassandra you're
> using.
>
> You can specify the row key type with 'key_validation_class'.
>
> For column types, use 'column_validation_classes', which is a dict mapping
> column names to types.  For example:
>
> sys.create_column_family('mykeyspace', 'users',
> column_validation_classes={'username': UTF8Type, 'age': IntegerType})
>
>
> On Wed, Dec 11, 2013 at 10:32 AM, Kumar Ranjan <wi...@gmail.com>wrote:
>
>> What are the all possible values for cf_kwargs ??
>>
>> SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
>> comparator_type=UTF8Type, ???? )
>>
>> ???? - Here I want to specify, Column data types and row key type. How
>> can I do that ?
>>
>>
>> On Thu, Aug 15, 2013 at 12:30 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>>
>>> The column_validation_classes arg is just for defining individual column
>>> types.  Glad you got it figured out, though.
>>>
>>>
>>> On Thu, Aug 15, 2013 at 11:23 AM, Pinak Pani <
>>> nishant.has.a.question@gmail.com> wrote:
>>>
>>>> Thanks for quick reply. Apparantly, I was trying this to get working
>>>>
>>>> cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
>>>> sys.create_column_family('my_ks', 'vote_count',
>>>> column_validation_classes=cf_kwargs)  #1
>>>>
>>>> But this works:
>>>>
>>>> sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2
>>>>
>>>> I thought #1 should work.
>>>>
>>>>
>>>>
>>>> On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com>wrote:
>>>>
>>>>> The only thing that makes a CF a counter CF is that the default
>>>>> validation class is CounterColumnType, which you can set through
>>>>> SystemManager.create_column_family().
>>>>>
>>>>>
>>>>> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
>>>>> nishant.has.a.question@gmail.com> wrote:
>>>>>
>>>>>> I do not find a way to create a counter column family in Pycassa.
>>>>>> This[1] does not help.
>>>>>>
>>>>>> Appreciate if someone can help me.
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>>  1.
>>>>>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Tyler Hobbs
>>>>> DataStax <http://datastax.com/>
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Tyler Hobbs
>>> DataStax <http://datastax.com/>
>>>
>>
>>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Re: How to create counter column family via Pycassa?

Posted by Tyler Hobbs <ty...@datastax.com>.
What options are available depends on what version of Cassandra you're
using.

You can specify the row key type with 'key_validation_class'.

For column types, use 'column_validation_classes', which is a dict mapping
column names to types.  For example:

sys.create_column_family('mykeyspace', 'users',
column_validation_classes={'username': UTF8Type, 'age': IntegerType})


On Wed, Dec 11, 2013 at 10:32 AM, Kumar Ranjan <wi...@gmail.com> wrote:

> What are the all possible values for cf_kwargs ??
>
> SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
> comparator_type=UTF8Type, ???? )
>
> ???? - Here I want to specify, Column data types and row key type. How can
> I do that ?
>
>
> On Thu, Aug 15, 2013 at 12:30 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>
>> The column_validation_classes arg is just for defining individual column
>> types.  Glad you got it figured out, though.
>>
>>
>> On Thu, Aug 15, 2013 at 11:23 AM, Pinak Pani <
>> nishant.has.a.question@gmail.com> wrote:
>>
>>> Thanks for quick reply. Apparantly, I was trying this to get working
>>>
>>> cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
>>> sys.create_column_family('my_ks', 'vote_count',
>>> column_validation_classes=cf_kwargs)  #1
>>>
>>> But this works:
>>>
>>> sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2
>>>
>>> I thought #1 should work.
>>>
>>>
>>>
>>> On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>>>
>>>> The only thing that makes a CF a counter CF is that the default
>>>> validation class is CounterColumnType, which you can set through
>>>> SystemManager.create_column_family().
>>>>
>>>>
>>>> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
>>>> nishant.has.a.question@gmail.com> wrote:
>>>>
>>>>> I do not find a way to create a counter column family in Pycassa.
>>>>> This[1] does not help.
>>>>>
>>>>> Appreciate if someone can help me.
>>>>>
>>>>> Thanks
>>>>>
>>>>>  1.
>>>>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Tyler Hobbs
>>>> DataStax <http://datastax.com/>
>>>>
>>>
>>>
>>
>>
>> --
>> Tyler Hobbs
>> DataStax <http://datastax.com/>
>>
>
>


-- 
Tyler Hobbs
DataStax <http://datastax.com/>

Re: How to create counter column family via Pycassa?

Posted by Kumar Ranjan <wi...@gmail.com>.
What are the all possible values for cf_kwargs ??

SYSTEM_MANAGER.create_column_family('Narrative','Twitter_search_test',
comparator_type=UTF8Type, ???? )

???? - Here I want to specify, Column data types and row key type. How can
I do that ?


On Thu, Aug 15, 2013 at 12:30 PM, Tyler Hobbs <ty...@datastax.com> wrote:

> The column_validation_classes arg is just for defining individual column
> types.  Glad you got it figured out, though.
>
>
> On Thu, Aug 15, 2013 at 11:23 AM, Pinak Pani <
> nishant.has.a.question@gmail.com> wrote:
>
>> Thanks for quick reply. Apparantly, I was trying this to get working
>>
>> cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
>> sys.create_column_family('my_ks', 'vote_count',
>> column_validation_classes=cf_kwargs)  #1
>>
>> But this works:
>>
>> sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2
>>
>> I thought #1 should work.
>>
>>
>>
>> On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>>
>>> The only thing that makes a CF a counter CF is that the default
>>> validation class is CounterColumnType, which you can set through
>>> SystemManager.create_column_family().
>>>
>>>
>>> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
>>> nishant.has.a.question@gmail.com> wrote:
>>>
>>>> I do not find a way to create a counter column family in Pycassa.
>>>> This[1] does not help.
>>>>
>>>> Appreciate if someone can help me.
>>>>
>>>> Thanks
>>>>
>>>>  1.
>>>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>>>
>>>
>>>
>>>
>>> --
>>> Tyler Hobbs
>>> DataStax <http://datastax.com/>
>>>
>>
>>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Re: How to create counter column family via Pycassa?

Posted by Tyler Hobbs <ty...@datastax.com>.
The column_validation_classes arg is just for defining individual column
types.  Glad you got it figured out, though.


On Thu, Aug 15, 2013 at 11:23 AM, Pinak Pani <
nishant.has.a.question@gmail.com> wrote:

> Thanks for quick reply. Apparantly, I was trying this to get working
>
> cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
> sys.create_column_family('my_ks', 'vote_count',
> column_validation_classes=cf_kwargs)  #1
>
> But this works:
>
> sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2
>
> I thought #1 should work.
>
>
>
> On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com> wrote:
>
>> The only thing that makes a CF a counter CF is that the default
>> validation class is CounterColumnType, which you can set through
>> SystemManager.create_column_family().
>>
>>
>> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
>> nishant.has.a.question@gmail.com> wrote:
>>
>>> I do not find a way to create a counter column family in Pycassa.
>>> This[1] does not help.
>>>
>>> Appreciate if someone can help me.
>>>
>>> Thanks
>>>
>>>  1.
>>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>>
>>
>>
>>
>> --
>> Tyler Hobbs
>> DataStax <http://datastax.com/>
>>
>
>


-- 
Tyler Hobbs
DataStax <http://datastax.com/>

Re: How to create counter column family via Pycassa?

Posted by Pinak Pani <ni...@gmail.com>.
Thanks for quick reply. Apparantly, I was trying this to get working

cf_kwargs = {'default_validation_class':COUNTER_COLUMN_TYPE}
sys.create_column_family('my_ks', 'vote_count',
column_validation_classes=cf_kwargs)  #1

But this works:

sys.create_column_family('my_ks', 'vote_count', **cf_kwargs)  #2

I thought #1 should work.



On Thu, Aug 15, 2013 at 9:15 PM, Tyler Hobbs <ty...@datastax.com> wrote:

> The only thing that makes a CF a counter CF is that the default validation
> class is CounterColumnType, which you can set through
> SystemManager.create_column_family().
>
>
> On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
> nishant.has.a.question@gmail.com> wrote:
>
>> I do not find a way to create a counter column family in Pycassa.
>> This[1] does not help.
>>
>> Appreciate if someone can help me.
>>
>> Thanks
>>
>>  1.
>> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>>
>
>
>
> --
> Tyler Hobbs
> DataStax <http://datastax.com/>
>

Re: How to create counter column family via Pycassa?

Posted by Tyler Hobbs <ty...@datastax.com>.
The only thing that makes a CF a counter CF is that the default validation
class is CounterColumnType, which you can set through
SystemManager.create_column_family().


On Thu, Aug 15, 2013 at 10:38 AM, Pinak Pani <
nishant.has.a.question@gmail.com> wrote:

> I do not find a way to create a counter column family in Pycassa.
> This[1] does not help.
>
> Appreciate if someone can help me.
>
> Thanks
>
> 1.
> http://pycassa.github.io/pycassa/api/pycassa/system_manager.html#pycassa.system_manager.SystemManager.create_column_family
>



-- 
Tyler Hobbs
DataStax <http://datastax.com/>