From 0fa3ed2c5d5986937131f94d1b123398cd8a37e8 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:32:04 -0800 Subject: [PATCH 01/41] First pass at refactoring. Many memory leaks present --- src/main/client/cdt_list_operate.c | 2072 ++++------------------------ 1 file changed, 277 insertions(+), 1795 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index ca83b51c52..fa8fb6a0c3 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -30,211 +30,6 @@ #include "cdt_list_operations.h" #include "cdt_operation_utils.h" -static as_status add_op_list_create(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_append(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_append_items(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_insert(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_insert_items(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_increment(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_size(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_pop(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_pop_range(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_remove(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_remove_range(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_clear(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_get(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_get_range(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_trim(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_set(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -/* NEW CDT LIST OPERATIONS Post 3.16.0.1*/ -/* GET BY*/ -static as_status add_op_list_get_by_index(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status -add_op_list_get_by_index_range(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_get_by_rank(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status -add_op_list_get_by_rank_range(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_get_by_value(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -static as_status -add_op_list_get_by_value_list(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -static as_status -add_op_list_get_by_value_range(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -/* remove by*/ - -static as_status -add_op_list_remove_by_index(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_remove_by_index_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, as_operations *ops, - as_static_pool *static_pool, int serializer_type); - -static as_status -add_op_list_remove_by_rank(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_remove_by_rank_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, as_operations *ops, - as_static_pool *static_pool, int serializer_type); - -static as_status -add_op_list_remove_by_value(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type); - -static as_status add_op_list_remove_by_value_list( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, as_operations *ops, - as_static_pool *static_pool, int serializer_type); - -static as_status add_op_list_remove_by_value_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_operations *ops, as_static_pool *static_pool, int serializer_type); - -/* Set Order*/ -static as_status add_op_list_set_order(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -/* List sort*/ -static as_status add_op_list_sort(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type); - -/* Server 4.3.0 relative operations*/ - -static as_status add_add_op_list_remove_by_value_rel_rank_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_operations *ops, as_static_pool *static_pool, int serializer_type); - -static as_status add_add_op_list_get_by_value_rel_rank_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_operations *ops, as_static_pool *static_pool, int serializer_type); -/* End forwards*/ as_status add_new_list_op(AerospikeClient *self, as_error *err, PyObject *op_dict, as_vector *unicodeStrVector, as_static_pool *static_pool, as_operations *ops, @@ -248,1671 +43,358 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, return err->code; } + as_list_policy list_policy; + bool policy_in_use = false; + switch (operation_code) { case OP_LIST_APPEND: - return add_op_list_append(self, err, bin, op_dict, ops, static_pool, - serializer_type); + case OP_LIST_APPEND_ITEMS: + case OP_LIST_INSERT: + case OP_LIST_INSERT_ITEMS: + case OP_LIST_INCREMENT: + case OP_LIST_SET: + if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, + self->validate_keys) != AEROSPIKE_OK) { + return err->code; + } + break; + } + as_val *val = NULL; + switch (operation_code) { + case OP_LIST_GET_BY_VALUE: + case OP_LIST_GET_BY_VALUE_LIST: + case OP_LIST_REMOVE_BY_VALUE: case OP_LIST_APPEND_ITEMS: - return add_op_list_append_items(self, err, bin, op_dict, ops, - static_pool, serializer_type); + case OP_LIST_INSERT: + case OP_LIST_INCREMENT: + case OP_LIST_SET: + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, + serializer_type, true) != AEROSPIKE_OK) { + return err->code; + } + break; + } - case OP_LIST_SIZE: - return add_op_list_size(self, err, bin, op_dict, ops, static_pool, - serializer_type); + int64_t count; + bool range_specified = false; + switch (operation_code) { + case OP_LIST_POP_RANGE: + if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { + return err->code; + } + break; + case OP_LIST_GET_BY_INDEX_RANGE: + if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, + &range_specified) != AEROSPIKE_OK) { + return err->code; + } + break; + } - case OP_LIST_INSERT: - return add_op_list_insert(self, err, bin, op_dict, ops, static_pool, - serializer_type); + int return_type = AS_LIST_RETURN_VALUE; + if (OP_LIST_GET_BY_INDEX <= operation_code <= + OP_LIST_REMOVE_BY_VALUE_RANGE) { + if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { + return err->code; + } + } - case OP_LIST_INSERT_ITEMS: - return add_op_list_insert_items(self, err, bin, op_dict, ops, - static_pool, serializer_type); + int64_t index; + if (operation_code == OP_LIST_POP) { + if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != + AEROSPIKE_OK) { + return err->code; + } + } - case OP_LIST_INCREMENT: - return add_op_list_increment(self, err, bin, op_dict, ops, static_pool, - serializer_type); + bool ctx_in_use = false; + as_cdt_ctx ctx; + // TODO: not all operations may take in ctx param + if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, + serializer_type) != AEROSPIKE_OK) { + return err->code; + } - case OP_LIST_POP: - return add_op_list_pop(self, err, bin, op_dict, ops, static_pool, - serializer_type); + int64_t rank; + switch (operation_code) { + case OP_LIST_GET_BY_RANK: + if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { + return err->code; + } + } - case OP_LIST_POP_RANGE: - return add_op_list_pop_range(self, err, bin, op_dict, ops, static_pool, - serializer_type); + as_list *value_list = NULL; + switch (operation_code) { + case OP_LIST_REMOVE_BY_VALUE_LIST: + if (get_val_list(self, err, AS_PY_VALUES_KEY, op_dict, &value_list, + static_pool, serializer_type) != AEROSPIKE_OK) { + return err->code; + } + break; + } - case OP_LIST_REMOVE: - return add_op_list_remove(self, err, bin, op_dict, ops, static_pool, - serializer_type); + as_val *val_begin = NULL; + as_val *val_end = NULL; + if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, + static_pool, serializer_type, false) != AEROSPIKE_OK) { + return err->code; + } - case OP_LIST_REMOVE_RANGE: - return add_op_list_remove_range(self, err, bin, op_dict, ops, - static_pool, serializer_type); + if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, + serializer_type, false) != AEROSPIKE_OK) { + return err->code; + } - case OP_LIST_CLEAR: - return add_op_list_clear(self, err, bin, op_dict, ops, static_pool, - serializer_type); + int64_t order_type_int; + if (operation_code == OP_LIST_CREATE || operation_code == OP_LIST_SORT) { + if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != + AEROSPIKE_OK) { + return err->code; + } + } + bool success = false; + switch (operation_code) { + case OP_LIST_SIZE: + success = as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_POP: + success = + as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_POP_RANGE: + success = as_operations_list_pop_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_REMOVE: + success = as_operations_list_remove(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_REMOVE_RANGE: + success = as_operations_list_remove_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_CLEAR: + success = + as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; case OP_LIST_SET: - return add_op_list_set(self, err, bin, op_dict, ops, static_pool, - serializer_type); - + success = as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), + index, val); + break; case OP_LIST_GET: - return add_op_list_get(self, err, bin, op_dict, ops, static_pool, - serializer_type); - + success = + as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; case OP_LIST_GET_RANGE: - return add_op_list_get_range(self, err, bin, op_dict, ops, static_pool, - serializer_type); - + success = as_operations_list_get_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; case OP_LIST_TRIM: - return add_op_list_trim(self, err, bin, op_dict, ops, static_pool, - serializer_type); - /***** New List ops****/ - + success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), + index, (uint64_t)count); case OP_LIST_GET_BY_INDEX: { - return add_op_list_get_by_index(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + success = as_operations_list_get_by_index( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); } case OP_LIST_GET_BY_INDEX_RANGE: { - return add_op_list_get_by_index_range(self, err, bin, op_dict, - unicodeStrVector, ops, - static_pool, serializer_type); - } + if (range_specified) { + success = as_operations_list_get_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_index_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } case OP_LIST_GET_BY_RANK: { - return add_op_list_get_by_rank(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + success = as_operations_list_get_by_rank( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); } case OP_LIST_GET_BY_RANK_RANGE: { - return add_op_list_get_by_rank_range(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + if (range_specified) { + success = as_operations_list_get_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } } case OP_LIST_GET_BY_VALUE: { - return add_op_list_get_by_value(self, err, bin, op_dict, ops, - static_pool, serializer_type); + success = as_operations_list_get_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); } - case OP_LIST_GET_BY_VALUE_LIST: { - return add_op_list_get_by_value_list(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + success = as_operations_list_get_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); } case OP_LIST_GET_BY_VALUE_RANGE: { - return add_op_list_get_by_value_range(self, err, bin, op_dict, - unicodeStrVector, ops, - static_pool, serializer_type); + success = as_operations_list_get_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); } case OP_LIST_REMOVE_BY_INDEX: { - return add_op_list_remove_by_index(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + success = as_operations_list_remove_by_index( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + break; } case OP_LIST_REMOVE_BY_INDEX_RANGE: { - return add_op_list_remove_by_index_range(self, err, bin, op_dict, - unicodeStrVector, ops, - static_pool, serializer_type); + if (range_specified) { + success = as_operations_list_remove_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_remove_by_index_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } } case OP_LIST_REMOVE_BY_RANK: { - return add_op_list_remove_by_rank(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + success = as_operations_list_remove_by_rank( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + break; } case OP_LIST_REMOVE_BY_RANK_RANGE: { - return add_op_list_remove_by_rank_range(self, err, bin, op_dict, - unicodeStrVector, ops, - static_pool, serializer_type); + if (range_specified) { + success = as_operations_list_remove_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_remove_by_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } } case OP_LIST_REMOVE_BY_VALUE: { - return add_op_list_remove_by_value(self, err, bin, op_dict, - unicodeStrVector, ops, static_pool, - serializer_type); + success = as_operations_list_remove_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + break; } case OP_LIST_REMOVE_BY_VALUE_LIST: { - return add_op_list_remove_by_value_list(self, err, bin, op_dict, - unicodeStrVector, ops, - static_pool, serializer_type); - } + success = as_operations_list_remove_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; case OP_LIST_REMOVE_BY_VALUE_RANGE: { - return add_op_list_remove_by_value_range(self, err, bin, op_dict, ops, - static_pool, serializer_type); + success = as_operations_list_remove_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); } case OP_LIST_SET_ORDER: { - return add_op_list_set_order(self, err, bin, op_dict, ops, static_pool, - serializer_type); + success = + as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int); + break; } case OP_LIST_SORT: { - return add_op_list_sort(self, err, bin, op_dict, ops, static_pool, - serializer_type); - } + int64_t sort_flags; - case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: { - return add_add_op_list_remove_by_value_rel_rank_range( - self, err, bin, op_dict, ops, static_pool, serializer_type); + if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != + AEROSPIKE_OK) { + return err->code; + } + success = as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_sort_flags)sort_flags); + break; } case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { - return add_add_op_list_get_by_value_rel_rank_range( - self, err, bin, op_dict, ops, static_pool, serializer_type); } case OP_LIST_CREATE: { - return add_op_list_create(self, err, bin, op_dict, ops, static_pool, - serializer_type); - } - - default: - // This should never be possible since we only get here if we know that the operation is valid. - return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); - } - - return err->code; -} - -static as_status add_op_list_get_by_index(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_get_by_index(ops, bin, (ctx_in_use ? &ctx : NULL), - index, return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add get_by_list_index operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status -add_op_list_get_by_index_range(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int64_t count; - bool range_specified = false; - bool success = false; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count of items, and store whether it was found in range_specified*/ - if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, - &range_specified) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (range_specified) { - success = as_operations_list_get_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - - if (!success) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add get_by_list_index_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_get_by_rank(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t rank; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } + bool pad, persist_index; + if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != + AEROSPIKE_OK) { + return err->code; + } - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } + if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, + &persist_index) != AEROSPIKE_OK) { + return err->code; + } - if (!as_operations_list_get_by_rank(ops, bin, (ctx_in_use ? &ctx : NULL), - rank, return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add get_by_list_index operation"); + success = as_operations_list_create_all( + ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, + pad, persist_index); + break; } + case OP_LIST_APPEND: + success = as_operations_list_append( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), val); + break; + case OP_LIST_APPEND_ITEMS: + success = as_operations_list_append_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), value_list); + break; + case OP_LIST_INSERT: + success = as_operations_list_insert( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_INSERT_ITEMS: + success = as_operations_list_insert_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, value_list); + case OP_LIST_INCREMENT: + success = as_operations_list_increment( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + if (range_specified) { + if (!as_operations_list_remove_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); + } + } + else { + if (!as_operations_list_remove_by_value_rel_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); + } + } + break; - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); + default: { + // This should never be possible since we only get here if we know that the operation is valid. + return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); } - - return err->code; -} - -static as_status -add_op_list_get_by_rank_range(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - int64_t rank; - int64_t count; - bool range_specified = false; - bool success = false; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; } - /* Get the count of items, and store whether it was found in range_specified*/ - if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, - &range_specified) != AEROSPIKE_OK) { - return err->code; - } - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } + if (!success) { + // TODO: regression in error message + as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add operation"); + } - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { return err->code; } - - if (range_specified) { - success = as_operations_list_get_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - - if (!success) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_get_by_rank_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_get_by_value(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_val *val = NULL; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to convert ctx list"); - } - - if (!as_operations_list_get_by_value(ops, bin, (ctx_in_use ? &ctx : NULL), - val, return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_get_by_value operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status -add_op_list_get_by_value_list(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - as_list *value_list = NULL; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_val_list(self, err, AS_PY_VALUES_KEY, op_dict, &value_list, - static_pool, serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - /* Failed to add the operation, we need to destroy the list of values*/ - as_val_destroy(value_list); - return err->code; - } - - if (!as_operations_list_get_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type)) { - /* Failed to add the operation, we need to destroy the list of values*/ - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_get_by_value_list operation"); - as_val_destroy(value_list); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status -add_op_list_get_by_value_range(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - as_val *val_begin = NULL; - as_val *val_end = NULL; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - int return_type = AS_LIST_RETURN_VALUE; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, - static_pool, serializer_type, false) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, - serializer_type, false) != AEROSPIKE_OK) { - goto error; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - goto error; - } - - if (!as_operations_list_get_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_get_by_value_range operation"); - goto error; - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; - -error: - /* Free the as_vals if they exists*/ - if (val_begin) { - as_val_destroy(val_begin); - } - - if (val_end) { - as_val_destroy(val_end); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status -add_op_list_remove_by_index(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_remove_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add remove_by_list_index operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_remove_by_index_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, as_operations *ops, - as_static_pool *static_pool, int serializer_type) -{ - int64_t index; - int64_t count; - bool range_specified = false; - bool success = false; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count of items, and store whether it was found in range_specified*/ - if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, - &range_specified) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (range_specified) { - success = as_operations_list_remove_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_remove_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - - if (!success) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add remove_by_list_index_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status -add_op_list_remove_by_rank(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - int64_t rank; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_remove_by_rank(ops, bin, (ctx_in_use ? &ctx : NULL), - rank, return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_remove_by_rank operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_remove_by_rank_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, as_operations *ops, - as_static_pool *static_pool, int serializer_type) -{ - int64_t rank; - int64_t count; - bool range_specified = false; - bool success = false; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count of items, and store whether it was found in range_specified*/ - if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, - &range_specified) != AEROSPIKE_OK) { - return err->code; - } - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (range_specified) { - success = as_operations_list_remove_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_remove_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - - if (!success) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_remove_by_rank_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status -add_op_list_remove_by_value(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_vector *unicodeStrVector, - as_operations *ops, as_static_pool *static_pool, - int serializer_type) -{ - as_val *val = NULL; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(val); - return err->code; - } - - if (!as_operations_list_remove_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_remove_by_value operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_remove_by_value_list( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_vector *unicodeStrVector, as_operations *ops, - as_static_pool *static_pool, int serializer_type) -{ - as_list *value_list = NULL; - int return_type = AS_LIST_RETURN_VALUE; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_val_list(self, err, AS_PY_VALUES_KEY, op_dict, &value_list, - static_pool, serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - /* Failed to convert ctx, we need to destroy the list of values*/ - as_val_destroy(value_list); - return err->code; - } - - if (!as_operations_list_remove_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type)) { - /* Failed to add the operation, we need to destroy the list of values*/ - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_get_by_value_list operation"); - as_val_destroy(value_list); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_remove_by_value_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_operations *ops, as_static_pool *static_pool, int serializer_type) -{ - as_val *val_begin = NULL; - as_val *val_end = NULL; - bool ctx_in_use = false; - as_cdt_ctx ctx; - int return_type = AS_LIST_RETURN_VALUE; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, - static_pool, serializer_type, false) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, - serializer_type, false) != AEROSPIKE_OK) { - goto error; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - goto error; - } - - if (!as_operations_list_remove_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_remove_by_value_range operation"); - goto error; - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; - -error: - /* Free the as_vals if they exist */ - if (val_begin) { - as_val_destroy(val_begin); - } - - if (val_end) { - as_val_destroy(val_end); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_set_order(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t order_type_int; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_set_order operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_sort(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t sort_flags; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_sort_flags)sort_flags)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_sort operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_create(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t order_type_int; - as_cdt_ctx ctx; - bool ctx_in_use = false; - bool pad, persist_index; - - if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != AEROSPIKE_OK) { - return err->code; - } - - if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, - &persist_index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - bool add_op_successful = as_operations_list_create_all( - ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, - pad, persist_index); - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - if (add_op_successful) { - return AEROSPIKE_OK; - } - else { - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_create operation"); - } -} - -static as_status add_op_list_append(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_val *val = NULL; - as_list_policy list_policy; - bool policy_in_use = false; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, - self->validate_keys) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(val); - return err->code; - } - - if (!as_operations_list_append(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), - val)) { - as_val_destroy(val); - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_append operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_append_items(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_list *items_list = NULL; - as_list_policy list_policy; - bool policy_in_use = false; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, - self->validate_keys) != AEROSPIKE_OK) { - return err->code; - } - - if (get_val_list(self, err, AS_PY_VAL_KEY, op_dict, &items_list, - static_pool, serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(items_list); - return err->code; - } - - if (!as_operations_list_append_items(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), - items_list)) { - as_val_destroy(items_list); - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_append_items operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_insert(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_val *val = NULL; - int64_t index; - as_list_policy list_policy; - bool policy_in_use = false; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, - self->validate_keys) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(val); - return err->code; - } - - if (!as_operations_list_insert(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, - val)) { - as_val_destroy(val); - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_insert operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_insert_items(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_list *items_list = NULL; - int64_t index; - as_list_policy list_policy; - bool policy_in_use = false; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, - self->validate_keys) != AEROSPIKE_OK) { - return err->code; - } - - if (get_val_list(self, err, AS_PY_VAL_KEY, op_dict, &items_list, - static_pool, serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(items_list); - return err->code; - } - - if (!as_operations_list_insert_items(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), - index, items_list)) { - as_val_destroy(items_list); - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_insert_items operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_increment(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_val *incr = NULL; - int64_t index; - as_list_policy list_policy; - bool policy_in_use = false; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, - self->validate_keys) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &incr, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(incr); - return err->code; - } - - if (!as_operations_list_increment(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), - index, incr)) { - as_val_destroy(incr); - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_increment operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_pop(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_pop operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_pop_range(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int64_t count; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count*/ - if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_pop_range(ops, bin, (ctx_in_use ? &ctx : NULL), - index, (uint64_t)count)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to list_pop_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_remove(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - ; - return err->code; - } - - if (!as_operations_list_remove(ops, bin, (ctx_in_use ? &ctx : NULL), - index)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_remove operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_remove_range(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int64_t count; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count*/ - if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_remove_range(ops, bin, (ctx_in_use ? &ctx : NULL), - index, (uint64_t)count)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to list_remove_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_clear(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL))) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_clear operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_set(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_val *val = NULL; - int64_t index; - as_list_policy list_policy; - bool policy_in_use = false; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, - self->validate_keys) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - as_val_destroy(val); - return err->code; - } - - if (!as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, - val)) { - as_val_destroy(val); - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_set operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_get(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_get operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_op_list_get_range(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int64_t count; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count*/ - if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_get_range(ops, bin, (ctx_in_use ? &ctx : NULL), - index, (uint64_t)count)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to list_get_range operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_trim(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t index; - int64_t count; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - /* Get the index*/ - if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; - } - - /* Get the count*/ - if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), index, - (uint64_t)count)) { - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to list_trim operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return err->code; -} - -static as_status add_op_list_size(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL))) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list_size operation"); - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_add_op_list_remove_by_value_rel_rank_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_operations *ops, as_static_pool *static_pool, int serializer_type) -{ - bool count_present = false; - int64_t count; - int return_type; - int64_t rank; - as_val *value = NULL; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; - } - - if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, - &count_present) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &value, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (count_present) { - if (!as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), value, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update( - err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value rank relative operation"); - } - } - else { - if (!as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), value, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update( - err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value rank relative operation"); - } - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} - -static as_status add_add_op_list_get_by_value_rel_rank_range( - AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, - as_operations *ops, as_static_pool *static_pool, int serializer_type) -{ - - bool count_present = false; - int64_t count; - int return_type; - int64_t rank; - as_val *value = NULL; - bool ctx_in_use = false; - as_cdt_ctx ctx; - - if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; - } - - if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, - &count_present) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &value, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - return err->code; - } - - if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, - serializer_type) != AEROSPIKE_OK) { - return err->code; - } - - if (count_present) { - if (!as_operations_list_get_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), value, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update( - err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value rank relative operation"); - } - } - else { - if (!as_operations_list_get_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), value, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update( - err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value rank relative operation"); - } - } - - if (ctx_in_use) { - as_cdt_ctx_destroy(&ctx); - } - - return AEROSPIKE_OK; -} From b9d6ecd22876236e08fe81843a47a7f0a0b31652 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:34:34 -0800 Subject: [PATCH 02/41] fix --- src/main/client/cdt_list_operate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index fa8fb6a0c3..2ba8e9e706 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -95,8 +95,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int return_type = AS_LIST_RETURN_VALUE; - if (OP_LIST_GET_BY_INDEX <= operation_code <= - OP_LIST_REMOVE_BY_VALUE_RANGE) { + if (operation_code >= OP_LIST_GET_BY_INDEX && + operation_code <= OP_LIST_REMOVE_BY_VALUE_RANGE) { if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { return err->code; } From 5dab35281eca8c931bd10d57ff9f2ca7612e237c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:51:10 -0800 Subject: [PATCH 03/41] fix --- src/main/client/cdt_list_operate.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 2ba8e9e706..3514ac11e3 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -212,7 +212,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_get_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); } - + } case OP_LIST_GET_BY_RANK: { success = as_operations_list_get_by_rank( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); @@ -229,7 +229,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); } } - case OP_LIST_GET_BY_VALUE: { success = as_operations_list_get_by_value( ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); @@ -384,17 +383,15 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } break; - default: { + default: // This should never be possible since we only get here if we know that the operation is valid. return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); - } } - if (!success) { - // TODO: regression in error message - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add operation"); - } - - return err->code; + if (!success) { + // TODO: regression in error message + as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); } + + return err->code; +} From 8b524a3e21c24065b7126e3280e5d6ed2717ce44 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:12:35 -0800 Subject: [PATCH 04/41] fix --- src/main/client/cdt_list_operate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 3514ac11e3..32f940be22 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -317,6 +317,10 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { + success = as_operations_list_get_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, (uint64_t)count, + return_type); + break; } case OP_LIST_CREATE: { From e666b80d79805d7672d3d706d8c4bce53993634f Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:14:28 -0800 Subject: [PATCH 05/41] list_sort doesn't take in a list_order arg --- src/main/client/cdt_list_operate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 32f940be22..76b6255a16 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -149,7 +149,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int64_t order_type_int; - if (operation_code == OP_LIST_CREATE || operation_code == OP_LIST_SORT) { + if (operation_code == OP_LIST_CREATE) { if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != AEROSPIKE_OK) { return err->code; From 2e2b84f84a77c580e425b9850886d16028ef6611 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:26:45 -0800 Subject: [PATCH 06/41] fix index param related errors --- src/main/client/cdt_list_operate.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 76b6255a16..f6fd8302a2 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -103,7 +103,21 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int64_t index; - if (operation_code == OP_LIST_POP) { + switch (operation_code) { + case OP_LIST_POP: + case OP_LIST_POP_RANGE: + case OP_LIST_REMOVE: + case OP_LIST_REMOVE_RANGE: + case OP_LIST_SET: + case OP_LIST_GET_RANGE: + case OP_LIST_TRIM: + case OP_LIST_GET_BY_INDEX: + case OP_LIST_GET_BY_INDEX_RANGE: + case OP_LIST_REMOVE_BY_INDEX: + case OP_LIST_REMOVE_BY_INDEX_RANGE: + case OP_LIST_INSERT: + case OP_LIST_INSERT_ITEMS: + case OP_LIST_INCREMENT: if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { return err->code; From d6d5d016885d96ee489ae5158999bbd164de536d Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:40:20 -0800 Subject: [PATCH 07/41] Add missing breaks --- src/main/client/cdt_list_operate.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index f6fd8302a2..f6f5cf4768 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -211,10 +211,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_TRIM: success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; case OP_LIST_GET_BY_INDEX: { success = as_operations_list_get_by_index( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } + } break; case OP_LIST_GET_BY_INDEX_RANGE: { if (range_specified) { @@ -226,11 +227,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_get_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); } - } + } break; case OP_LIST_GET_BY_RANK: { success = as_operations_list_get_by_rank( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } + } break; case OP_LIST_GET_BY_RANK_RANGE: { if (range_specified) { @@ -242,21 +243,21 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_get_by_rank_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); } - } + } break; case OP_LIST_GET_BY_VALUE: { success = as_operations_list_get_by_value( ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - } + } break; case OP_LIST_GET_BY_VALUE_LIST: { success = as_operations_list_get_by_value_list( ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } + } break; case OP_LIST_GET_BY_VALUE_RANGE: { success = as_operations_list_get_by_value_range( ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, return_type); - } + } break; case OP_LIST_REMOVE_BY_INDEX: { success = as_operations_list_remove_by_index( @@ -274,7 +275,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_remove_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); } - } + } break; case OP_LIST_REMOVE_BY_RANK: { success = as_operations_list_remove_by_rank( @@ -292,7 +293,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_remove_by_rank_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); } - } + } break; case OP_LIST_REMOVE_BY_VALUE: { success = as_operations_list_remove_by_value( @@ -309,7 +310,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_remove_by_value_range( ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, return_type); - } + } break; case OP_LIST_SET_ORDER: { success = @@ -373,6 +374,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_insert_items( ops, bin, (ctx_in_use ? &ctx : NULL), (policy_in_use ? &list_policy : NULL), index, value_list); + break; case OP_LIST_INCREMENT: success = as_operations_list_increment( ops, bin, (ctx_in_use ? &ctx : NULL), From 3250d018c4a723d0ac97b1d8d09943e4eb88b983 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:48:18 -0800 Subject: [PATCH 08/41] Fix some operations not receiving the return type in python --- src/main/client/cdt_list_operate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index f6f5cf4768..2bcdbafe2c 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -95,8 +95,10 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int return_type = AS_LIST_RETURN_VALUE; - if (operation_code >= OP_LIST_GET_BY_INDEX && - operation_code <= OP_LIST_REMOVE_BY_VALUE_RANGE) { + if ((operation_code >= OP_LIST_GET_BY_INDEX && + operation_code <= OP_LIST_REMOVE_BY_VALUE_RANGE) || + (operation_code >= OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL && + operation_code <= OP_LIST_REMOVE_BY_RANK_RANGE_TO_END)) { if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { return err->code; } From c2c56f447142150b1711a0fcce1b27dd6b9f6b3b Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:30:19 -0800 Subject: [PATCH 09/41] fix. --- src/main/client/cdt_list_operate.c | 490 +++++++++++++++-------------- 1 file changed, 258 insertions(+), 232 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 2bcdbafe2c..aefa884e53 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -64,9 +64,15 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, switch (operation_code) { case OP_LIST_GET_BY_VALUE: case OP_LIST_GET_BY_VALUE_LIST: + case OP_LIST_GET_RANGE: case OP_LIST_REMOVE_BY_VALUE: + case OP_LIST_TRIM: + case OP_LIST_APPEND: case OP_LIST_APPEND_ITEMS: case OP_LIST_INSERT: + case OP_LIST_INSERT_ITEMS: + case OP_LIST_POP_RANGE: + case OP_LIST_REMOVE_RANGE: case OP_LIST_INCREMENT: case OP_LIST_SET: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: @@ -87,6 +93,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } break; case OP_LIST_GET_BY_INDEX_RANGE: + case OP_LIST_REMOVE_BY_INDEX_RANGE: + case OP_LIST_GET_BY_RANK_RANGE: + case OP_LIST_REMOVE_BY_RANK_RANGE: + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, &range_specified) != AEROSPIKE_OK) { return err->code; @@ -98,7 +109,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, if ((operation_code >= OP_LIST_GET_BY_INDEX && operation_code <= OP_LIST_REMOVE_BY_VALUE_RANGE) || (operation_code >= OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL && - operation_code <= OP_LIST_REMOVE_BY_RANK_RANGE_TO_END)) { + operation_code <= OP_LIST_GET_BY_VALUE_RANK_RANGE_REL)) { if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { return err->code; } @@ -111,6 +122,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE: case OP_LIST_REMOVE_RANGE: case OP_LIST_SET: + case OP_LIST_GET: case OP_LIST_GET_RANGE: case OP_LIST_TRIM: case OP_LIST_GET_BY_INDEX: @@ -128,7 +140,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, bool ctx_in_use = false; as_cdt_ctx ctx; - // TODO: not all operations may take in ctx param if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, serializer_type) != AEROSPIKE_OK) { return err->code; @@ -137,13 +148,20 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, int64_t rank; switch (operation_code) { case OP_LIST_GET_BY_RANK: + case OP_LIST_GET_BY_RANK_RANGE: + case OP_LIST_REMOVE_BY_RANK: + case OP_LIST_REMOVE_BY_RANK_RANGE: + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { return err->code; } + break; } as_list *value_list = NULL; switch (operation_code) { + case OP_LIST_GET_BY_VALUE_LIST: case OP_LIST_REMOVE_BY_VALUE_LIST: if (get_val_list(self, err, AS_PY_VALUES_KEY, op_dict, &value_list, static_pool, serializer_type) != AEROSPIKE_OK) { @@ -154,266 +172,274 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_val *val_begin = NULL; as_val *val_end = NULL; - if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, - static_pool, serializer_type, false) != AEROSPIKE_OK) { - return err->code; - } - - if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, - serializer_type, false) != AEROSPIKE_OK) { - return err->code; - } - - int64_t order_type_int; - if (operation_code == OP_LIST_CREATE) { - if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != - AEROSPIKE_OK) { + switch (operation_code) { + case OP_LIST_GET_BY_VALUE_LIST: + case OP_LIST_REMOVE_BY_VALUE_LIST: + if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, + static_pool, serializer_type, false) != AEROSPIKE_OK) { return err->code; } - } - bool success = false; - switch (operation_code) { - case OP_LIST_SIZE: - success = as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_POP: - success = - as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_POP_RANGE: - success = as_operations_list_pop_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_REMOVE: - success = as_operations_list_remove(ops, bin, - (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_REMOVE_RANGE: - success = as_operations_list_remove_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_CLEAR: - success = - as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_SET: - success = as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), - index, val); - break; - case OP_LIST_GET: - success = - as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_GET_RANGE: - success = as_operations_list_get_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_TRIM: - success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), - index, (uint64_t)count); + if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, + static_pool, serializer_type, false) != AEROSPIKE_OK) { + return err->code; + } break; - case OP_LIST_GET_BY_INDEX: { - success = as_operations_list_get_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } break; - - case OP_LIST_GET_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, - return_type); + + int64_t order_type_int; + if (operation_code == OP_LIST_CREATE) { + if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != + AEROSPIKE_OK) { + return err->code; + } } - else { - success = as_operations_list_get_by_index_range_to_end( + + bool success = false; + switch (operation_code) { + case OP_LIST_SIZE: + success = + as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_POP: + success = as_operations_list_pop(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_POP_RANGE: + success = as_operations_list_pop_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_REMOVE: + success = as_operations_list_remove( + ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_REMOVE_RANGE: + success = as_operations_list_remove_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_CLEAR: + success = + as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_SET: + success = as_operations_list_set( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_GET: + success = as_operations_list_get(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_GET_RANGE: + success = as_operations_list_get_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_TRIM: + success = as_operations_list_trim( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_GET_BY_INDEX: { + success = as_operations_list_get_by_index( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - } break; - case OP_LIST_GET_BY_RANK: { - success = as_operations_list_get_by_rank( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } break; - - case OP_LIST_GET_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_rank_range_to_end( + } break; + + case OP_LIST_GET_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, + (uint64_t)count, return_type); + } + else { + success = as_operations_list_get_by_index_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } + } break; + case OP_LIST_GET_BY_RANK: { + success = as_operations_list_get_by_rank( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - } break; - case OP_LIST_GET_BY_VALUE: { - success = as_operations_list_get_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - } break; - case OP_LIST_GET_BY_VALUE_LIST: { - success = as_operations_list_get_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; - - case OP_LIST_GET_BY_VALUE_RANGE: { - success = as_operations_list_get_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); - } break; - - case OP_LIST_REMOVE_BY_INDEX: { - success = as_operations_list_remove_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - break; - } + } break; - case OP_LIST_REMOVE_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, + case OP_LIST_GET_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } + } break; + case OP_LIST_GET_BY_VALUE: { + success = as_operations_list_get_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + } break; + case OP_LIST_GET_BY_VALUE_LIST: { + success = as_operations_list_get_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; + + case OP_LIST_GET_BY_VALUE_RANGE: { + success = as_operations_list_get_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, return_type); - } - else { - success = as_operations_list_remove_by_index_range_to_end( + } break; + + case OP_LIST_REMOVE_BY_INDEX: { + success = as_operations_list_remove_by_index( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + break; } - } break; - case OP_LIST_REMOVE_BY_RANK: { - success = as_operations_list_remove_by_rank( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - break; - } + case OP_LIST_REMOVE_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, + (uint64_t)count, return_type); + } + else { + success = as_operations_list_remove_by_index_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } + } break; - case OP_LIST_REMOVE_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_remove_by_rank_range_to_end( + case OP_LIST_REMOVE_BY_RANK: { + success = as_operations_list_remove_by_rank( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + break; } - } break; - case OP_LIST_REMOVE_BY_VALUE: { - success = as_operations_list_remove_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - break; - } + case OP_LIST_REMOVE_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_remove_by_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } + } break; - case OP_LIST_REMOVE_BY_VALUE_LIST: { - success = as_operations_list_remove_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; - - case OP_LIST_REMOVE_BY_VALUE_RANGE: { - success = as_operations_list_remove_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); - } break; - - case OP_LIST_SET_ORDER: { - success = - as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int); - break; - } + case OP_LIST_REMOVE_BY_VALUE: { + success = as_operations_list_remove_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + break; + } - case OP_LIST_SORT: { - int64_t sort_flags; + case OP_LIST_REMOVE_BY_VALUE_LIST: { + success = as_operations_list_remove_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; - if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != - AEROSPIKE_OK) { - return err->code; + case OP_LIST_REMOVE_BY_VALUE_RANGE: { + success = as_operations_list_remove_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); + } break; + + case OP_LIST_SET_ORDER: { + success = as_operations_list_set_order( + ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int); + break; } - success = as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_sort_flags)sort_flags); - break; - } - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { - success = as_operations_list_get_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, (uint64_t)count, - return_type); - break; - } + case OP_LIST_SORT: { + int64_t sort_flags; - case OP_LIST_CREATE: { - bool pad, persist_index; - if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != - AEROSPIKE_OK) { - return err->code; + if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != + AEROSPIKE_OK) { + return err->code; + } + success = + as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_sort_flags)sort_flags); + break; } - if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, - &persist_index) != AEROSPIKE_OK) { - return err->code; + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { + success = as_operations_list_get_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type); + break; } - success = as_operations_list_create_all( - ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, - pad, persist_index); - break; - } - case OP_LIST_APPEND: - success = as_operations_list_append( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), val); - break; - case OP_LIST_APPEND_ITEMS: - success = as_operations_list_append_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), value_list); - break; - case OP_LIST_INSERT: - success = as_operations_list_insert( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_INSERT_ITEMS: - success = as_operations_list_insert_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, value_list); - break; - case OP_LIST_INCREMENT: - success = as_operations_list_increment( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: - if (range_specified) { - if (!as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); + case OP_LIST_CREATE: { + bool pad, persist_index; + if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != + AEROSPIKE_OK) { + return err->code; } + + if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, + &persist_index) != AEROSPIKE_OK) { + return err->code; + } + + success = as_operations_list_create_all( + ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int, pad, persist_index); + break; } - else { - if (!as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); + case OP_LIST_APPEND: + success = as_operations_list_append( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), val); + break; + case OP_LIST_APPEND_ITEMS: + success = as_operations_list_append_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), value_list); + break; + case OP_LIST_INSERT: + success = as_operations_list_insert( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_INSERT_ITEMS: + success = as_operations_list_insert_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, value_list); + break; + case OP_LIST_INCREMENT: + success = as_operations_list_increment( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + if (range_specified) { + if (!as_operations_list_remove_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); + } + } + else { + if (!as_operations_list_remove_by_value_rel_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); + } } + break; + + default: + // This should never be possible since we only get here if we know that the operation is valid. + return as_error_update(err, AEROSPIKE_ERR_PARAM, + "Unknown operation"); } - break; - default: - // This should never be possible since we only get here if we know that the operation is valid. - return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); - } + if (!success) { + // TODO: regression in error message + as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add operation"); + } - if (!success) { - // TODO: regression in error message - as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); + return err->code; } - - return err->code; -} From 8b9fc85be2488794ea6df9bebb5f73c8bb9d453c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:32:21 -0800 Subject: [PATCH 10/41] fix --- src/main/client/cdt_list_operate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index aefa884e53..597ddb4586 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -443,3 +443,4 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, return err->code; } +} From fd97333d59052d9995872972580a4bb3b40ea378 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:35:37 -0800 Subject: [PATCH 11/41] Fix --- src/main/client/cdt_list_operate.c | 450 ++++++++++++++--------------- 1 file changed, 223 insertions(+), 227 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 597ddb4586..0b26d5b87e 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -185,262 +185,258 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, return err->code; } break; + } - int64_t order_type_int; - if (operation_code == OP_LIST_CREATE) { - if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != - AEROSPIKE_OK) { - return err->code; - } + int64_t order_type_int; + if (operation_code == OP_LIST_CREATE) { + if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != + AEROSPIKE_OK) { + return err->code; } + } - bool success = false; - switch (operation_code) { - case OP_LIST_SIZE: - success = - as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_POP: - success = as_operations_list_pop(ops, bin, - (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_POP_RANGE: - success = as_operations_list_pop_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_REMOVE: - success = as_operations_list_remove( - ops, bin, (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_REMOVE_RANGE: - success = as_operations_list_remove_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_CLEAR: - success = - as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_SET: - success = as_operations_list_set( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_GET: - success = as_operations_list_get(ops, bin, - (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_GET_RANGE: - success = as_operations_list_get_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_TRIM: - success = as_operations_list_trim( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_GET_BY_INDEX: { - success = as_operations_list_get_by_index( + bool success = false; + switch (operation_code) { + case OP_LIST_SIZE: + success = as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_POP: + success = + as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_POP_RANGE: + success = as_operations_list_pop_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_REMOVE: + success = as_operations_list_remove(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_REMOVE_RANGE: + success = as_operations_list_remove_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_CLEAR: + success = + as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_SET: + success = as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), + index, val); + break; + case OP_LIST_GET: + success = + as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_GET_RANGE: + success = as_operations_list_get_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_TRIM: + success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), + index, (uint64_t)count); + break; + case OP_LIST_GET_BY_INDEX: { + success = as_operations_list_get_by_index( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } break; + + case OP_LIST_GET_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } break; - - case OP_LIST_GET_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, - (uint64_t)count, return_type); - } - else { - success = as_operations_list_get_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - } break; - case OP_LIST_GET_BY_RANK: { - success = as_operations_list_get_by_rank( + } + } break; + case OP_LIST_GET_BY_RANK: { + success = as_operations_list_get_by_rank( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } break; + + case OP_LIST_GET_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_rank_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } break; + } + } break; + case OP_LIST_GET_BY_VALUE: { + success = as_operations_list_get_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + } break; + case OP_LIST_GET_BY_VALUE_LIST: { + success = as_operations_list_get_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; + + case OP_LIST_GET_BY_VALUE_RANGE: { + success = as_operations_list_get_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); + } break; + + case OP_LIST_REMOVE_BY_INDEX: { + success = as_operations_list_remove_by_index( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + break; + } - case OP_LIST_GET_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - } break; - case OP_LIST_GET_BY_VALUE: { - success = as_operations_list_get_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - } break; - case OP_LIST_GET_BY_VALUE_LIST: { - success = as_operations_list_get_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; - - case OP_LIST_GET_BY_VALUE_RANGE: { - success = as_operations_list_get_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + case OP_LIST_REMOVE_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, return_type); - } break; - - case OP_LIST_REMOVE_BY_INDEX: { - success = as_operations_list_remove_by_index( + } + else { + success = as_operations_list_remove_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - break; } + } break; - case OP_LIST_REMOVE_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, - (uint64_t)count, return_type); - } - else { - success = as_operations_list_remove_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - } break; + case OP_LIST_REMOVE_BY_RANK: { + success = as_operations_list_remove_by_rank( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + break; + } - case OP_LIST_REMOVE_BY_RANK: { - success = as_operations_list_remove_by_rank( + case OP_LIST_REMOVE_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_remove_by_rank_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - break; } + } break; - case OP_LIST_REMOVE_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_remove_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - } break; - - case OP_LIST_REMOVE_BY_VALUE: { - success = as_operations_list_remove_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - break; - } + case OP_LIST_REMOVE_BY_VALUE: { + success = as_operations_list_remove_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + break; + } - case OP_LIST_REMOVE_BY_VALUE_LIST: { - success = as_operations_list_remove_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; + case OP_LIST_REMOVE_BY_VALUE_LIST: { + success = as_operations_list_remove_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; + + case OP_LIST_REMOVE_BY_VALUE_RANGE: { + success = as_operations_list_remove_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); + } break; + + case OP_LIST_SET_ORDER: { + success = + as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int); + break; + } - case OP_LIST_REMOVE_BY_VALUE_RANGE: { - success = as_operations_list_remove_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); - } break; + case OP_LIST_SORT: { + int64_t sort_flags; - case OP_LIST_SET_ORDER: { - success = as_operations_list_set_order( - ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int); - break; + if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != + AEROSPIKE_OK) { + return err->code; } + success = as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_sort_flags)sort_flags); + break; + } - case OP_LIST_SORT: { - int64_t sort_flags; + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { + success = as_operations_list_get_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, (uint64_t)count, + return_type); + break; + } - if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != - AEROSPIKE_OK) { - return err->code; - } - success = - as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_sort_flags)sort_flags); - break; + case OP_LIST_CREATE: { + bool pad, persist_index; + if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != + AEROSPIKE_OK) { + return err->code; } - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { - success = as_operations_list_get_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type); - break; + if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, + &persist_index) != AEROSPIKE_OK) { + return err->code; } - case OP_LIST_CREATE: { - bool pad, persist_index; - if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, - &persist_index) != AEROSPIKE_OK) { - return err->code; + success = as_operations_list_create_all( + ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, + pad, persist_index); + break; + } + case OP_LIST_APPEND: + success = as_operations_list_append( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), val); + break; + case OP_LIST_APPEND_ITEMS: + success = as_operations_list_append_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), value_list); + break; + case OP_LIST_INSERT: + success = as_operations_list_insert( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_INSERT_ITEMS: + success = as_operations_list_insert_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, value_list); + break; + case OP_LIST_INCREMENT: + success = as_operations_list_increment( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + if (range_specified) { + if (!as_operations_list_remove_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); } - - success = as_operations_list_create_all( - ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int, pad, persist_index); - break; } - case OP_LIST_APPEND: - success = as_operations_list_append( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), val); - break; - case OP_LIST_APPEND_ITEMS: - success = as_operations_list_append_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), value_list); - break; - case OP_LIST_INSERT: - success = as_operations_list_insert( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_INSERT_ITEMS: - success = as_operations_list_insert_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, value_list); - break; - case OP_LIST_INCREMENT: - success = as_operations_list_increment( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: - if (range_specified) { - if (!as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); - } + else { + if (!as_operations_list_remove_by_value_rel_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); } - else { - if (!as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); - } - } - break; - - default: - // This should never be possible since we only get here if we know that the operation is valid. - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Unknown operation"); } + break; - if (!success) { - // TODO: regression in error message - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add operation"); - } + default: + // This should never be possible since we only get here if we know that the operation is valid. + return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); + } - return err->code; + if (!success) { + // TODO: regression in error message + as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); } + + return err->code; } From 21554934bdd733f2bb095dc2d5d91d497d452d41 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:43:35 -0800 Subject: [PATCH 12/41] Move switch cases in ascending order so there is a greater chance the compiler will optimize these switch statements --- src/main/client/cdt_list_operate.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 0b26d5b87e..7801cfe2c0 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -62,19 +62,19 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_val *val = NULL; switch (operation_code) { - case OP_LIST_GET_BY_VALUE: - case OP_LIST_GET_BY_VALUE_LIST: - case OP_LIST_GET_RANGE: - case OP_LIST_REMOVE_BY_VALUE: - case OP_LIST_TRIM: case OP_LIST_APPEND: case OP_LIST_APPEND_ITEMS: case OP_LIST_INSERT: case OP_LIST_INSERT_ITEMS: case OP_LIST_POP_RANGE: case OP_LIST_REMOVE_RANGE: - case OP_LIST_INCREMENT: case OP_LIST_SET: + case OP_LIST_INCREMENT: + case OP_LIST_GET_BY_VALUE: + case OP_LIST_GET_BY_VALUE_LIST: + case OP_LIST_GET_RANGE: + case OP_LIST_TRIM: + case OP_LIST_REMOVE_BY_VALUE: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, @@ -93,11 +93,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } break; case OP_LIST_GET_BY_INDEX_RANGE: - case OP_LIST_REMOVE_BY_INDEX_RANGE: case OP_LIST_GET_BY_RANK_RANGE: + case OP_LIST_REMOVE_BY_INDEX_RANGE: case OP_LIST_REMOVE_BY_RANK_RANGE: - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, &range_specified) != AEROSPIKE_OK) { return err->code; @@ -117,6 +117,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, int64_t index; switch (operation_code) { + case OP_LIST_INSERT: + case OP_LIST_INSERT_ITEMS: case OP_LIST_POP: case OP_LIST_POP_RANGE: case OP_LIST_REMOVE: @@ -125,13 +127,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET: case OP_LIST_GET_RANGE: case OP_LIST_TRIM: + case OP_LIST_INCREMENT: case OP_LIST_GET_BY_INDEX: case OP_LIST_GET_BY_INDEX_RANGE: case OP_LIST_REMOVE_BY_INDEX: case OP_LIST_REMOVE_BY_INDEX_RANGE: - case OP_LIST_INSERT: - case OP_LIST_INSERT_ITEMS: - case OP_LIST_INCREMENT: if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { return err->code; From 3e6ebb1c020c9def6fb7d5f4b1d6534bc897e156 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 08:53:21 -0800 Subject: [PATCH 13/41] fix... --- src/main/client/cdt_list_operate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 7801cfe2c0..d3c3390e0c 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -173,8 +173,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_val *val_begin = NULL; as_val *val_end = NULL; switch (operation_code) { - case OP_LIST_GET_BY_VALUE_LIST: - case OP_LIST_REMOVE_BY_VALUE_LIST: + case OP_LIST_GET_BY_VALUE_RANGE: + case OP_LIST_REMOVE_BY_VALUE_RANGE: if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, static_pool, serializer_type, false) != AEROSPIKE_OK) { return err->code; From 43e959fb3e4b867ac8cf94315c055926b0b6be9f Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:42:25 -0800 Subject: [PATCH 14/41] fix --- src/main/client/cdt_list_operate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index d3c3390e0c..f64a675efe 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -71,7 +71,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_SET: case OP_LIST_INCREMENT: case OP_LIST_GET_BY_VALUE: - case OP_LIST_GET_BY_VALUE_LIST: case OP_LIST_GET_RANGE: case OP_LIST_TRIM: case OP_LIST_REMOVE_BY_VALUE: From 80797cb630523d10243cae82b97766aa9b45bbd4 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:56:43 -0800 Subject: [PATCH 15/41] fix --- src/main/client/cdt_list_operate.c | 442 +++++++++++++++-------------- 1 file changed, 224 insertions(+), 218 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index f64a675efe..23954d31ff 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -187,255 +187,261 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int64_t order_type_int; - if (operation_code == OP_LIST_CREATE) { + switch (operation_code) { + case OP_LIST_SET_ORDER: + case OP_LIST_CREATE: { if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != AEROSPIKE_OK) { return err->code; } } - bool success = false; - switch (operation_code) { - case OP_LIST_SIZE: - success = as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_POP: - success = - as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_POP_RANGE: - success = as_operations_list_pop_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_REMOVE: - success = as_operations_list_remove(ops, bin, - (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_REMOVE_RANGE: - success = as_operations_list_remove_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_CLEAR: - success = - as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_SET: - success = as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), - index, val); - break; - case OP_LIST_GET: - success = - as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_GET_RANGE: - success = as_operations_list_get_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_TRIM: - success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), - index, (uint64_t)count); - break; - case OP_LIST_GET_BY_INDEX: { - success = as_operations_list_get_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } break; - - case OP_LIST_GET_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_index_range_to_end( + bool success = false; + switch (operation_code) { + case OP_LIST_SIZE: + success = + as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_POP: + success = as_operations_list_pop(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_POP_RANGE: + success = as_operations_list_pop_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_REMOVE: + success = as_operations_list_remove( + ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_REMOVE_RANGE: + success = as_operations_list_remove_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_CLEAR: + success = + as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_SET: + success = as_operations_list_set( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_GET: + success = as_operations_list_get(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_GET_RANGE: + success = as_operations_list_get_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_TRIM: + success = as_operations_list_trim( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_GET_BY_INDEX: { + success = as_operations_list_get_by_index( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - } break; - case OP_LIST_GET_BY_RANK: { - success = as_operations_list_get_by_rank( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } break; - - case OP_LIST_GET_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_rank_range_to_end( + } break; + + case OP_LIST_GET_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, + (uint64_t)count, return_type); + } + else { + success = as_operations_list_get_by_index_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } + } break; + case OP_LIST_GET_BY_RANK: { + success = as_operations_list_get_by_rank( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - } break; - case OP_LIST_GET_BY_VALUE: { - success = as_operations_list_get_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - } break; - case OP_LIST_GET_BY_VALUE_LIST: { - success = as_operations_list_get_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; - - case OP_LIST_GET_BY_VALUE_RANGE: { - success = as_operations_list_get_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); - } break; - - case OP_LIST_REMOVE_BY_INDEX: { - success = as_operations_list_remove_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - break; - } + } break; - case OP_LIST_REMOVE_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, + case OP_LIST_GET_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } + } break; + case OP_LIST_GET_BY_VALUE: { + success = as_operations_list_get_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + } break; + case OP_LIST_GET_BY_VALUE_LIST: { + success = as_operations_list_get_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; + + case OP_LIST_GET_BY_VALUE_RANGE: { + success = as_operations_list_get_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, return_type); - } - else { - success = as_operations_list_remove_by_index_range_to_end( + } break; + + case OP_LIST_REMOVE_BY_INDEX: { + success = as_operations_list_remove_by_index( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + break; } - } break; - case OP_LIST_REMOVE_BY_RANK: { - success = as_operations_list_remove_by_rank( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - break; - } + case OP_LIST_REMOVE_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, + (uint64_t)count, return_type); + } + else { + success = as_operations_list_remove_by_index_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } + } break; - case OP_LIST_REMOVE_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_remove_by_rank_range_to_end( + case OP_LIST_REMOVE_BY_RANK: { + success = as_operations_list_remove_by_rank( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + break; } - } break; - case OP_LIST_REMOVE_BY_VALUE: { - success = as_operations_list_remove_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - break; - } + case OP_LIST_REMOVE_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_remove_by_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } + } break; - case OP_LIST_REMOVE_BY_VALUE_LIST: { - success = as_operations_list_remove_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; - - case OP_LIST_REMOVE_BY_VALUE_RANGE: { - success = as_operations_list_remove_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); - } break; - - case OP_LIST_SET_ORDER: { - success = - as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int); - break; - } + case OP_LIST_REMOVE_BY_VALUE: { + success = as_operations_list_remove_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + break; + } - case OP_LIST_SORT: { - int64_t sort_flags; + case OP_LIST_REMOVE_BY_VALUE_LIST: { + success = as_operations_list_remove_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; - if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != - AEROSPIKE_OK) { - return err->code; + case OP_LIST_REMOVE_BY_VALUE_RANGE: { + success = as_operations_list_remove_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); + } break; + + case OP_LIST_SET_ORDER: { + success = as_operations_list_set_order( + ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int); + break; } - success = as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_sort_flags)sort_flags); - break; - } - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { - success = as_operations_list_get_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, (uint64_t)count, - return_type); - break; - } + case OP_LIST_SORT: { + int64_t sort_flags; - case OP_LIST_CREATE: { - bool pad, persist_index; - if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != - AEROSPIKE_OK) { - return err->code; + if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != + AEROSPIKE_OK) { + return err->code; + } + success = + as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_sort_flags)sort_flags); + break; } - if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, - &persist_index) != AEROSPIKE_OK) { - return err->code; + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { + success = as_operations_list_get_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type); + break; } - success = as_operations_list_create_all( - ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, - pad, persist_index); - break; - } - case OP_LIST_APPEND: - success = as_operations_list_append( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), val); - break; - case OP_LIST_APPEND_ITEMS: - success = as_operations_list_append_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), value_list); - break; - case OP_LIST_INSERT: - success = as_operations_list_insert( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_INSERT_ITEMS: - success = as_operations_list_insert_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, value_list); - break; - case OP_LIST_INCREMENT: - success = as_operations_list_increment( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: - if (range_specified) { - if (!as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); + case OP_LIST_CREATE: { + bool pad, persist_index; + if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != + AEROSPIKE_OK) { + return err->code; } + + if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, + &persist_index) != AEROSPIKE_OK) { + return err->code; + } + + success = as_operations_list_create_all( + ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int, pad, persist_index); + break; } - else { - if (!as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); + case OP_LIST_APPEND: + success = as_operations_list_append( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), val); + break; + case OP_LIST_APPEND_ITEMS: + success = as_operations_list_append_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), value_list); + break; + case OP_LIST_INSERT: + success = as_operations_list_insert( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_INSERT_ITEMS: + success = as_operations_list_insert_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, value_list); + break; + case OP_LIST_INCREMENT: + success = as_operations_list_increment( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + if (range_specified) { + if (!as_operations_list_remove_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); + } } + else { + if (!as_operations_list_remove_by_value_rel_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); + } + } + break; + + default: + // This should never be possible since we only get here if we know that the operation is valid. + return as_error_update(err, AEROSPIKE_ERR_PARAM, + "Unknown operation"); } - break; - default: - // This should never be possible since we only get here if we know that the operation is valid. - return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); - } + if (!success) { + // TODO: regression in error message + as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add operation"); + } - if (!success) { - // TODO: regression in error message - as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); + return err->code; } - - return err->code; -} From d0758961a8b3cb79cbde460d44a7bf55f1f894f7 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:56:57 -0800 Subject: [PATCH 16/41] Revert "fix" This reverts commit 80797cb630523d10243cae82b97766aa9b45bbd4. --- src/main/client/cdt_list_operate.c | 442 ++++++++++++++--------------- 1 file changed, 218 insertions(+), 224 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 23954d31ff..f64a675efe 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -187,261 +187,255 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int64_t order_type_int; - switch (operation_code) { - case OP_LIST_SET_ORDER: - case OP_LIST_CREATE: { + if (operation_code == OP_LIST_CREATE) { if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != AEROSPIKE_OK) { return err->code; } } - bool success = false; - switch (operation_code) { - case OP_LIST_SIZE: - success = - as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_POP: - success = as_operations_list_pop(ops, bin, - (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_POP_RANGE: - success = as_operations_list_pop_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_REMOVE: - success = as_operations_list_remove( - ops, bin, (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_REMOVE_RANGE: - success = as_operations_list_remove_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_CLEAR: - success = - as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); - break; - case OP_LIST_SET: - success = as_operations_list_set( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_GET: - success = as_operations_list_get(ops, bin, - (ctx_in_use ? &ctx : NULL), index); - break; - case OP_LIST_GET_RANGE: - success = as_operations_list_get_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_TRIM: - success = as_operations_list_trim( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); - break; - case OP_LIST_GET_BY_INDEX: { - success = as_operations_list_get_by_index( + bool success = false; + switch (operation_code) { + case OP_LIST_SIZE: + success = as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_POP: + success = + as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_POP_RANGE: + success = as_operations_list_pop_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_REMOVE: + success = as_operations_list_remove(ops, bin, + (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_REMOVE_RANGE: + success = as_operations_list_remove_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_CLEAR: + success = + as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); + break; + case OP_LIST_SET: + success = as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), + index, val); + break; + case OP_LIST_GET: + success = + as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index); + break; + case OP_LIST_GET_RANGE: + success = as_operations_list_get_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + break; + case OP_LIST_TRIM: + success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), + index, (uint64_t)count); + break; + case OP_LIST_GET_BY_INDEX: { + success = as_operations_list_get_by_index( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + } break; + + case OP_LIST_GET_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } break; - - case OP_LIST_GET_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, - (uint64_t)count, return_type); - } - else { - success = as_operations_list_get_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - } break; - case OP_LIST_GET_BY_RANK: { - success = as_operations_list_get_by_rank( + } + } break; + case OP_LIST_GET_BY_RANK: { + success = as_operations_list_get_by_rank( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + } break; + + case OP_LIST_GET_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_get_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_get_by_rank_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } break; + } + } break; + case OP_LIST_GET_BY_VALUE: { + success = as_operations_list_get_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + } break; + case OP_LIST_GET_BY_VALUE_LIST: { + success = as_operations_list_get_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; + + case OP_LIST_GET_BY_VALUE_RANGE: { + success = as_operations_list_get_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); + } break; + + case OP_LIST_REMOVE_BY_INDEX: { + success = as_operations_list_remove_by_index( + ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + break; + } - case OP_LIST_GET_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_get_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_get_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - } break; - case OP_LIST_GET_BY_VALUE: { - success = as_operations_list_get_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - } break; - case OP_LIST_GET_BY_VALUE_LIST: { - success = as_operations_list_get_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; - - case OP_LIST_GET_BY_VALUE_RANGE: { - success = as_operations_list_get_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + case OP_LIST_REMOVE_BY_INDEX_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_index_range( + ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, return_type); - } break; - - case OP_LIST_REMOVE_BY_INDEX: { - success = as_operations_list_remove_by_index( + } + else { + success = as_operations_list_remove_by_index_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - break; } + } break; - case OP_LIST_REMOVE_BY_INDEX_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, - (uint64_t)count, return_type); - } - else { - success = as_operations_list_remove_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); - } - } break; + case OP_LIST_REMOVE_BY_RANK: { + success = as_operations_list_remove_by_rank( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + break; + } - case OP_LIST_REMOVE_BY_RANK: { - success = as_operations_list_remove_by_rank( + case OP_LIST_REMOVE_BY_RANK_RANGE: { + if (range_specified) { + success = as_operations_list_remove_by_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, + return_type); + } + else { + success = as_operations_list_remove_by_rank_range_to_end( ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - break; } + } break; - case OP_LIST_REMOVE_BY_RANK_RANGE: { - if (range_specified) { - success = as_operations_list_remove_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); - } - else { - success = as_operations_list_remove_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); - } - } break; - - case OP_LIST_REMOVE_BY_VALUE: { - success = as_operations_list_remove_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); - break; - } + case OP_LIST_REMOVE_BY_VALUE: { + success = as_operations_list_remove_by_value( + ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + break; + } - case OP_LIST_REMOVE_BY_VALUE_LIST: { - success = as_operations_list_remove_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); - } break; + case OP_LIST_REMOVE_BY_VALUE_LIST: { + success = as_operations_list_remove_by_value_list( + ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + } break; + + case OP_LIST_REMOVE_BY_VALUE_RANGE: { + success = as_operations_list_remove_by_value_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, + return_type); + } break; + + case OP_LIST_SET_ORDER: { + success = + as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_order)order_type_int); + break; + } - case OP_LIST_REMOVE_BY_VALUE_RANGE: { - success = as_operations_list_remove_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); - } break; + case OP_LIST_SORT: { + int64_t sort_flags; - case OP_LIST_SET_ORDER: { - success = as_operations_list_set_order( - ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int); - break; + if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != + AEROSPIKE_OK) { + return err->code; } + success = as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), + (as_list_sort_flags)sort_flags); + break; + } - case OP_LIST_SORT: { - int64_t sort_flags; + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { + success = as_operations_list_get_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, (uint64_t)count, + return_type); + break; + } - if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != - AEROSPIKE_OK) { - return err->code; - } - success = - as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_sort_flags)sort_flags); - break; + case OP_LIST_CREATE: { + bool pad, persist_index; + if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != + AEROSPIKE_OK) { + return err->code; } - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { - success = as_operations_list_get_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type); - break; + if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, + &persist_index) != AEROSPIKE_OK) { + return err->code; } - case OP_LIST_CREATE: { - bool pad, persist_index; - if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, - &persist_index) != AEROSPIKE_OK) { - return err->code; + success = as_operations_list_create_all( + ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, + pad, persist_index); + break; + } + case OP_LIST_APPEND: + success = as_operations_list_append( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), val); + break; + case OP_LIST_APPEND_ITEMS: + success = as_operations_list_append_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), value_list); + break; + case OP_LIST_INSERT: + success = as_operations_list_insert( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_INSERT_ITEMS: + success = as_operations_list_insert_items( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, value_list); + break; + case OP_LIST_INCREMENT: + success = as_operations_list_increment( + ops, bin, (ctx_in_use ? &ctx : NULL), + (policy_in_use ? &list_policy : NULL), index, val); + break; + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + if (range_specified) { + if (!as_operations_list_remove_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); } - - success = as_operations_list_create_all( - ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int, pad, persist_index); - break; } - case OP_LIST_APPEND: - success = as_operations_list_append( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), val); - break; - case OP_LIST_APPEND_ITEMS: - success = as_operations_list_append_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), value_list); - break; - case OP_LIST_INSERT: - success = as_operations_list_insert( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_INSERT_ITEMS: - success = as_operations_list_insert_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, value_list); - break; - case OP_LIST_INCREMENT: - success = as_operations_list_increment( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); - break; - case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: - if (range_specified) { - if (!as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); - } + else { + if (!as_operations_list_remove_by_value_rel_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + return_type)) { + as_cdt_ctx_destroy(&ctx); + return as_error_update(err, AEROSPIKE_ERR_CLIENT, + "Failed to add list remove by value " + "rank relative operation"); } - else { - if (!as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); - } - } - break; - - default: - // This should never be possible since we only get here if we know that the operation is valid. - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Unknown operation"); } + break; - if (!success) { - // TODO: regression in error message - as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add operation"); - } + default: + // This should never be possible since we only get here if we know that the operation is valid. + return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); + } - return err->code; + if (!success) { + // TODO: regression in error message + as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); } + + return err->code; +} From ca3a4332caf9d427ccd55c164d56e61bb638d333 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 09:57:50 -0800 Subject: [PATCH 17/41] fix --- src/main/client/cdt_list_operate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index f64a675efe..9e75cdd627 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -187,7 +187,9 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } int64_t order_type_int; - if (operation_code == OP_LIST_CREATE) { + switch (operation_code) { + case OP_LIST_SET_ORDER: + case OP_LIST_CREATE: if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != AEROSPIKE_OK) { return err->code; From 935373b16a10a0bf1bf37d16819588c34869624c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:23:56 -0800 Subject: [PATCH 18/41] Fix --- src/main/client/cdt_list_operate.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 9e75cdd627..e68ccdd122 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -408,27 +408,15 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (range_specified) { - if (!as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); - } + success = as_operations_list_remove_by_value_rel_rank_range( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, + (uint64_t)count, return_type); } else { - if (!as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - return_type)) { - as_cdt_ctx_destroy(&ctx); - return as_error_update(err, AEROSPIKE_ERR_CLIENT, - "Failed to add list remove by value " - "rank relative operation"); - } + success = as_operations_list_remove_by_value_rel_rank_range_to_end( + ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, return_type); } break; - default: // This should never be possible since we only get here if we know that the operation is valid. return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); From 799f8eb8820d39ff4022e30b4c502d1619994e9f Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:39:43 -0800 Subject: [PATCH 19/41] fix --- src/main/client/cdt_list_operate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index e68ccdd122..3538f0a518 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -67,12 +67,9 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_INSERT: case OP_LIST_INSERT_ITEMS: case OP_LIST_POP_RANGE: - case OP_LIST_REMOVE_RANGE: case OP_LIST_SET: case OP_LIST_INCREMENT: case OP_LIST_GET_BY_VALUE: - case OP_LIST_GET_RANGE: - case OP_LIST_TRIM: case OP_LIST_REMOVE_BY_VALUE: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: @@ -87,6 +84,9 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, bool range_specified = false; switch (operation_code) { case OP_LIST_POP_RANGE: + case OP_LIST_REMOVE_RANGE: + case OP_LIST_GET_RANGE: + case OP_LIST_TRIM: if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { return err->code; } @@ -389,7 +389,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_APPEND_ITEMS: success = as_operations_list_append_items( ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), value_list); + (policy_in_use ? &list_policy : NULL), val); break; case OP_LIST_INSERT: success = as_operations_list_insert( From efe8f4abc8b4c0ca0295fe1738aa4b815c165914 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:44:34 -0800 Subject: [PATCH 20/41] fix --- src/main/client/cdt_list_operate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 3538f0a518..f1ce8d5990 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -63,7 +63,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_val *val = NULL; switch (operation_code) { case OP_LIST_APPEND: - case OP_LIST_APPEND_ITEMS: case OP_LIST_INSERT: case OP_LIST_INSERT_ITEMS: case OP_LIST_POP_RANGE: @@ -160,6 +159,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_list *value_list = NULL; switch (operation_code) { + case OP_LIST_APPEND_ITEMS: case OP_LIST_GET_BY_VALUE_LIST: case OP_LIST_REMOVE_BY_VALUE_LIST: if (get_val_list(self, err, AS_PY_VALUES_KEY, op_dict, &value_list, @@ -389,7 +389,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_APPEND_ITEMS: success = as_operations_list_append_items( ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), val); + (policy_in_use ? &list_policy : NULL), value_list); break; case OP_LIST_INSERT: success = as_operations_list_insert( From c61d4a46837b233a07f28507af7110af3bfaae5c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 10:47:16 -0800 Subject: [PATCH 21/41] Create a variable to get the results of the ternary operation. This makes it easier to refactor in the future --- src/main/client/cdt_list_operate.c | 129 +++++++++++++---------------- 1 file changed, 58 insertions(+), 71 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index f1ce8d5990..7e499051d1 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -142,6 +142,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, serializer_type) != AEROSPIKE_OK) { return err->code; } + as_cdt_ctx *ctx_ref = (ctx_in_use ? &ctx : NULL); int64_t rank; switch (operation_code) { @@ -199,149 +200,138 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, bool success = false; switch (operation_code) { case OP_LIST_SIZE: - success = as_operations_list_size(ops, bin, (ctx_in_use ? &ctx : NULL)); + success = as_operations_list_size(ops, bin, ctx_ref); break; case OP_LIST_POP: - success = - as_operations_list_pop(ops, bin, (ctx_in_use ? &ctx : NULL), index); + success = as_operations_list_pop(ops, bin, ctx_ref, index); break; case OP_LIST_POP_RANGE: - success = as_operations_list_pop_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + success = as_operations_list_pop_range(ops, bin, ctx_ref, index, + (uint64_t)count); break; case OP_LIST_REMOVE: - success = as_operations_list_remove(ops, bin, - (ctx_in_use ? &ctx : NULL), index); + success = as_operations_list_remove(ops, bin, ctx_ref, index); break; case OP_LIST_REMOVE_RANGE: - success = as_operations_list_remove_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + success = as_operations_list_remove_range(ops, bin, ctx_ref, index, + (uint64_t)count); break; case OP_LIST_CLEAR: - success = - as_operations_list_clear(ops, bin, (ctx_in_use ? &ctx : NULL)); + success = as_operations_list_clear(ops, bin, ctx_ref); break; case OP_LIST_SET: - success = as_operations_list_set(ops, bin, (ctx_in_use ? &ctx : NULL), + success = as_operations_list_set(ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, val); break; case OP_LIST_GET: - success = - as_operations_list_get(ops, bin, (ctx_in_use ? &ctx : NULL), index); + success = as_operations_list_get(ops, bin, ctx_ref, index); break; case OP_LIST_GET_RANGE: - success = as_operations_list_get_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count); + success = as_operations_list_get_range(ops, bin, ctx_ref, index, + (uint64_t)count); break; case OP_LIST_TRIM: - success = as_operations_list_trim(ops, bin, (ctx_in_use ? &ctx : NULL), - index, (uint64_t)count); + success = + as_operations_list_trim(ops, bin, ctx_ref, index, (uint64_t)count); break; case OP_LIST_GET_BY_INDEX: { - success = as_operations_list_get_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + success = as_operations_list_get_by_index(ops, bin, ctx_ref, index, + return_type); } break; case OP_LIST_GET_BY_INDEX_RANGE: { if (range_specified) { success = as_operations_list_get_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, - return_type); + ops, bin, ctx_ref, index, (uint64_t)count, return_type); } else { success = as_operations_list_get_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + ops, bin, ctx_ref, index, return_type); } } break; case OP_LIST_GET_BY_RANK: { - success = as_operations_list_get_by_rank( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + success = as_operations_list_get_by_rank(ops, bin, ctx_ref, rank, + return_type); } break; case OP_LIST_GET_BY_RANK_RANGE: { if (range_specified) { success = as_operations_list_get_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); + ops, bin, ctx_ref, rank, (uint64_t)count, return_type); } else { success = as_operations_list_get_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + ops, bin, ctx_ref, rank, return_type); } } break; case OP_LIST_GET_BY_VALUE: { - success = as_operations_list_get_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + success = as_operations_list_get_by_value(ops, bin, ctx_ref, val, + return_type); } break; case OP_LIST_GET_BY_VALUE_LIST: { - success = as_operations_list_get_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + success = as_operations_list_get_by_value_list(ops, bin, ctx_ref, + value_list, return_type); } break; case OP_LIST_GET_BY_VALUE_RANGE: { success = as_operations_list_get_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); + ops, bin, ctx_ref, val_begin, val_end, return_type); } break; case OP_LIST_REMOVE_BY_INDEX: { - success = as_operations_list_remove_by_index( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + success = as_operations_list_remove_by_index(ops, bin, ctx_ref, index, + return_type); break; } case OP_LIST_REMOVE_BY_INDEX_RANGE: { if (range_specified) { success = as_operations_list_remove_by_index_range( - ops, bin, (ctx_in_use ? &ctx : NULL), index, (uint64_t)count, - return_type); + ops, bin, ctx_ref, index, (uint64_t)count, return_type); } else { success = as_operations_list_remove_by_index_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), index, return_type); + ops, bin, ctx_ref, index, return_type); } } break; case OP_LIST_REMOVE_BY_RANK: { - success = as_operations_list_remove_by_rank( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + success = as_operations_list_remove_by_rank(ops, bin, ctx_ref, rank, + return_type); break; } case OP_LIST_REMOVE_BY_RANK_RANGE: { if (range_specified) { success = as_operations_list_remove_by_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, (uint64_t)count, - return_type); + ops, bin, ctx_ref, rank, (uint64_t)count, return_type); } else { success = as_operations_list_remove_by_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), rank, return_type); + ops, bin, ctx_ref, rank, return_type); } } break; case OP_LIST_REMOVE_BY_VALUE: { - success = as_operations_list_remove_by_value( - ops, bin, (ctx_in_use ? &ctx : NULL), val, return_type); + success = as_operations_list_remove_by_value(ops, bin, ctx_ref, val, + return_type); break; } case OP_LIST_REMOVE_BY_VALUE_LIST: { success = as_operations_list_remove_by_value_list( - ops, bin, (ctx_in_use ? &ctx : NULL), value_list, return_type); + ops, bin, ctx_ref, value_list, return_type); } break; case OP_LIST_REMOVE_BY_VALUE_RANGE: { success = as_operations_list_remove_by_value_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val_begin, val_end, - return_type); + ops, bin, ctx_ref, val_begin, val_end, return_type); } break; case OP_LIST_SET_ORDER: { - success = - as_operations_list_set_order(ops, bin, (ctx_in_use ? &ctx : NULL), - (as_list_order)order_type_int); + success = as_operations_list_set_order(ops, bin, ctx_ref, + (as_list_order)order_type_int); break; } @@ -352,15 +342,14 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, AEROSPIKE_OK) { return err->code; } - success = as_operations_list_sort(ops, bin, (ctx_in_use ? &ctx : NULL), + success = as_operations_list_sort(ops, bin, ctx_ref, (as_list_sort_flags)sort_flags); break; } case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { success = as_operations_list_get_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, (uint64_t)count, - return_type); + ops, bin, ctx_ref, val, rank, (uint64_t)count, return_type); break; } @@ -376,45 +365,43 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, return err->code; } - success = as_operations_list_create_all( - ops, bin, (ctx_in_use ? &ctx : NULL), (as_list_order)order_type_int, - pad, persist_index); + success = as_operations_list_create_all(ops, bin, ctx_ref, + (as_list_order)order_type_int, + pad, persist_index); break; } case OP_LIST_APPEND: success = as_operations_list_append( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), val); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), val); break; case OP_LIST_APPEND_ITEMS: success = as_operations_list_append_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), value_list); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), + value_list); break; case OP_LIST_INSERT: success = as_operations_list_insert( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, + val); break; case OP_LIST_INSERT_ITEMS: success = as_operations_list_insert_items( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, value_list); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, + value_list); break; case OP_LIST_INCREMENT: success = as_operations_list_increment( - ops, bin, (ctx_in_use ? &ctx : NULL), - (policy_in_use ? &list_policy : NULL), index, val); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, + val); break; case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (range_specified) { success = as_operations_list_remove_by_value_rel_rank_range( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, - (uint64_t)count, return_type); + ops, bin, ctx_ref, val, rank, (uint64_t)count, return_type); } else { success = as_operations_list_remove_by_value_rel_rank_range_to_end( - ops, bin, (ctx_in_use ? &ctx : NULL), val, rank, return_type); + ops, bin, ctx_ref, val, rank, return_type); } break; default: From 114c568abddc1580511684495b83ac7a71c84271 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:00:53 -0800 Subject: [PATCH 22/41] list_append and list_insert take in a different key for the list of values --- src/main/client/cdt_list_operate.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 7e499051d1..161cc89306 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -72,6 +72,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE_BY_VALUE: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_APPEND_ITEMS: if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, serializer_type, true) != AEROSPIKE_OK) { return err->code; @@ -159,11 +160,22 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } as_list *value_list = NULL; + const char *list_values_key = NULL; switch (operation_code) { + case OP_LIST_GET_BY_VALUE_LIST: + case OP_LIST_REMOVE_BY_VALUE_LIST: + list_values_key = AS_PY_VALUES_KEY; + break; case OP_LIST_APPEND_ITEMS: + list_values_key = AS_PY_VAL_KEY; + break; + } + + switch (operation_code) { case OP_LIST_GET_BY_VALUE_LIST: case OP_LIST_REMOVE_BY_VALUE_LIST: - if (get_val_list(self, err, AS_PY_VALUES_KEY, op_dict, &value_list, + case OP_LIST_APPEND_ITEMS: + if (get_val_list(self, err, list_values_key, op_dict, &value_list, static_pool, serializer_type) != AEROSPIKE_OK) { return err->code; } @@ -376,8 +388,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; case OP_LIST_APPEND_ITEMS: success = as_operations_list_append_items( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), - value_list); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), val); break; case OP_LIST_INSERT: success = as_operations_list_insert( From 77531b5ce16590b51c37a4c565b918d86f5a54fd Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:04:54 -0800 Subject: [PATCH 23/41] fix --- src/main/client/cdt_list_operate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 161cc89306..c097af27f7 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -64,7 +64,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, switch (operation_code) { case OP_LIST_APPEND: case OP_LIST_INSERT: - case OP_LIST_INSERT_ITEMS: case OP_LIST_POP_RANGE: case OP_LIST_SET: case OP_LIST_INCREMENT: @@ -167,6 +166,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, list_values_key = AS_PY_VALUES_KEY; break; case OP_LIST_APPEND_ITEMS: + case OP_LIST_INSERT_ITEMS: list_values_key = AS_PY_VAL_KEY; break; } @@ -388,7 +388,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; case OP_LIST_APPEND_ITEMS: success = as_operations_list_append_items( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), val); + ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), + value_list); break; case OP_LIST_INSERT: success = as_operations_list_insert( From 713561175603850ed51eb949f058717b7d5785ec Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:06:46 -0800 Subject: [PATCH 24/41] Also refactor list_policy code to reduce number of times ternary operator is called --- src/main/client/cdt_list_operate.c | 31 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index c097af27f7..bf0c453618 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -44,6 +44,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } as_list_policy list_policy; + as_list_policy *list_policy_ref = NULL; bool policy_in_use = false; switch (operation_code) { @@ -57,6 +58,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, self->validate_keys) != AEROSPIKE_OK) { return err->code; } + list_policy_ref = policy_in_use ? &list_policy : NULL; break; } @@ -232,9 +234,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_clear(ops, bin, ctx_ref); break; case OP_LIST_SET: - success = as_operations_list_set(ops, bin, ctx_ref, - (policy_in_use ? &list_policy : NULL), - index, val); + success = + as_operations_list_set(ops, bin, ctx_ref, policy_ref, index, val); break; case OP_LIST_GET: success = as_operations_list_get(ops, bin, ctx_ref, index); @@ -383,28 +384,24 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; } case OP_LIST_APPEND: - success = as_operations_list_append( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), val); + success = + as_operations_list_append(ops, bin, ctx_ref, list_policy_ref, val); break; case OP_LIST_APPEND_ITEMS: - success = as_operations_list_append_items( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), - value_list); + success = as_operations_list_append_items(ops, bin, ctx_ref, policy_ref, + value_list); break; case OP_LIST_INSERT: - success = as_operations_list_insert( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, - val); + success = as_operations_list_insert(ops, bin, ctx_ref, policy_ref, + index, val); break; case OP_LIST_INSERT_ITEMS: - success = as_operations_list_insert_items( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, - value_list); + success = as_operations_list_insert_items(ops, bin, ctx_ref, policy_ref, + index, value_list); break; case OP_LIST_INCREMENT: - success = as_operations_list_increment( - ops, bin, ctx_ref, (policy_in_use ? &list_policy : NULL), index, - val); + success = as_operations_list_increment(ops, bin, ctx_ref, policy_ref, + index, val); break; case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (range_specified) { From 23b48214652f4ff260672bacec08910393563398 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:08:53 -0800 Subject: [PATCH 25/41] fix... --- src/main/client/cdt_list_operate.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index bf0c453618..c2870ef4ce 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -234,8 +234,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_clear(ops, bin, ctx_ref); break; case OP_LIST_SET: - success = - as_operations_list_set(ops, bin, ctx_ref, policy_ref, index, val); + success = as_operations_list_set(ops, bin, ctx_ref, list_policy_ref, + index, val); break; case OP_LIST_GET: success = as_operations_list_get(ops, bin, ctx_ref, index); @@ -388,20 +388,20 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_operations_list_append(ops, bin, ctx_ref, list_policy_ref, val); break; case OP_LIST_APPEND_ITEMS: - success = as_operations_list_append_items(ops, bin, ctx_ref, policy_ref, - value_list); + success = as_operations_list_append_items(ops, bin, ctx_ref, + list_policy_ref, value_list); break; case OP_LIST_INSERT: - success = as_operations_list_insert(ops, bin, ctx_ref, policy_ref, + success = as_operations_list_insert(ops, bin, ctx_ref, list_policy_ref, index, val); break; case OP_LIST_INSERT_ITEMS: - success = as_operations_list_insert_items(ops, bin, ctx_ref, policy_ref, - index, value_list); + success = as_operations_list_insert_items( + ops, bin, ctx_ref, list_policy_ref, index, value_list); break; case OP_LIST_INCREMENT: - success = as_operations_list_increment(ops, bin, ctx_ref, policy_ref, - index, val); + success = as_operations_list_increment(ops, bin, ctx_ref, + list_policy_ref, index, val); break; case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (range_specified) { From 0cf272f5f49ae11f7886433347df0b873943c223 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:26:41 -0800 Subject: [PATCH 26/41] fix --- src/main/client/cdt_list_operate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index c2870ef4ce..26efb52937 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -177,6 +177,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_BY_VALUE_LIST: case OP_LIST_REMOVE_BY_VALUE_LIST: case OP_LIST_APPEND_ITEMS: + case OP_LIST_INSERT_ITEMS: if (get_val_list(self, err, list_values_key, op_dict, &value_list, static_pool, serializer_type) != AEROSPIKE_OK) { return err->code; From 86a21f586d2ac7d85f15d56cbafdfa5e0856d87b Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:35:52 -0800 Subject: [PATCH 27/41] Fix mem leaks --- src/main/client/cdt_list_operate.c | 58 ++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 26efb52937..fda59c3c4e 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -40,7 +40,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, char *bin = NULL; if (get_bin(err, op_dict, unicodeStrVector, &bin) != AEROSPIKE_OK) { - return err->code; + goto exit; } as_list_policy list_policy; @@ -56,7 +56,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_SET: if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, self->validate_keys) != AEROSPIKE_OK) { - return err->code; + goto exit; } list_policy_ref = policy_in_use ? &list_policy : NULL; break; @@ -76,7 +76,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_APPEND_ITEMS: if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, serializer_type, true) != AEROSPIKE_OK) { - return err->code; + goto exit; } break; } @@ -89,7 +89,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_RANGE: case OP_LIST_TRIM: if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR1; } break; case OP_LIST_GET_BY_INDEX_RANGE: @@ -100,7 +100,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, &range_specified) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR1; } break; } @@ -111,7 +111,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, (operation_code >= OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL && operation_code <= OP_LIST_GET_BY_VALUE_RANK_RANGE_REL)) { if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR1; } } @@ -134,7 +134,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE_BY_INDEX_RANGE: if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR1; } } @@ -142,7 +142,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_cdt_ctx ctx; if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, serializer_type) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR1; } as_cdt_ctx *ctx_ref = (ctx_in_use ? &ctx : NULL); @@ -155,12 +155,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR2; } break; } - as_list *value_list = NULL; const char *list_values_key = NULL; switch (operation_code) { case OP_LIST_GET_BY_VALUE_LIST: @@ -173,6 +172,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; } + as_list *value_list = NULL; switch (operation_code) { case OP_LIST_GET_BY_VALUE_LIST: case OP_LIST_REMOVE_BY_VALUE_LIST: @@ -180,7 +180,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_INSERT_ITEMS: if (get_val_list(self, err, list_values_key, op_dict, &value_list, static_pool, serializer_type) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR2; } break; } @@ -192,12 +192,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE_BY_VALUE_RANGE: if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, static_pool, serializer_type, false) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR3; } if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, serializer_type, false) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR4; } break; } @@ -208,7 +208,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_CREATE: if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR5; } } @@ -354,7 +354,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR5; } success = as_operations_list_sort(ops, bin, ctx_ref, (as_list_sort_flags)sort_flags); @@ -371,12 +371,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, bool pad, persist_index; if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR5; } if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, &persist_index) != AEROSPIKE_OK) { - return err->code; + goto CLEANUP_ON_ERROR5; } success = as_operations_list_create_all(ops, bin, ctx_ref, @@ -416,7 +416,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; default: // This should never be possible since we only get here if we know that the operation is valid. - return as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); + as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); + goto CLEANUP_ON_ERROR5; } if (!success) { @@ -424,5 +425,26 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); } +CLEANUP_ON_ERROR5: + if (val_end) { + as_val_destroy(val_end); + } +CLEANUP_ON_ERROR4: + if (val_begin) { + as_val_destroy(val_begin); + } +CLEANUP_ON_ERROR3: + if (value_list) { + as_list_destroy(value_list); + } +CLEANUP_ON_ERROR2: + if (ctx_ref) { + as_cdt_ctx_destroy(ctx_ref); + } +CLEANUP_ON_ERROR1: + if (val) { + as_val_destroy(val); + } +exit: return err->code; } From 982816e8430c3c2744c31122ca28d1c291733e9e Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:57:08 -0800 Subject: [PATCH 28/41] Fix --- src/main/client/cdt_list_operate.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index fda59c3c4e..8d7f4863f9 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -66,14 +66,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, switch (operation_code) { case OP_LIST_APPEND: case OP_LIST_INSERT: - case OP_LIST_POP_RANGE: case OP_LIST_SET: case OP_LIST_INCREMENT: case OP_LIST_GET_BY_VALUE: case OP_LIST_REMOVE_BY_VALUE: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: - case OP_LIST_APPEND_ITEMS: if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, serializer_type, true) != AEROSPIKE_OK) { goto exit; From ed26bbde385bfd4945175e042092d925639c5da5 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 14:17:28 -0800 Subject: [PATCH 29/41] as_val shouldn't be destroyed since C client already takes ownership of it --- src/main/client/cdt_list_operate.c | 49 +++++++++++------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 8d7f4863f9..7d800769c9 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -87,7 +87,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_RANGE: case OP_LIST_TRIM: if (get_int64_t(err, AS_PY_VAL_KEY, op_dict, &count) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR1; + goto exit; } break; case OP_LIST_GET_BY_INDEX_RANGE: @@ -98,7 +98,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: if (get_optional_int64_t(err, AS_PY_COUNT_KEY, op_dict, &count, &range_specified) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR1; + goto exit; } break; } @@ -109,7 +109,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, (operation_code >= OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL && operation_code <= OP_LIST_GET_BY_VALUE_RANK_RANGE_REL)) { if (get_list_return_type(err, op_dict, &return_type) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR1; + goto exit; } } @@ -132,7 +132,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE_BY_INDEX_RANGE: if (get_int64_t(err, AS_PY_INDEX_KEY, op_dict, &index) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR1; + goto exit; } } @@ -140,7 +140,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_cdt_ctx ctx; if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, serializer_type) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR1; + goto exit; } as_cdt_ctx *ctx_ref = (ctx_in_use ? &ctx : NULL); @@ -153,7 +153,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR2; + goto CLEANUP_CTX_ON_ERROR; } break; } @@ -178,7 +178,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_INSERT_ITEMS: if (get_val_list(self, err, list_values_key, op_dict, &value_list, static_pool, serializer_type) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR2; + goto CLEANUP_CTX_ON_ERROR; } break; } @@ -190,12 +190,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE_BY_VALUE_RANGE: if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, static_pool, serializer_type, false) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR3; + goto CLEANUP_CTX_ON_ERROR; } if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, serializer_type, false) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR4; + goto CLEANUP_CTX_ON_ERROR; } break; } @@ -206,7 +206,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_CREATE: if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR5; + goto CLEANUP_CTX_ON_ERROR; } } @@ -234,7 +234,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; case OP_LIST_SET: success = as_operations_list_set(ops, bin, ctx_ref, list_policy_ref, - index, val); + index, P); break; case OP_LIST_GET: success = as_operations_list_get(ops, bin, ctx_ref, index); @@ -352,7 +352,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR5; + goto CLEANUP_CTX_ON_ERROR; } success = as_operations_list_sort(ops, bin, ctx_ref, (as_list_sort_flags)sort_flags); @@ -369,12 +369,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, bool pad, persist_index; if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR5; + goto CLEANUP_CTX_ON_ERROR; } if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, &persist_index) != AEROSPIKE_OK) { - goto CLEANUP_ON_ERROR5; + goto CLEANUP_CTX_ON_ERROR; } success = as_operations_list_create_all(ops, bin, ctx_ref, @@ -415,7 +415,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, default: // This should never be possible since we only get here if we know that the operation is valid. as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); - goto CLEANUP_ON_ERROR5; + goto CLEANUP_CTX_ON_ERROR; } if (!success) { @@ -423,26 +423,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); } -CLEANUP_ON_ERROR5: - if (val_end) { - as_val_destroy(val_end); - } -CLEANUP_ON_ERROR4: - if (val_begin) { - as_val_destroy(val_begin); - } -CLEANUP_ON_ERROR3: - if (value_list) { - as_list_destroy(value_list); - } -CLEANUP_ON_ERROR2: +CLEANUP_CTX_ON_ERROR: if (ctx_ref) { as_cdt_ctx_destroy(ctx_ref); } -CLEANUP_ON_ERROR1: - if (val) { - as_val_destroy(val); - } + exit: return err->code; } From a1ed9b76305c96785dd4ba4ceae65b8dd4f75452 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 14:19:46 -0800 Subject: [PATCH 30/41] fix --- src/main/client/cdt_list_operate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 7d800769c9..9cb9e043a9 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -234,7 +234,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, break; case OP_LIST_SET: success = as_operations_list_set(ops, bin, ctx_ref, list_policy_ref, - index, P); + index, val); break; case OP_LIST_GET: success = as_operations_list_get(ops, bin, ctx_ref, index); From f372b80a0fa15722033b0220a81651277dc578c2 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 14:40:08 -0800 Subject: [PATCH 31/41] Curly brackets only needed after case if local variable is initialized --- src/main/client/cdt_list_operate.c | 78 ++++++++++++------------------ 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 9cb9e043a9..b1830a41b3 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -45,7 +45,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, as_list_policy list_policy; as_list_policy *list_policy_ref = NULL; - bool policy_in_use = false; switch (operation_code) { case OP_LIST_APPEND: @@ -53,7 +52,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_INSERT: case OP_LIST_INSERT_ITEMS: case OP_LIST_INCREMENT: - case OP_LIST_SET: + case OP_LIST_SET: { + bool policy_in_use = false; if (get_list_policy(err, op_dict, &list_policy, &policy_in_use, self->validate_keys) != AEROSPIKE_OK) { goto exit; @@ -61,6 +61,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, list_policy_ref = policy_in_use ? &list_policy : NULL; break; } + } as_val *val = NULL; switch (operation_code) { @@ -247,12 +248,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_trim(ops, bin, ctx_ref, index, (uint64_t)count); break; - case OP_LIST_GET_BY_INDEX: { + case OP_LIST_GET_BY_INDEX: success = as_operations_list_get_by_index(ops, bin, ctx_ref, index, return_type); - } break; + break; - case OP_LIST_GET_BY_INDEX_RANGE: { + case OP_LIST_GET_BY_INDEX_RANGE: if (range_specified) { success = as_operations_list_get_by_index_range( ops, bin, ctx_ref, index, (uint64_t)count, return_type); @@ -261,13 +262,13 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_get_by_index_range_to_end( ops, bin, ctx_ref, index, return_type); } - } break; - case OP_LIST_GET_BY_RANK: { + break; + case OP_LIST_GET_BY_RANK: success = as_operations_list_get_by_rank(ops, bin, ctx_ref, rank, return_type); - } break; + break; - case OP_LIST_GET_BY_RANK_RANGE: { + case OP_LIST_GET_BY_RANK_RANGE: if (range_specified) { success = as_operations_list_get_by_rank_range( ops, bin, ctx_ref, rank, (uint64_t)count, return_type); @@ -276,28 +277,25 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_get_by_rank_range_to_end( ops, bin, ctx_ref, rank, return_type); } - } break; - case OP_LIST_GET_BY_VALUE: { + break; + case OP_LIST_GET_BY_VALUE: success = as_operations_list_get_by_value(ops, bin, ctx_ref, val, return_type); - } break; - case OP_LIST_GET_BY_VALUE_LIST: { + break; + case OP_LIST_GET_BY_VALUE_LIST: success = as_operations_list_get_by_value_list(ops, bin, ctx_ref, value_list, return_type); - } break; - - case OP_LIST_GET_BY_VALUE_RANGE: { + break; + case OP_LIST_GET_BY_VALUE_RANGE: success = as_operations_list_get_by_value_range( ops, bin, ctx_ref, val_begin, val_end, return_type); - } break; + break; - case OP_LIST_REMOVE_BY_INDEX: { + case OP_LIST_REMOVE_BY_INDEX: success = as_operations_list_remove_by_index(ops, bin, ctx_ref, index, return_type); break; - } - - case OP_LIST_REMOVE_BY_INDEX_RANGE: { + case OP_LIST_REMOVE_BY_INDEX_RANGE: if (range_specified) { success = as_operations_list_remove_by_index_range( ops, bin, ctx_ref, index, (uint64_t)count, return_type); @@ -306,15 +304,14 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_remove_by_index_range_to_end( ops, bin, ctx_ref, index, return_type); } - } break; + break; - case OP_LIST_REMOVE_BY_RANK: { + case OP_LIST_REMOVE_BY_RANK: success = as_operations_list_remove_by_rank(ops, bin, ctx_ref, rank, return_type); break; - } - case OP_LIST_REMOVE_BY_RANK_RANGE: { + case OP_LIST_REMOVE_BY_RANK_RANGE: if (range_specified) { success = as_operations_list_remove_by_rank_range( ops, bin, ctx_ref, rank, (uint64_t)count, return_type); @@ -323,31 +320,25 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_remove_by_rank_range_to_end( ops, bin, ctx_ref, rank, return_type); } - } break; + break; - case OP_LIST_REMOVE_BY_VALUE: { + case OP_LIST_REMOVE_BY_VALUE: success = as_operations_list_remove_by_value(ops, bin, ctx_ref, val, return_type); break; - } - - case OP_LIST_REMOVE_BY_VALUE_LIST: { + case OP_LIST_REMOVE_BY_VALUE_LIST: success = as_operations_list_remove_by_value_list( ops, bin, ctx_ref, value_list, return_type); - } break; - - case OP_LIST_REMOVE_BY_VALUE_RANGE: { + break; + case OP_LIST_REMOVE_BY_VALUE_RANGE: success = as_operations_list_remove_by_value_range( ops, bin, ctx_ref, val_begin, val_end, return_type); - } break; - - case OP_LIST_SET_ORDER: { + break; + case OP_LIST_SET_ORDER: success = as_operations_list_set_order(ops, bin, ctx_ref, (as_list_order)order_type_int); break; - } - - case OP_LIST_SORT: { + case OP_LIST_SORT: int64_t sort_flags; if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != @@ -357,15 +348,11 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_sort(ops, bin, ctx_ref, (as_list_sort_flags)sort_flags); break; - } - - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: { + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: success = as_operations_list_get_by_value_rel_rank_range( ops, bin, ctx_ref, val, rank, (uint64_t)count, return_type); break; - } - - case OP_LIST_CREATE: { + case OP_LIST_CREATE: bool pad, persist_index; if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != AEROSPIKE_OK) { @@ -381,7 +368,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, (as_list_order)order_type_int, pad, persist_index); break; - } case OP_LIST_APPEND: success = as_operations_list_append(ops, bin, ctx_ref, list_policy_ref, val); From a339e897025a669db40e038fdfaedda6f88cb3d7 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 15:40:12 -0800 Subject: [PATCH 32/41] use X-macro to map operation codes to operation names --- src/include/policy.h | 82 ++++++++++++++---------------- src/main/client/cdt_list_operate.c | 4 +- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/src/include/policy.h b/src/include/policy.h index 9948676a86..cb02e894ce 100644 --- a/src/include/policy.h +++ b/src/include/policy.h @@ -41,50 +41,46 @@ enum Aerospike_send_bool_as_values { SEND_BOOL_AS_AS_BOOL, /* default for writing Python bools */ }; +#define LIST_OP_NAMES_EXCEPT_LIST_APPEND \ + X(LIST_APPEND_ITEMS), X(LIST_INSERT), X(LIST_INSERT_ITEMS), X(LIST_POP), \ + X(LIST_POP_RANGE), X(LIST_REMOVE), X(LIST_REMOVE_RANGE), \ + X(LIST_CLEAR), X(LIST_SET), X(LIST_GET), X(LIST_GET_RANGE), \ + X(LIST_TRIM), X(LIST_SIZE), X(LIST_INCREMENT), X(LIST_GET_BY_INDEX), \ + X(LIST_GET_BY_INDEX_RANGE), X(LIST_GET_BY_RANK), \ + X(LIST_GET_BY_RANK_RANGE), X(LIST_GET_BY_VALUE), \ + X(LIST_GET_BY_VALUE_LIST), X(LIST_GET_BY_VALUE_RANGE), \ + X(LIST_REMOVE_BY_INDEX), X(LIST_REMOVE_BY_INDEX_RANGE), \ + X(LIST_REMOVE_BY_RANK), X(LIST_REMOVE_BY_RANK_RANGE), \ + X(LIST_REMOVE_BY_VALUE), X(LIST_REMOVE_BY_VALUE_LIST), \ + X(LIST_REMOVE_BY_VALUE_RANGE), X(LIST_SET_ORDER), X(LIST_SORT), \ + X(LIST_REMOVE_BY_VALUE_RANK_RANGE_REL), \ + X(LIST_GET_BY_VALUE_RANK_RANGE_REL), \ + X(LIST_GET_BY_VALUE_RANK_RANGE_REL_TO_END), \ + X(LIST_GET_BY_INDEX_RANGE_TO_END), X(LIST_GET_BY_RANK_RANGE_TO_END), \ + X(LIST_REMOVE_BY_REL_RANK_RANGE_TO_END), \ + X(LIST_REMOVE_BY_REL_RANK_RANGE), \ + X(LIST_REMOVE_BY_INDEX_RANGE_TO_END), \ + X(LIST_REMOVE_BY_RANK_RANGE_TO_END), X(LIST_CREATE) + enum Aerospike_list_operations { - OP_LIST_APPEND = 1001, - OP_LIST_APPEND_ITEMS, - OP_LIST_INSERT, - OP_LIST_INSERT_ITEMS, - OP_LIST_POP, - OP_LIST_POP_RANGE, - OP_LIST_REMOVE, - OP_LIST_REMOVE_RANGE, - OP_LIST_CLEAR, - OP_LIST_SET, - OP_LIST_GET, - OP_LIST_GET_RANGE, - OP_LIST_TRIM, - OP_LIST_SIZE, - OP_LIST_INCREMENT, - OP_LIST_GET_BY_INDEX, - OP_LIST_GET_BY_INDEX_RANGE, - OP_LIST_GET_BY_RANK, - OP_LIST_GET_BY_RANK_RANGE, - OP_LIST_GET_BY_VALUE, - OP_LIST_GET_BY_VALUE_LIST, - OP_LIST_GET_BY_VALUE_RANGE, - OP_LIST_REMOVE_BY_INDEX, - OP_LIST_REMOVE_BY_INDEX_RANGE, - OP_LIST_REMOVE_BY_RANK, - OP_LIST_REMOVE_BY_RANK_RANGE, - OP_LIST_REMOVE_BY_VALUE, - OP_LIST_REMOVE_BY_VALUE_LIST, - OP_LIST_REMOVE_BY_VALUE_RANGE, - OP_LIST_SET_ORDER, - OP_LIST_SORT, - OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL, - OP_LIST_GET_BY_VALUE_RANK_RANGE_REL, - - // for use in expressions - OP_LIST_GET_BY_VALUE_RANK_RANGE_REL_TO_END, - OP_LIST_GET_BY_INDEX_RANGE_TO_END, - OP_LIST_GET_BY_RANK_RANGE_TO_END, - OP_LIST_REMOVE_BY_REL_RANK_RANGE_TO_END, - OP_LIST_REMOVE_BY_REL_RANK_RANGE, - OP_LIST_REMOVE_BY_INDEX_RANGE_TO_END, - OP_LIST_REMOVE_BY_RANK_RANGE_TO_END, - OP_LIST_CREATE +#define X(op_name) OP_##op_name + X(LIST_APPEND) = 1001, + LIST_OP_NAMES_EXCEPT_LIST_APPEND +#undef X +}; + +typedef struct { + int operation_code; + const char *operation_name; +} op_code_to_name; + +op_code_to_name op_code_to_names[] = { +#define X(op_name) \ + { \ + OP_##op_name, #op_name \ + } + X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND +#undef X }; enum Aerospike_map_operations { diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index b1830a41b3..55b26723ea 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -405,8 +405,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } if (!success) { - // TODO: regression in error message - as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add operation"); + as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add %s operation", + op_code_to_names[operation_code]); } CLEANUP_CTX_ON_ERROR: From 23f5b55ead720ddc3237c04744b483a0e9269796 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 15:44:19 -0800 Subject: [PATCH 33/41] Define global variable in C source file instead of header to avoid duplicate defs? --- src/include/policy.h | 14 -------------- src/main/client/cdt_list_operate.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/include/policy.h b/src/include/policy.h index cb02e894ce..cc5309e593 100644 --- a/src/include/policy.h +++ b/src/include/policy.h @@ -69,20 +69,6 @@ enum Aerospike_list_operations { #undef X }; -typedef struct { - int operation_code; - const char *operation_name; -} op_code_to_name; - -op_code_to_name op_code_to_names[] = { -#define X(op_name) \ - { \ - OP_##op_name, #op_name \ - } - X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND -#undef X -}; - enum Aerospike_map_operations { OP_MAP_SET_POLICY = 1101, OP_MAP_PUT, diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 55b26723ea..6b6cdeab47 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -30,6 +30,20 @@ #include "cdt_list_operations.h" #include "cdt_operation_utils.h" +typedef struct { + int operation_code; + const char *operation_name; +} op_code_to_name; + +op_code_to_name op_code_to_names[] = { +#define X(op_name) \ + { \ + OP_##op_name, #op_name \ + } + X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND +#undef X +}; + as_status add_new_list_op(AerospikeClient *self, as_error *err, PyObject *op_dict, as_vector *unicodeStrVector, as_static_pool *static_pool, as_operations *ops, From 6f34f7c1d7ca8d737a1964225f6d1485dc946bc8 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 16:24:45 -0800 Subject: [PATCH 34/41] Fix memory error --- src/main/client/cdt_list_operate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 6b6cdeab47..feafbb7a04 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -363,8 +363,14 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, (as_list_sort_flags)sort_flags); break; case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: - success = as_operations_list_get_by_value_rel_rank_range( - ops, bin, ctx_ref, val, rank, (uint64_t)count, return_type); + if (range_specified) { + success = as_operations_list_get_by_value_rel_rank_range( + ops, bin, ctx_ref, val, rank, (uint64_t)count, return_type); + } + else { + success = as_operations_list_get_by_value_rel_rank_range_to_end( + ops, bin, ctx_ref, val, rank, return_type); + } break; case OP_LIST_CREATE: bool pad, persist_index; From 940a7047cd4df79b9bf8b16c5bec90ff879866ef Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 16:55:31 -0800 Subject: [PATCH 35/41] move heap allocations further down the function for performance --- src/main/client/cdt_list_operate.c | 107 ++++++++++++++++++----------- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index feafbb7a04..1f956c8582 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -51,6 +51,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, int serializer_type) { + bool has_as_operations_taken_ownership_of_as_val_objs = false; char *bin = NULL; if (get_bin(err, op_dict, unicodeStrVector, &bin) != AEROSPIKE_OK) { @@ -77,23 +78,6 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } } - as_val *val = NULL; - switch (operation_code) { - case OP_LIST_APPEND: - case OP_LIST_INSERT: - case OP_LIST_SET: - case OP_LIST_INCREMENT: - case OP_LIST_GET_BY_VALUE: - case OP_LIST_REMOVE_BY_VALUE: - case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: - if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, - serializer_type, true) != AEROSPIKE_OK) { - goto exit; - } - break; - } - int64_t count; bool range_specified = false; switch (operation_code) { @@ -151,6 +135,30 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } } + int64_t rank; + switch (operation_code) { + case OP_LIST_GET_BY_RANK: + case OP_LIST_GET_BY_RANK_RANGE: + case OP_LIST_REMOVE_BY_RANK: + case OP_LIST_REMOVE_BY_RANK_RANGE: + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: + if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { + goto exit; + } + break; + } + + int64_t order_type_int; + switch (operation_code) { + case OP_LIST_SET_ORDER: + case OP_LIST_CREATE: + if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != + AEROSPIKE_OK) { + goto exit; + } + } + bool ctx_in_use = false; as_cdt_ctx ctx; if (get_cdt_ctx(self, err, &ctx, op_dict, &ctx_in_use, static_pool, @@ -159,15 +167,18 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, } as_cdt_ctx *ctx_ref = (ctx_in_use ? &ctx : NULL); - int64_t rank; + as_val *val = NULL; switch (operation_code) { - case OP_LIST_GET_BY_RANK: - case OP_LIST_GET_BY_RANK_RANGE: - case OP_LIST_REMOVE_BY_RANK: - case OP_LIST_REMOVE_BY_RANK_RANGE: - case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + case OP_LIST_APPEND: + case OP_LIST_INSERT: + case OP_LIST_SET: + case OP_LIST_INCREMENT: + case OP_LIST_GET_BY_VALUE: + case OP_LIST_REMOVE_BY_VALUE: case OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL: - if (get_int64_t(err, AS_PY_RANK_KEY, op_dict, &rank) != AEROSPIKE_OK) { + case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: + if (get_asval(self, err, AS_PY_VAL_KEY, op_dict, &val, static_pool, + serializer_type, true) != AEROSPIKE_OK) { goto CLEANUP_CTX_ON_ERROR; } break; @@ -193,7 +204,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_INSERT_ITEMS: if (get_val_list(self, err, list_values_key, op_dict, &value_list, static_pool, serializer_type) != AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR1; } break; } @@ -205,26 +216,16 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, case OP_LIST_REMOVE_BY_VALUE_RANGE: if (get_asval(self, err, AS_PY_VAL_BEGIN_KEY, op_dict, &val_begin, static_pool, serializer_type, false) != AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR2; } if (get_asval(self, err, AS_PY_VAL_END_KEY, op_dict, &val_end, static_pool, serializer_type, false) != AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR3; } break; } - int64_t order_type_int; - switch (operation_code) { - case OP_LIST_SET_ORDER: - case OP_LIST_CREATE: - if (get_int64_t(err, AS_PY_LIST_ORDER, op_dict, &order_type_int) != - AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; - } - } - bool success = false; switch (operation_code) { case OP_LIST_SIZE: @@ -357,7 +358,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR4; } success = as_operations_list_sort(ops, bin, ctx_ref, (as_list_sort_flags)sort_flags); @@ -376,12 +377,12 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, bool pad, persist_index; if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR4; } if (get_bool_from_pyargs(err, AS_PY_PERSIST_INDEX, op_dict, &persist_index) != AEROSPIKE_OK) { - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR4; } success = as_operations_list_create_all(ops, bin, ctx_ref, @@ -421,14 +422,38 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, default: // This should never be possible since we only get here if we know that the operation is valid. as_error_update(err, AEROSPIKE_ERR_PARAM, "Unknown operation"); - goto CLEANUP_CTX_ON_ERROR; + goto CLEANUP_VAL_ON_ERROR4; } + has_as_operations_taken_ownership_of_as_val_objs = true; + if (!success) { as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add %s operation", op_code_to_names[operation_code]); } + if (has_as_operations_taken_ownership_of_as_val_objs == false) { + CLEANUP_VAL_ON_ERROR4: + if (val_end) { + as_val_destroy(val_end); + } + + CLEANUP_VAL_ON_ERROR3: + if (val_begin) { + as_val_destroy(val_begin); + } + + CLEANUP_VAL_ON_ERROR2: + if (value_list) { + as_list_destroy(value_list); + } + + CLEANUP_VAL_ON_ERROR1: + if (val) { + as_val_destroy(val); + } + } + CLEANUP_CTX_ON_ERROR: if (ctx_ref) { as_cdt_ctx_destroy(ctx_ref); From 4207bf378f0d3b0079ef4c0e5b069908e1d9ed2f Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 12 Jan 2026 17:30:04 -0800 Subject: [PATCH 36/41] Fix bug where get_cdt_ctx calls a C client API even though the conversion code from Python to C failed beforehand... --- src/main/conversions.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/conversions.c b/src/main/conversions.c index 23065d51c7..598bec8932 100644 --- a/src/main/conversions.c +++ b/src/main/conversions.c @@ -2505,7 +2505,13 @@ as_status get_cdt_ctx(AerospikeClient *self, as_error *err, as_cdt_ctx *cdt_ctx, int pad = 0; get_int_from_py_dict(err, CDT_CTX_ORDER_KEY, py_extra_args, &list_order); + if (err->code != AEROSPIKE_OK) { + goto CLEANUP1; + } get_int_from_py_dict(err, CDT_CTX_PAD_KEY, py_extra_args, &pad); + if (err->code != AEROSPIKE_OK) { + goto CLEANUP1; + } as_cdt_ctx_add_list_index_create(cdt_ctx, int_val, list_order, pad); break; From 18e9a3e74f675db2cee618f9f7aa081bf845f50e Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 13 Jan 2026 08:43:56 -0800 Subject: [PATCH 37/41] get_cdt_ctx must set status local var or it will be AEROSPIKE_OK --- src/main/conversions.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/conversions.c b/src/main/conversions.c index 598bec8932..82aac7cf8a 100644 --- a/src/main/conversions.c +++ b/src/main/conversions.c @@ -2503,12 +2503,13 @@ as_status get_cdt_ctx(AerospikeClient *self, as_error *err, as_cdt_ctx *cdt_ctx, case CDT_CTX_LIST_INDEX_CREATE:; int list_order = 0; int pad = 0; - get_int_from_py_dict(err, CDT_CTX_ORDER_KEY, py_extra_args, - &list_order); + status = get_int_from_py_dict(err, CDT_CTX_ORDER_KEY, + py_extra_args, &list_order); if (err->code != AEROSPIKE_OK) { goto CLEANUP1; } - get_int_from_py_dict(err, CDT_CTX_PAD_KEY, py_extra_args, &pad); + status = get_int_from_py_dict(err, CDT_CTX_PAD_KEY, + py_extra_args, &pad); if (err->code != AEROSPIKE_OK) { goto CLEANUP1; } From 4f415347537077d058d4ac731237748b0533db92 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 13 Jan 2026 09:13:20 -0800 Subject: [PATCH 38/41] Clear up why we have this flag instead of using succeed flag --- src/main/client/cdt_list_operate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 1f956c8582..8b5ede8d32 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -51,6 +51,8 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, int serializer_type) { + // as_operations_add_* API methods can take ownership of heap allocated as_val + // objects even if the methods fail and return false. bool has_as_operations_taken_ownership_of_as_val_objs = false; char *bin = NULL; From 5e739477e670baa4f9a99bf40c15fe30802f59f6 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 13 Jan 2026 09:45:51 -0800 Subject: [PATCH 39/41] Add test case for list_remove_by_index_range receiving count = None --- test/new_tests/test_new_list_operation_helpers.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/new_tests/test_new_list_operation_helpers.py b/test/new_tests/test_new_list_operation_helpers.py index 23d4fc2da4..dc2ee2caeb 100644 --- a/test/new_tests/test_new_list_operation_helpers.py +++ b/test/new_tests/test_new_list_operation_helpers.py @@ -243,17 +243,18 @@ def test_remove_by_index(self): _, _, bins = self.as_connection.get(self.test_key) assert bins[self.test_bin] == self.test_list[:2] + self.test_list[3:] - def test_remove_by_index_range(self): + @pytest.mark.parametrize("count, expected_result", + [(2, [5, 8]), (None, [5, 8, 9, 10])] + ) + def test_remove_by_index_range(self, count, expected_result): """ Remove the 3rd item, a 5 """ - operation = list_operations.list_remove_by_index_range(self.test_bin, 2, aerospike.LIST_RETURN_VALUE, count=2) + operation = list_operations.list_remove_by_index_range(self.test_bin, count, aerospike.LIST_RETURN_VALUE, count=2) result = get_list_result_from_operation(self.as_connection, self.test_key, operation, self.test_bin) - assert result == [5, 8] - _, _, bins = self.as_connection.get(self.test_key) - assert bins[self.test_bin] == self.test_list[:2] + self.test_list[4:] + assert result == expected_result def test_remove_by_index_range_inverted(self): """ From 22094f1775f78626c1d2f2ed891023019de72863 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 13 Jan 2026 09:50:32 -0800 Subject: [PATCH 40/41] Revert "Add test case for list_remove_by_index_range receiving count = None" This reverts commit 5e739477e670baa4f9a99bf40c15fe30802f59f6. --- test/new_tests/test_new_list_operation_helpers.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/new_tests/test_new_list_operation_helpers.py b/test/new_tests/test_new_list_operation_helpers.py index dc2ee2caeb..23d4fc2da4 100644 --- a/test/new_tests/test_new_list_operation_helpers.py +++ b/test/new_tests/test_new_list_operation_helpers.py @@ -243,18 +243,17 @@ def test_remove_by_index(self): _, _, bins = self.as_connection.get(self.test_key) assert bins[self.test_bin] == self.test_list[:2] + self.test_list[3:] - @pytest.mark.parametrize("count, expected_result", - [(2, [5, 8]), (None, [5, 8, 9, 10])] - ) - def test_remove_by_index_range(self, count, expected_result): + def test_remove_by_index_range(self): """ Remove the 3rd item, a 5 """ - operation = list_operations.list_remove_by_index_range(self.test_bin, count, aerospike.LIST_RETURN_VALUE, count=2) + operation = list_operations.list_remove_by_index_range(self.test_bin, 2, aerospike.LIST_RETURN_VALUE, count=2) result = get_list_result_from_operation(self.as_connection, self.test_key, operation, self.test_bin) - assert result == expected_result + assert result == [5, 8] + _, _, bins = self.as_connection.get(self.test_key) + assert bins[self.test_bin] == self.test_list[:2] + self.test_list[4:] def test_remove_by_index_range_inverted(self): """ From f257041625e92b29b8a3abaee45c165cc38497cc Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Tue, 13 Jan 2026 13:22:48 -0800 Subject: [PATCH 41/41] Those stack vars belong to specific cases so they should be in their own scope anyways --- src/main/client/cdt_list_operate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 8b5ede8d32..c24d1c1197 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -355,7 +355,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_set_order(ops, bin, ctx_ref, (as_list_order)order_type_int); break; - case OP_LIST_SORT: + case OP_LIST_SORT: { int64_t sort_flags; if (get_int64_t(err, AS_PY_LIST_SORT_FLAGS, op_dict, &sort_flags) != @@ -365,6 +365,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, success = as_operations_list_sort(ops, bin, ctx_ref, (as_list_sort_flags)sort_flags); break; + } case OP_LIST_GET_BY_VALUE_RANK_RANGE_REL: if (range_specified) { success = as_operations_list_get_by_value_rel_rank_range( @@ -375,7 +376,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, ops, bin, ctx_ref, val, rank, return_type); } break; - case OP_LIST_CREATE: + case OP_LIST_CREATE: { bool pad, persist_index; if (get_bool_from_pyargs(err, AS_PY_PAD, op_dict, &pad) != AEROSPIKE_OK) { @@ -391,6 +392,7 @@ as_status add_new_list_op(AerospikeClient *self, as_error *err, (as_list_order)order_type_int, pad, persist_index); break; + } case OP_LIST_APPEND: success = as_operations_list_append(ops, bin, ctx_ref, list_policy_ref, val);