here is a reproduction using python 3.9 and client version 6.0.0
import aerospike
from aerospike_helpers import cdt_ctx, expressions
from aerospike_helpers.operations import expression_operations
ac = aerospike.client({'hosts': [('localhost', 3000)]})
ac.connect()
key = ('test', 'test', 'test')
try:
ac.remove(key)
except:
pass
ac.put(key, {'bin': [{'key': 'value0'}]})
print(ac.get(key)[2])
ac.operate(
key,
[
expression_operations.expression_write(
bin_name='bin',
expression=expressions.Cond(
expressions.Eq(
# expressions.MapGetByKey(
# ctx=None,
# return_type=aerospike.MAP_RETURN_VALUE,
# value_type=expressions.resources.ResultType.STRING,
# key='key',
# bin=expressions.ListGetByIndex(
# ctx=None,
# return_type=aerospike.LIST_RETURN_VALUE,
# value_type=expressions.resources.ResultType.MAP,
# index=0,
# bin='bin'
# )
# ),
expressions.MapGetByKey(
ctx=[cdt_ctx.cdt_ctx_list_index(0)],
return_type=aerospike.MAP_RETURN_VALUE,
value_type=expressions.resources.ResultType.STRING,
key='key',
bin='bin'
),
'value0',
),
[{'key': 'value1'}],
expressions.Unknown()
).compile()
),
]
)
print(ac.get(key)[2])
i get output
exception.OpNotApplicable: (26, '127.0.0.1:3000 AEROSPIKE_ERR_OP_NOT_APPLICABLE', 'src/main/client/operate.c', 813, False)
when using the commented out MapGetByKey
above which uses ListGetByIndex
instead, i get the expected
{'bin': [{'key': 'value0'}]}
{'bin': [{'key': 'value1'}]}
but these should be equivalent operations correct? are there advantages to using the cdt_ctx
(i do think the cdt_ctx
is syntactically better at the very least)?