Added support for DynamicCompositeType. #183

Merged
merged 1 commit into from Jan 11, 2013

Projects

None yet

2 participants

@umairmufti

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!

@thobbs
Member
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.

@umairmufti

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

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

1 check passed

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