Merge pull request #33 from michaelplaing/cqltypes

Amend 'set' and 'map' types to conform to C* sorting/ordering.
This commit is contained in:
Tyler Hobbs
2013-09-16 15:36:45 -07:00
3 changed files with 11 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ Installation through pip is recommended:
If you want to install manually, you can instead do:
$ sudo pip install futures scales # install dependencies
$ sudo pip install futures scales blist # install dependencies
$ sudo python setup.py install
C Extensions

View File

@@ -35,6 +35,13 @@ apache_cassandra_type_prefix = 'org.apache.cassandra.db.marshal.'
_number_types = frozenset((int, long, float))
from blist import sortedset
try:
from collections import OrderedDict
except ImportError: # Python <2.7
from cassandra.util import OrderedDict # NOQA
def trim_if_startswith(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
@@ -581,7 +588,7 @@ class ListType(_SimpleParameterizedType):
class SetType(_SimpleParameterizedType):
typename = 'set'
num_subtypes = 1
adapter = set
adapter = sortedset
class MapType(_ParameterizedType):
@@ -598,7 +605,7 @@ class MapType(_ParameterizedType):
subkeytype, subvaltype = cls.subtypes
numelements = uint16_unpack(byts[:2])
p = 2
themap = {}
themap = OrderedDict()
for n in xrange(numelements):
key_len = uint16_unpack(byts[p:p + 2])
p += 2

View File

@@ -180,7 +180,7 @@ setup(
author_email='tyler@datastax.com',
packages=["cassandra", "cassandra.io"],
features=features,
install_requires=['futures', 'scales'],
install_requires=['futures', 'scales', 'blist'],
tests_require=['nose', 'mock', 'ccm'],
cmdclass={"build_ext": build_extensions,
"doc": doc},