Skip to content
Browse files

Merge branch 'master' of https://github.com/neikos/HyperDex

* 'master' of https://github.com/neikos/HyperDex:
  Python API: map_atomic_xxx() fix.
  This commit and all previous that I have authored are signed off by me
  Typo in python API: 'int' should be 'int64'
  • Loading branch information...
2 parents 55ea359 + 2f9f143 commit 0c510d86be3d0790c55e373cb07dce67c45e75d2 @rescrv rescrv committed
Showing with 15 additions and 15 deletions.
  1. +15 −15 hyperclient/python/hyperclient.pyx
View
30 hyperclient/python/hyperclient.pyx
@@ -227,7 +227,7 @@ cdef _obj_to_backing(v):
mixedtype = TypeError("Cannot store heterogeneous maps")
for x, y in v.iteritems():
if isinstance(x, int):
- if keytype not in ('int', None):
+ if keytype not in ('int64', None):
raise mixedtype
backing += struct.pack('<q', x)
keytype = 'int64'
@@ -240,7 +240,7 @@ cdef _obj_to_backing(v):
else:
raise mixedtype
if isinstance(y, int):
- if valtype not in ('int', None):
+ if valtype not in ('int64', None):
raise mixedtype
backing += struct.pack('<q', y)
valtype = 'int64'
@@ -288,7 +288,7 @@ cdef _dict_to_map_attrs(list value, hyperclient_map_attribute** attrs, size_t* a
cdef dict b
cdef bytes name
cdef long i = 0
- attrs_sz[0] = sizeof(hyperclient_map_attribute) * sum([len(a) for a in value])
+ attrs_sz[0] = sum([len(a[1]) for a in value])
attrs[0] = <hyperclient_map_attribute*> \
malloc(sizeof(hyperclient_map_attribute) * attrs_sz[0])
if attrs[0] == NULL:
@@ -674,40 +674,40 @@ cdef class DeferredMapOp(Deferred):
# get Cython to work with function pointers correctly
if op == 'map_add':
self._reqid = hyperclient_map_add(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_remove':
self._reqid = hyperclient_map_remove(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_add':
self._reqid = hyperclient_map_atomic_add(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_sub':
self._reqid = hyperclient_map_atomic_sub(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_mul':
self._reqid = hyperclient_map_atomic_mul(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_div':
self._reqid = hyperclient_map_atomic_div(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_mod':
self._reqid = hyperclient_map_atomic_mod(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_and':
self._reqid = hyperclient_map_atomic_and(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_or':
self._reqid = hyperclient_map_atomic_or(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_atomic_xor':
self._reqid = hyperclient_map_atomic_xor(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_string_prepend':
self._reqid = hyperclient_map_string_prepend(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
elif op == 'map_string_append':
self._reqid = hyperclient_map_string_append(client._client, space_cstr,
- key_cstr, len(key_backing), attrs, len(value), &self._status)
+ key_cstr, len(key_backing), attrs, attrs_sz, &self._status)
else:
raise AttributeError("op == {0} is not valid".format(op))
if self._reqid < 0:

0 comments on commit 0c510d8

Please sign in to comment.
Something went wrong with that request. Please try again.