Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added support for DynamicCompositeType. #183

Merged
merged 1 commit into from Jan 11, 2013

Conversation

Projects
None yet
2 participants
Contributor

umairmufti commented Jan 8, 2013

We needed to use DynamicCompositeTypes for our project so I went ahead and added support for it in Pycassa. I wanted to contribute back as a way to say thanks and in the hopes that some others may find it useful.

Usage is very similar to the way CompositeTypes work, except that every component is a 2-tuple (comparator type, value). The comparator type can either be a full CassandraType or an alias, if one was given when the column family was created.

In order to create a column family with aliases, simply create a DynamicCompositeType object with a dictionary of aliases and use that for the comparator.

Example:
comparator = DynamicCompositeType({'L': LongType(reversed=True), 'a': AsciiType()})
sys.create_column_family("Keyspace1", "CF1", comparator_type=comparator)

cf = ColumnFamily(pool, "CF1")
comp1 = ('L', 1234)
comp2 = ('a', "abc")
comp3 = ('UTF8Type', "look ma, no hands!")
cf.insert("key", {(comp1, comp2, comp3): "colval"})

Hope this helps!

Owner

thobbs commented Jan 8, 2013

Wow, this looks awesome, great work! Thank you very much for taking the time to write tests and good docs.

It will take a little while to review it, but I should be able to get this merged in pretty soon.

Contributor

umairmufti commented Jan 11, 2013

Thanks, Tyler. Both, for the kind words, as well as for creating a kick-ass library to begin with.

@thobbs thobbs added a commit that referenced this pull request Jan 11, 2013

@thobbs thobbs Merge pull request #183 from umairmufti/develop
Added support for DynamicCompositeType.
79534e8

@thobbs thobbs merged commit 79534e8 into pycassa:master Jan 11, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment