From 43abbef94e3e1b460751a0b510bf982ee739a7b2 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 8 May 2026 09:35:48 -0700 Subject: [PATCH 01/24] WIP --- src/main/client/bit_operate.c | 247 ++++++++++------------------------ 1 file changed, 70 insertions(+), 177 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 2e962dd3df..60c8fab5ae 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -57,101 +57,6 @@ static as_status get_uint8t_from_pyargs(as_error *err, char *key, static as_status get_uint32t_from_pyargs(as_error *err, char *key, PyObject *op_dict, uint32_t *value); -static as_status add_op_bit_resize(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_bit_set(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type, long operation_code); - -static as_status add_op_bit_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_bit_count(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_bit_add(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_bit_and(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_bit_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_bit_get_int(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_bit_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_bit_lscan(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_bit_lshift(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_bit_not(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_bit_or(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_bit_rscan(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_bit_rshift(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_bit_subtract(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_bit_xor(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_bit_op(AerospikeClient *self, as_error *err, PyObject *op_dict, as_vector *unicodeStrVector, @@ -166,99 +71,103 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, return err->code; } + as_bit_policy bit_policy; switch (operation_code) { case OP_BIT_RESIZE: - return add_op_bit_resize(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_SET: - case OP_BIT_SET_INT: - return add_op_bit_set(self, err, bin, op_dict, ops, static_pool, - serializer_type, operation_code); case OP_BIT_REMOVE: - return add_op_bit_remove(self, err, bin, op_dict, ops, static_pool, - serializer_type); - case OP_BIT_COUNT: - return add_op_bit_count(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_ADD: - return add_op_bit_add(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_AND: - return add_op_bit_and(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_GET: - return add_op_bit_get(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_GET_INT: - return add_op_bit_get_int(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_INSERT: - return add_op_bit_insert(self, err, bin, op_dict, ops, static_pool, - serializer_type); - case OP_BIT_LSCAN: - return add_op_bit_lscan(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_LSHIFT: - return add_op_bit_lshift(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_NOT: - return add_op_bit_not(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_OR: - return add_op_bit_or(self, err, bin, op_dict, ops, static_pool, - serializer_type); - case OP_BIT_RSCAN: - return add_op_bit_rscan(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_RSHIFT: - return add_op_bit_rshift(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_SUBTRACT: - return add_op_bit_subtract(self, err, bin, op_dict, ops, static_pool, - serializer_type); case OP_BIT_XOR: - return add_op_bit_xor(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"); + if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != + AEROSPIKE_OK) { + goto exit; + } + break; } - return err->code; -} - -static as_status add_op_bit_resize(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; as_bit_resize_flags flags = AS_BIT_RESIZE_DEFAULT; - uint32_t new_size = 0; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { + if (operation_code == OP_BIT_RESIZE && + get_bit_resize_flags(err, op_dict, &flags) != AEROSPIKE_OK) { return err->code; } - if (get_bit_resize_flags(err, op_dict, &flags) != AEROSPIKE_OK) { - return err->code; + uint32_t new_size = 0; + switch (operation_code) { + case OP_BIT_RESIZE: + if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &new_size) != + AEROSPIKE_OK) { + return err->code; + } + break; } - if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &new_size) != - AEROSPIKE_OK) { - return err->code; + int64_t bit_offset = 0; + uint32_t bit_size = 0; + switch (operation_code) { + case OP_BIT_SET: + case OP_BIT_COUNT: + case OP_BIT_ADD: + case OP_BIT_AND: + case OP_BIT_GET: + case OP_BIT_GET_INT: + case OP_BIT_LSCAN: + case OP_BIT_LSHIFT: + case OP_BIT_NOT: + case OP_BIT_OR: + case OP_BIT_RSCAN: + case OP_BIT_RSHIFT: + case OP_BIT_SUBTRACT: + case OP_BIT_XOR: + if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != + AEROSPIKE_OK) { + goto exit; + } + + if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != + AEROSPIKE_OK) { + goto exit; + } + break; } - if (!as_operations_bit_resize(ops, bin, NULL, &bit_policy, new_size, - flags)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit resize operation"); + bool success = false; + switch (operation_code) { + case OP_BIT_RESIZE: + success = as_operations_bit_resize(ops, bin, NULL, &bit_policy, + new_size, flags); + case OP_BIT_SET: + case OP_BIT_SET_INT: + case OP_BIT_REMOVE: + case OP_BIT_COUNT: + case OP_BIT_ADD: + case OP_BIT_AND: + case OP_BIT_GET: + case OP_BIT_GET_INT: + case OP_BIT_INSERT: + case OP_BIT_LSCAN: + case OP_BIT_LSHIFT: + case OP_BIT_NOT: + case OP_BIT_OR: + case OP_BIT_RSCAN: + case OP_BIT_RSHIFT: + case OP_BIT_SUBTRACT: + case OP_BIT_XOR: + 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 AEROSPIKE_OK; +exit: + return err->code; } static as_status add_op_bit_set(AerospikeClient *self, as_error *err, char *bin, @@ -267,25 +176,9 @@ static as_status add_op_bit_set(AerospikeClient *self, as_error *err, char *bin, int serializer_type, long operation_code) { as_bit_policy bit_policy; - int64_t bit_offset = 0; uint32_t bit_size = 0; uint32_t value_byte_size = 0; - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - if (operation_code == OP_BIT_SET) { if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, &value_byte_size) != AEROSPIKE_OK) { From 350a812aa14806ec2aaa0285773f65b1292e77a4 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 8 May 2026 10:26:46 -0700 Subject: [PATCH 02/24] WIP --- src/main/client/bit_operate.c | 123 ++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 57 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 60c8fab5ae..cdc59c4871 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -139,28 +139,94 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; } + uint32_t value_byte_size = 0; + uint8_t *value = NULL; + switch (operation_code) { + case OP_BIT_SET: + case OP_BIT_AND: + case OP_BIT_INSERT: + case OP_BIT_OR: + case OP_BIT_XOR: + if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, + &value_byte_size) != AEROSPIKE_OK) { + return err->code; + } + + if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != + AEROSPIKE_OK) { + return as_error_update(err, AEROSPIKE_ERR_PARAM, + "unable to parse value from add_op_bit_set"); + } + break; + } + + int64_t value = 0; + switch (operation_code) { + case OP_BIT_SET_INT: + case OP_BIT_ADD: + case OP_BIT_SUBTRACT: + if (get_int64_t(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { + return as_error_update( + err, AEROSPIKE_ERR_PARAM, + "unable to parse value while adding bit set int operation"); + } + } + + int64_t byte_offset = 0; + switch (operation_code) { + case OP_BIT_REMOVE: + case OP_BIT_INSERT: + if (get_int64_t(err, BYTE_OFFSET_KEY, op_dict, &byte_offset) != + AEROSPIKE_OK) { + return err->code; + } + break; + } + bool success = false; switch (operation_code) { case OP_BIT_RESIZE: success = as_operations_bit_resize(ops, bin, NULL, &bit_policy, new_size, flags); + break; case OP_BIT_SET: + success = as_operations_bit_set(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, value); + break; case OP_BIT_SET_INT: + success = as_operations_bit_set_int(ops, bin, NULL, &bit_policy, + bit_offset, bit_size, value); + break; case OP_BIT_REMOVE: + break; case OP_BIT_COUNT: + break; case OP_BIT_ADD: + break; case OP_BIT_AND: + break; case OP_BIT_GET: + break; case OP_BIT_GET_INT: + break; case OP_BIT_INSERT: + break; case OP_BIT_LSCAN: + break; case OP_BIT_LSHIFT: + break; case OP_BIT_NOT: + break; case OP_BIT_OR: + break; case OP_BIT_RSCAN: + break; case OP_BIT_RSHIFT: + break; case OP_BIT_SUBTRACT: + break; case OP_BIT_XOR: + 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"); @@ -170,52 +236,6 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, return err->code; } -static as_status add_op_bit_set(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type, long operation_code) -{ - as_bit_policy bit_policy; - uint32_t bit_size = 0; - uint32_t value_byte_size = 0; - - if (operation_code == OP_BIT_SET) { - if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, - &value_byte_size) != AEROSPIKE_OK) { - return err->code; - } - - uint8_t *value = NULL; - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != - AEROSPIKE_OK) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "unable to parse value from add_op_bit_set"); - } - - if (!as_operations_bit_set(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit set operation") - } - } - else if (operation_code == OP_BIT_SET_INT) { - int64_t value = 0; - if (get_int64_t(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { - return as_error_update( - err, AEROSPIKE_ERR_PARAM, - "unable to parse value while adding bit set int operation"); - } - - if (!as_operations_bit_set_int(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit set int operation") - } - } - - return AEROSPIKE_OK; -} - static as_status add_op_bit_remove(AerospikeClient *self, as_error *err, char *bin, PyObject *op_dict, as_operations *ops, @@ -223,19 +243,8 @@ static as_status add_op_bit_remove(AerospikeClient *self, as_error *err, int serializer_type) { as_bit_policy bit_policy; - int64_t byte_offset = 0; uint32_t byte_size = 0; - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BYTE_OFFSET_KEY, op_dict, &byte_offset) != - AEROSPIKE_OK) { - return err->code; - } - if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &byte_size) != AEROSPIKE_OK) { return err->code; From 8e1dae23a772aae00c8963f003980180cd83d982 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Thu, 14 May 2026 19:57:29 -0700 Subject: [PATCH 03/24] Finish cleaning technical debt in bit_operate.c --- src/main/client/bit_operate.c | 654 +++++----------------------------- 1 file changed, 85 insertions(+), 569 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index cdc59c4871..fcef1372bb 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -71,6 +71,18 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, return err->code; } + bool sign = false; + switch (operation_code) { + case OP_BIT_ADD: + case OP_BIT_SUBTRACT: + case OP_BIT_GET_INT: + if (get_bool_from_pyargs(err, SIGN_KEY, op_dict, &sign) != + AEROSPIKE_OK) { + return err->code; + } + break; + } + as_bit_policy bit_policy; switch (operation_code) { case OP_BIT_RESIZE: @@ -100,10 +112,10 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, return err->code; } - uint32_t new_size = 0; + uint32_t byte_size = 0; switch (operation_code) { case OP_BIT_RESIZE: - if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &new_size) != + if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &byte_size) != AEROSPIKE_OK) { return err->code; } @@ -160,6 +172,31 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; } + bool value = false; + switch (operation_code) { + case OP_BIT_LSCAN: + case OP_BIT_RSCAN: + if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &value) != + AEROSPIKE_OK) { + return err->code; + } + break; + } + + // TODO: uninitialized + as_bit_overflow_action action; + switch (operation_code) { + case OP_BIT_ADD: + case OP_BIT_SUBTRACT: + int64_t action_int64; + if (get_int64_t(err, ACTION_KEY, op_dict, &action_int64) != + AEROSPIKE_OK) { + return err->code; + } + action = action_int64; + break; + } + int64_t value = 0; switch (operation_code) { case OP_BIT_SET_INT: @@ -172,6 +209,16 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, } } + uint32_t shift = 0; + switch (operation_code) { + case OP_BIT_LSHIFT: + case OP_BIT_RSHIFT: + if (get_uint32t_from_pyargs(err, VALUE_KEY, op_dict, &shift) != + AEROSPIKE_OK) { + return err->code; + } + } + int64_t byte_offset = 0; switch (operation_code) { case OP_BIT_REMOVE: @@ -187,7 +234,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, switch (operation_code) { case OP_BIT_RESIZE: success = as_operations_bit_resize(ops, bin, NULL, &bit_policy, - new_size, flags); + byte_size, flags); break; case OP_BIT_SET: success = as_operations_bit_set(ops, bin, NULL, &bit_policy, bit_offset, @@ -198,609 +245,78 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, bit_offset, bit_size, value); break; case OP_BIT_REMOVE: + success = as_operations_bit_remove(ops, bin, NULL, &bit_policy, + byte_offset, byte_size); break; case OP_BIT_COUNT: + success = as_operations_bit_count(ops, bin, NULL, bit_offset, bit_size); break; case OP_BIT_ADD: + success = as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value, sign, action); break; case OP_BIT_AND: + success = as_operations_bit_and(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, value); break; case OP_BIT_GET: + success = as_operations_bit_get(ops, bin, NULL, bit_offset, bit_size); break; case OP_BIT_GET_INT: + success = as_operations_bit_get_int(ops, bin, NULL, bit_offset, + bit_size, sign); break; case OP_BIT_INSERT: + success = as_operations_bit_insert(ops, bin, NULL, &bit_policy, + byte_offset, value_byte_size, value); break; case OP_BIT_LSCAN: + success = as_operations_bit_lscan(ops, bin, NULL, bit_offset, bit_size, + value); break; case OP_BIT_LSHIFT: + success = as_operations_bit_lshift(ops, bin, NULL, &bit_policy, + bit_offset, bit_size, shift); break; case OP_BIT_NOT: + success = as_operations_bit_not(ops, bin, NULL, &bit_policy, bit_offset, + bit_size); break; case OP_BIT_OR: + success = as_operations_bit_or(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, value); break; case OP_BIT_RSCAN: + success = as_operations_bit_rscan(ops, bin, NULL, bit_offset, bit_size, + value); break; case OP_BIT_RSHIFT: + success = as_operations_bit_rshift(ops, bin, NULL, &bit_policy, + bit_offset, bit_size, shift); break; case OP_BIT_SUBTRACT: + success = + as_operations_bit_subtract(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value, sign, action); break; case OP_BIT_XOR: + success = as_operations_bit_xor(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, value); 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"); } -exit: - return err->code; -} - -static as_status add_op_bit_remove(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - uint32_t byte_size = 0; - - if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &byte_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_remove(ops, bin, NULL, &bit_policy, byte_offset, - byte_size)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit remove operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_count(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t bit_offset = 0; - uint32_t bit_size = 0; - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_count(ops, bin, NULL, bit_offset, bit_size)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit count operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_add(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - int64_t value = 0; - bool sign = false; - as_bit_overflow_action action; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { - return err->code; - } - - if (get_bool_from_pyargs(err, SIGN_KEY, op_dict, &sign) != AEROSPIKE_OK) { - return err->code; - } - - int64_t action_int64; - if (get_int64_t(err, ACTION_KEY, op_dict, &action_int64) != AEROSPIKE_OK) { - return err->code; - } - action = action_int64; - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value, sign, action)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit add operation") + if (!success) { + // TODO: needs to be more specific + as_error_update(err, AEROSPIKE_ERR_PARAM, + "Failed to add bit operation"); } - return AEROSPIKE_OK; -} - -static as_status add_op_bit_and(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - uint32_t value_byte_size = 0; - uint8_t *value = NULL; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, - &value_byte_size) != AEROSPIKE_OK) { - return err->code; - } - - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != - AEROSPIKE_OK) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "unable to parse value from add_op_bit_and"); - } - - if (!as_operations_bit_and(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit and operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_get(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t bit_offset = 0; - uint32_t bit_size = 0; - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_get(ops, bin, NULL, bit_offset, bit_size)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit get int operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_get_int(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t bit_offset = 0; - uint32_t bit_size = 0; - bool sign = false; - - if (get_bool_from_pyargs(err, SIGN_KEY, op_dict, &sign) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_get_int(ops, bin, NULL, bit_offset, bit_size, - sign)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit get operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_insert(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t byte_offset = 0; - uint32_t value_byte_size = 0; - uint8_t *value = NULL; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BYTE_OFFSET_KEY, op_dict, &byte_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, - &value_byte_size) != AEROSPIKE_OK) { - return err->code; - } - - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != - AEROSPIKE_OK) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "unable to parse value from add_op_bit_insert"); - } - - if (!as_operations_bit_insert(ops, bin, NULL, &bit_policy, byte_offset, - value_byte_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit insert operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_lscan(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t bit_offset = 0; - uint32_t bit_size = 0; - bool value = false; - - if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_lscan(ops, bin, NULL, bit_offset, bit_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit lscan operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_lshift(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - uint32_t shift = 0; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, VALUE_KEY, op_dict, &shift) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_lshift(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, shift)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit lshift operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_not(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_not(ops, bin, NULL, &bit_policy, bit_offset, - bit_size)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit not operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_or(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - uint32_t value_byte_size = 0; - uint8_t *value = NULL; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, - &value_byte_size) != AEROSPIKE_OK) { - return err->code; - } - - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != - AEROSPIKE_OK) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "unable to parse value from add_op_bit_or"); - } - - if (!as_operations_bit_or(ops, bin, NULL, &bit_policy, bit_offset, bit_size, - value_byte_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit or operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_rscan(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - int64_t bit_offset = 0; - uint32_t bit_size = 0; - bool value = false; - - if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_rscan(ops, bin, NULL, bit_offset, bit_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit rscan operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_rshift(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - uint32_t shift = 0; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, VALUE_KEY, op_dict, &shift) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_rshift(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, shift)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit rshift operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_subtract(AerospikeClient *self, as_error *err, - char *bin, PyObject *op_dict, - as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - int64_t value = 0; - bool sign = 0; - as_bit_overflow_action action; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { - return err->code; - } - - if (get_bool_from_pyargs(err, SIGN_KEY, op_dict, &sign) != AEROSPIKE_OK) { - return err->code; - } - - int64_t action_int64; - if (get_int64_t(err, ACTION_KEY, op_dict, &action_int64) != AEROSPIKE_OK) { - return err->code; - } - action = action_int64; - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (!as_operations_bit_subtract(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value, sign, action)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit subtract operation") - } - - return AEROSPIKE_OK; -} - -static as_status add_op_bit_xor(AerospikeClient *self, as_error *err, char *bin, - PyObject *op_dict, as_operations *ops, - as_static_pool *static_pool, - int serializer_type) -{ - as_bit_policy bit_policy; - int64_t bit_offset = 0; - uint32_t bit_size = 0; - uint32_t value_byte_size = 0; - uint8_t *value = NULL; - - if (get_bit_policy(err, op_dict, &bit_policy, self->validate_keys) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_int64_t(err, BIT_OFFSET_KEY, op_dict, &bit_offset) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, BIT_SIZE_KEY, op_dict, &bit_size) != - AEROSPIKE_OK) { - return err->code; - } - - if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, - &value_byte_size) != AEROSPIKE_OK) { - return err->code; - } - - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != - AEROSPIKE_OK) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "unable to parse value from add_op_bit_xor"); - } - - if (!as_operations_bit_xor(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value)) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit xor operation") - } - - return AEROSPIKE_OK; +exit: + return err->code; } - static as_status get_bit_resize_flags(as_error *err, PyObject *op_dict, as_bit_resize_flags *resize_flags) { From 06a8fe939297bf08325eaf3dba6a047a5f803742 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 07:40:56 -0700 Subject: [PATCH 04/24] address compiler errors --- src/main/client/bit_operate.c | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index fcef1372bb..e7b2d8fe90 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -152,7 +152,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, } uint32_t value_byte_size = 0; - uint8_t *value = NULL; + uint8_t *uint8_value = NULL; switch (operation_code) { case OP_BIT_SET: case OP_BIT_AND: @@ -164,7 +164,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, return err->code; } - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &value) != + if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &uint8_value) != AEROSPIKE_OK) { return as_error_update(err, AEROSPIKE_ERR_PARAM, "unable to parse value from add_op_bit_set"); @@ -172,11 +172,11 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; } - bool value = false; + bool bool_value = false; switch (operation_code) { case OP_BIT_LSCAN: case OP_BIT_RSCAN: - if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &value) != + if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &bool_value) != AEROSPIKE_OK) { return err->code; } @@ -197,12 +197,13 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; } - int64_t value = 0; + int64_t int64_value = 0; switch (operation_code) { case OP_BIT_SET_INT: case OP_BIT_ADD: case OP_BIT_SUBTRACT: - if (get_int64_t(err, VALUE_KEY, op_dict, &value) != AEROSPIKE_OK) { + if (get_int64_t(err, VALUE_KEY, op_dict, &uint8_value) != + AEROSPIKE_OK) { return as_error_update( err, AEROSPIKE_ERR_PARAM, "unable to parse value while adding bit set int operation"); @@ -238,11 +239,11 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; case OP_BIT_SET: success = as_operations_bit_set(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value); + bit_size, value_byte_size, uint8_value); break; case OP_BIT_SET_INT: success = as_operations_bit_set_int(ops, bin, NULL, &bit_policy, - bit_offset, bit_size, value); + bit_offset, bit_size, uint8_value); break; case OP_BIT_REMOVE: success = as_operations_bit_remove(ops, bin, NULL, &bit_policy, @@ -253,11 +254,11 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; case OP_BIT_ADD: success = as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value, sign, action); + bit_size, uint8_value, sign, action); break; case OP_BIT_AND: success = as_operations_bit_and(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value); + bit_size, value_byte_size, uint8_value); break; case OP_BIT_GET: success = as_operations_bit_get(ops, bin, NULL, bit_offset, bit_size); @@ -267,12 +268,13 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, bit_size, sign); break; case OP_BIT_INSERT: - success = as_operations_bit_insert(ops, bin, NULL, &bit_policy, - byte_offset, value_byte_size, value); + success = + as_operations_bit_insert(ops, bin, NULL, &bit_policy, byte_offset, + value_byte_size, uint8_value); break; case OP_BIT_LSCAN: success = as_operations_bit_lscan(ops, bin, NULL, bit_offset, bit_size, - value); + bool_value); break; case OP_BIT_LSHIFT: success = as_operations_bit_lshift(ops, bin, NULL, &bit_policy, @@ -284,11 +286,11 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; case OP_BIT_OR: success = as_operations_bit_or(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value); + bit_size, value_byte_size, uint8_value); break; case OP_BIT_RSCAN: success = as_operations_bit_rscan(ops, bin, NULL, bit_offset, bit_size, - value); + bool_value); break; case OP_BIT_RSHIFT: success = as_operations_bit_rshift(ops, bin, NULL, &bit_policy, @@ -297,11 +299,11 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_SUBTRACT: success = as_operations_bit_subtract(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value, sign, action); + bit_size, uint8_value, sign, action); break; case OP_BIT_XOR: success = as_operations_bit_xor(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, value); + bit_size, value_byte_size, uint8_value); break; default: // This should never be possible since we only get here if we know that the operation is valid. From 9b537d99f07180b25ae9177b685e6eaf0fd8654f Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 08:01:17 -0700 Subject: [PATCH 05/24] Address compiler error --- src/main/client/bit_operate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index e7b2d8fe90..be41ef5028 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -202,7 +202,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_SET_INT: case OP_BIT_ADD: case OP_BIT_SUBTRACT: - if (get_int64_t(err, VALUE_KEY, op_dict, &uint8_value) != + if (get_int64_t(err, VALUE_KEY, op_dict, &int64_value) != AEROSPIKE_OK) { return as_error_update( err, AEROSPIKE_ERR_PARAM, From cfee064cf047655125e7d1fbbc496b30b6bd50ad Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 08:06:22 -0700 Subject: [PATCH 06/24] Address compiler errors. Leave TODO --- src/main/client/bit_operate.c | 38 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index be41ef5028..9c02687d43 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -152,7 +152,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, } uint32_t value_byte_size = 0; - uint8_t *uint8_value = NULL; + uint8_t *uint8_array_value = NULL; switch (operation_code) { case OP_BIT_SET: case OP_BIT_AND: @@ -164,8 +164,8 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, return err->code; } - if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &uint8_value) != - AEROSPIKE_OK) { + if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, + &uint8_array_value) != AEROSPIKE_OK) { return as_error_update(err, AEROSPIKE_ERR_PARAM, "unable to parse value from add_op_bit_set"); } @@ -238,12 +238,13 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, byte_size, flags); break; case OP_BIT_SET: - success = as_operations_bit_set(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, uint8_value); + success = + as_operations_bit_set(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, uint8_array_value); break; case OP_BIT_SET_INT: success = as_operations_bit_set_int(ops, bin, NULL, &bit_policy, - bit_offset, bit_size, uint8_value); + bit_offset, bit_size, int64_value); break; case OP_BIT_REMOVE: success = as_operations_bit_remove(ops, bin, NULL, &bit_policy, @@ -253,12 +254,14 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, success = as_operations_bit_count(ops, bin, NULL, bit_offset, bit_size); break; case OP_BIT_ADD: - success = as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, uint8_value, sign, action); + success = + as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, uint8_array_value, sign, action); break; case OP_BIT_AND: - success = as_operations_bit_and(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, uint8_value); + success = + as_operations_bit_and(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, uint8_array_value); break; case OP_BIT_GET: success = as_operations_bit_get(ops, bin, NULL, bit_offset, bit_size); @@ -270,7 +273,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_INSERT: success = as_operations_bit_insert(ops, bin, NULL, &bit_policy, byte_offset, - value_byte_size, uint8_value); + value_byte_size, uint8_array_value); break; case OP_BIT_LSCAN: success = as_operations_bit_lscan(ops, bin, NULL, bit_offset, bit_size, @@ -285,8 +288,9 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, bit_size); break; case OP_BIT_OR: - success = as_operations_bit_or(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, uint8_value); + success = + as_operations_bit_or(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, uint8_array_value); break; case OP_BIT_RSCAN: success = as_operations_bit_rscan(ops, bin, NULL, bit_offset, bit_size, @@ -297,13 +301,15 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, bit_offset, bit_size, shift); break; case OP_BIT_SUBTRACT: + // TODO: int64_value is the wrong type here. This problem exists in dev success = as_operations_bit_subtract(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, uint8_value, sign, action); + bit_size, int64_value, sign, action); break; case OP_BIT_XOR: - success = as_operations_bit_xor(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, value_byte_size, uint8_value); + success = + as_operations_bit_xor(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, value_byte_size, uint8_array_value); break; default: // This should never be possible since we only get here if we know that the operation is valid. From 9da78647d49ff8e702fce4280ebe7383e0a34327 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 08:09:37 -0700 Subject: [PATCH 07/24] Address one more compiler error. Leave TODO --- src/main/client/bit_operate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 9c02687d43..2388ff386b 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -254,9 +254,9 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, success = as_operations_bit_count(ops, bin, NULL, bit_offset, bit_size); break; case OP_BIT_ADD: - success = - as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, uint8_array_value, sign, action); + // TODO: value is wrong type + success = as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, int64_value, sign, action); break; case OP_BIT_AND: success = From 2ec22a8bd77424e67df1975292eb18057f1a3a92 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 08:11:51 -0700 Subject: [PATCH 08/24] Address compiler warning --- src/main/client/bit_operate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 2388ff386b..4239d217f7 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -183,8 +183,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; } - // TODO: uninitialized - as_bit_overflow_action action; + as_bit_overflow_action action = AS_BIT_OVERFLOW_FAIL; switch (operation_code) { case OP_BIT_ADD: case OP_BIT_SUBTRACT: From eae0faa34704438d7e1f6be9eac8282f1b7e2296 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 09:20:44 -0700 Subject: [PATCH 09/24] Address test regressions --- src/main/client/bit_operate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 4239d217f7..2f9c289eaa 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -115,6 +115,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, uint32_t byte_size = 0; switch (operation_code) { case OP_BIT_RESIZE: + case OP_BIT_REMOVE: if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &byte_size) != AEROSPIKE_OK) { return err->code; @@ -126,6 +127,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, uint32_t bit_size = 0; switch (operation_code) { case OP_BIT_SET: + case OP_BIT_SET_INT: case OP_BIT_COUNT: case OP_BIT_ADD: case OP_BIT_AND: From d6cfec5549a484e1c1ebf3a948c5b185846acecc Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 09:59:20 -0700 Subject: [PATCH 10/24] Address test regressions --- src/main/client/bit_operate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 2f9c289eaa..7ff9eaa883 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -87,6 +87,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, switch (operation_code) { case OP_BIT_RESIZE: case OP_BIT_SET: + case OP_BIT_SET_INT: case OP_BIT_REMOVE: case OP_BIT_ADD: case OP_BIT_AND: From c4a6dcfeff8926de47dc1fb7405fb550827feddc Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 10:46:25 -0700 Subject: [PATCH 11/24] Replace all returns with goto statement --- src/main/client/bit_operate.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 7ff9eaa883..87369160ac 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -68,7 +68,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, char *bin = NULL; if (get_bin(err, op_dict, unicodeStrVector, &bin) != AEROSPIKE_OK) { - return err->code; + goto exit; } bool sign = false; @@ -78,7 +78,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_GET_INT: if (get_bool_from_pyargs(err, SIGN_KEY, op_dict, &sign) != AEROSPIKE_OK) { - return err->code; + goto exit; } break; } @@ -110,7 +110,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, as_bit_resize_flags flags = AS_BIT_RESIZE_DEFAULT; if (operation_code == OP_BIT_RESIZE && get_bit_resize_flags(err, op_dict, &flags) != AEROSPIKE_OK) { - return err->code; + goto exit; } uint32_t byte_size = 0; @@ -119,7 +119,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_REMOVE: if (get_uint32t_from_pyargs(err, BYTE_SIZE_KEY, op_dict, &byte_size) != AEROSPIKE_OK) { - return err->code; + goto exit; } break; } @@ -164,13 +164,12 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_XOR: if (get_uint32t_from_pyargs(err, VALUE_BYTE_SIZE_KEY, op_dict, &value_byte_size) != AEROSPIKE_OK) { - return err->code; + goto exit; } if (get_uint8t_from_pyargs(err, VALUE_KEY, op_dict, &uint8_array_value) != AEROSPIKE_OK) { - return as_error_update(err, AEROSPIKE_ERR_PARAM, - "unable to parse value from add_op_bit_set"); + goto exit; } break; } @@ -181,7 +180,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_RSCAN: if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &bool_value) != AEROSPIKE_OK) { - return err->code; + goto exit; } break; } @@ -193,7 +192,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, int64_t action_int64; if (get_int64_t(err, ACTION_KEY, op_dict, &action_int64) != AEROSPIKE_OK) { - return err->code; + goto exit; } action = action_int64; break; @@ -206,9 +205,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_SUBTRACT: if (get_int64_t(err, VALUE_KEY, op_dict, &int64_value) != AEROSPIKE_OK) { - return as_error_update( - err, AEROSPIKE_ERR_PARAM, - "unable to parse value while adding bit set int operation"); + goto exit; } } @@ -218,7 +215,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_RSHIFT: if (get_uint32t_from_pyargs(err, VALUE_KEY, op_dict, &shift) != AEROSPIKE_OK) { - return err->code; + goto exit; } } @@ -228,7 +225,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_INSERT: if (get_int64_t(err, BYTE_OFFSET_KEY, op_dict, &byte_offset) != AEROSPIKE_OK) { - return err->code; + goto exit; } break; } @@ -315,7 +312,8 @@ as_status add_new_bit_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 exit; } if (!success) { From 74e90c3b77b883aa14683b8815a78ab298da528d Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 11:47:40 -0700 Subject: [PATCH 12/24] Clear up TODO comments --- src/main/client/bit_operate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 87369160ac..d5f5237217 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -253,7 +253,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, success = as_operations_bit_count(ops, bin, NULL, bit_offset, bit_size); break; case OP_BIT_ADD: - // TODO: value is wrong type + // TODO: value argument is wrong type. This problem exists in dev success = as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, bit_size, int64_value, sign, action); break; @@ -300,7 +300,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, bit_offset, bit_size, shift); break; case OP_BIT_SUBTRACT: - // TODO: int64_value is the wrong type here. This problem exists in dev + // TODO: value argument is wrong type. This problem exists in dev success = as_operations_bit_subtract(ops, bin, NULL, &bit_policy, bit_offset, bit_size, int64_value, sign, action); From 2e2866c5062dfe4eb8b06138d25473e86ce2f58a Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 11:53:07 -0700 Subject: [PATCH 13/24] Show more specific error message if bit operation fails to be added. --- src/include/policy.h | 28 ++++++++++------------------ src/main/client/bit_operate.c | 11 ++++++++--- src/main/client/cdt_list_operate.c | 5 ----- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/include/policy.h b/src/include/policy.h index f1891e464a..3f67a040a3 100644 --- a/src/include/policy.h +++ b/src/include/policy.h @@ -116,25 +116,17 @@ enum Aerospike_map_operations { OP_MAP_CREATE }; +#define BIT_OP_NAMES_EXCEPT_RESIZE \ + X(BIT_INSERT), X(BIT_REMOVE), X(BIT_SET), X(BIT_OR), X(BIT_XOR), \ + X(BIT_AND), X(BIT_NOT), X(BIT_LSHIFT), X(BIT_RSHIFT), X(BIT_ADD), \ + X(BIT_SUBTRACT), X(BIT_GET_INT), X(BIT_SET_INT), X(BIT_GET), \ + X(BIT_COUNT), X(BIT_LSCAN), X(BIT_RSCAN) + enum aerospike_bitwise_operations { - OP_BIT_RESIZE = 2000, - OP_BIT_INSERT, - OP_BIT_REMOVE, - OP_BIT_SET, - OP_BIT_OR, - OP_BIT_XOR, - OP_BIT_AND, - OP_BIT_NOT, - OP_BIT_LSHIFT, - OP_BIT_RSHIFT, - OP_BIT_ADD, - OP_BIT_SUBTRACT, - OP_BIT_GET_INT, - OP_BIT_SET_INT, - OP_BIT_GET, - OP_BIT_COUNT, - OP_BIT_LSCAN, - OP_BIT_RSCAN +#define X(op_name) OP_##op_name + X(BIT_RESIZE) = 2000, + BIT_OP_NAMES_EXCEPT_RESIZE +#undef X }; enum aerospike_hll_operations { diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index d5f5237217..569506350a 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -57,6 +57,12 @@ static as_status get_uint8t_from_pyargs(as_error *err, char *key, static as_status get_uint32t_from_pyargs(as_error *err, char *key, PyObject *op_dict, uint32_t *value); +const char *op_code_to_names[] = { +#define X(op_name) [OP_##op_name] = #op_name + X(BIT_RESIZE), BIT_OP_NAMES_EXCEPT_RESIZE +#undef X +}; + // End forwards as_status add_new_bit_op(AerospikeClient *self, as_error *err, PyObject *op_dict, as_vector *unicodeStrVector, @@ -317,9 +323,8 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, } if (!success) { - // TODO: needs to be more specific - as_error_update(err, AEROSPIKE_ERR_PARAM, - "Failed to add bit operation"); + as_error_update(err, AEROSPIKE_ERR_CLIENT, "Failed to add %s operation", + op_code_to_names[operation_code]); } exit: diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index c649be0fd3..26c09bf3f8 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -30,11 +30,6 @@ #include "cdt_list_operations.h" #include "cdt_operation_utils.h" -typedef struct { - int operation_code; - const char *operation_name; -} op_code_to_name; - const char *op_code_to_names[] = { #define X(op_name) [OP_##op_name] = #op_name X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND From b49c6c0b7d28c843147ca304f4df9591a7095497 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Fri, 15 May 2026 12:44:32 -0700 Subject: [PATCH 14/24] Make arrays static so they don't conflict with each other at link time. TODO should combine them in the near future --- src/main/client/bit_operate.c | 2 +- src/main/client/cdt_list_operate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 569506350a..2407d60355 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -57,7 +57,7 @@ static as_status get_uint8t_from_pyargs(as_error *err, char *key, static as_status get_uint32t_from_pyargs(as_error *err, char *key, PyObject *op_dict, uint32_t *value); -const char *op_code_to_names[] = { +static const char *op_code_to_names[] = { #define X(op_name) [OP_##op_name] = #op_name X(BIT_RESIZE), BIT_OP_NAMES_EXCEPT_RESIZE #undef X diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 26c09bf3f8..f0c1a5be32 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -30,7 +30,7 @@ #include "cdt_list_operations.h" #include "cdt_operation_utils.h" -const char *op_code_to_names[] = { +static const char *op_code_to_names[] = { #define X(op_name) [OP_##op_name] = #op_name X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND #undef X From ac866bf84940a83e05effa6b9bab1fb4dbeda778 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 14:01:21 -0700 Subject: [PATCH 15/24] Add section to ignore clang-format so each macro is in its own line --- src/include/policy.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/include/policy.h b/src/include/policy.h index 3f67a040a3..6c977cbada 100644 --- a/src/include/policy.h +++ b/src/include/policy.h @@ -116,11 +116,26 @@ enum Aerospike_map_operations { OP_MAP_CREATE }; +// clang-format off #define BIT_OP_NAMES_EXCEPT_RESIZE \ - X(BIT_INSERT), X(BIT_REMOVE), X(BIT_SET), X(BIT_OR), X(BIT_XOR), \ - X(BIT_AND), X(BIT_NOT), X(BIT_LSHIFT), X(BIT_RSHIFT), X(BIT_ADD), \ - X(BIT_SUBTRACT), X(BIT_GET_INT), X(BIT_SET_INT), X(BIT_GET), \ - X(BIT_COUNT), X(BIT_LSCAN), X(BIT_RSCAN) + X(BIT_INSERT), \ + X(BIT_REMOVE), \ + X(BIT_SET), \ + X(BIT_OR), \ + X(BIT_XOR), \ + X(BIT_AND), \ + X(BIT_NOT), \ + X(BIT_LSHIFT), \ + X(BIT_RSHIFT), \ + X(BIT_ADD), \ + X(BIT_SUBTRACT), \ + X(BIT_GET_INT), \ + X(BIT_SET_INT), \ + X(BIT_GET), \ + X(BIT_COUNT), \ + X(BIT_LSCAN), \ + X(BIT_RSCAN) +// clang-format on enum aerospike_bitwise_operations { #define X(op_name) OP_##op_name From e81ee0767937567a10d1d58b4d3315c4ed6e201c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 14:20:55 -0700 Subject: [PATCH 16/24] Reuse const char * array in cdt_list_operate to save memory --- src/main/client/bit_operate.c | 6 +----- src/main/client/cdt_list_operate.c | 5 +++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 2407d60355..7f39a025ef 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -57,11 +57,7 @@ static as_status get_uint8t_from_pyargs(as_error *err, char *key, static as_status get_uint32t_from_pyargs(as_error *err, char *key, PyObject *op_dict, uint32_t *value); -static const char *op_code_to_names[] = { -#define X(op_name) [OP_##op_name] = #op_name - X(BIT_RESIZE), BIT_OP_NAMES_EXCEPT_RESIZE -#undef X -}; +extern const char *op_code_to_names[]; // End forwards as_status add_new_bit_op(AerospikeClient *self, as_error *err, diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index f0c1a5be32..0bd8bc34f4 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -30,9 +30,10 @@ #include "cdt_list_operations.h" #include "cdt_operation_utils.h" -static const char *op_code_to_names[] = { +const char *op_code_to_names[] = { #define X(op_name) [OP_##op_name] = #op_name - X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND + X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND, X(BIT_RESIZE), + BIT_OP_NAMES_EXCEPT_RESIZE #undef X }; From 532d2cee03a81d04c1017f868488c08e67d0388b Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 14:33:00 -0700 Subject: [PATCH 17/24] Provide estimate of memory usage for the op_code_to_names array. --- src/main/client/cdt_list_operate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/client/cdt_list_operate.c b/src/main/client/cdt_list_operate.c index 0bd8bc34f4..02a281c572 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -30,6 +30,11 @@ #include "cdt_list_operations.h" #include "cdt_operation_utils.h" +// Estimated size of array: (8 byte const char* address) * 2000 = 16000 bytes = 0.016 MB +// not including the string constants the array points to +// We estimate each string to be 15 bytes long. +// 20 bytes * 2000 = 40000 bytes = 0.04 MB +// Total memory usage is about 0.056 MB per client const char *op_code_to_names[] = { #define X(op_name) [OP_##op_name] = #op_name X(LIST_APPEND), LIST_OP_NAMES_EXCEPT_LIST_APPEND, X(BIT_RESIZE), From f96352786655a66c9f2567e79e7ce031ae097ed9 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 14:34:48 -0700 Subject: [PATCH 18/24] fix comment... --- 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 02a281c572..127393266b 100644 --- a/src/main/client/cdt_list_operate.c +++ b/src/main/client/cdt_list_operate.c @@ -32,7 +32,7 @@ // Estimated size of array: (8 byte const char* address) * 2000 = 16000 bytes = 0.016 MB // not including the string constants the array points to -// We estimate each string to be 15 bytes long. +// We estimate each string to be 20 bytes long. // 20 bytes * 2000 = 40000 bytes = 0.04 MB // Total memory usage is about 0.056 MB per client const char *op_code_to_names[] = { From 8691e1f2a261877519eed2a49aebdf3699a5f085 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 15:46:51 -0700 Subject: [PATCH 19/24] Add more tests to increase code coverage. --- test/new_tests/test_bitwise_operations.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/new_tests/test_bitwise_operations.py b/test/new_tests/test_bitwise_operations.py index e55585422d..e29cda21a1 100644 --- a/test/new_tests/test_bitwise_operations.py +++ b/test/new_tests/test_bitwise_operations.py @@ -1647,3 +1647,19 @@ def test_bit_xor_with_policy(self): _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([0] * 5) assert bins[self.test_bin_zeroes] == expected_result + + BIN_NAME_FOR_INVALID_PARAMS = "bitwise0" + + @pytest.mark.parametrize( + "op", + [ + pytest.param( + bitwise_operations.bit_add(BIN_NAME_FOR_INVALID_PARAMS, 7, 8, 1, sign="true"), + id="invalid sign" + ), + pytest.param( + bitwise_operations.bit_resize(BIN_NAME_FOR_INVALID_PARAMS, 7, policy=None, resize_flags={}), + id="invalid resize flags" + ) + ] + ) From 96ff2897a9e9d888abeadc27272a10a1b006b5c4 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 15:50:44 -0700 Subject: [PATCH 20/24] Fix careless mistake --- test/new_tests/test_bitwise_operations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/new_tests/test_bitwise_operations.py b/test/new_tests/test_bitwise_operations.py index e29cda21a1..b279e768f5 100644 --- a/test/new_tests/test_bitwise_operations.py +++ b/test/new_tests/test_bitwise_operations.py @@ -1663,3 +1663,9 @@ def test_bit_xor_with_policy(self): ) ] ) + def test_invalid_args(self, op): + ops = [ + op + ] + with pytest.raises(e.ParamError): + self.as_connection.operate(self.test_key, ops) From e277aab98822a1546aaa61c9a419a4a6d783a96c Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 15:56:26 -0700 Subject: [PATCH 21/24] Merge similar code paths to increase code coverage and reduce repetition. --- src/main/client/bit_operate.c | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index 7f39a025ef..b53f712059 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -73,12 +73,24 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, goto exit; } - bool sign = false; + bool bool_value = false; switch (operation_code) { case OP_BIT_ADD: case OP_BIT_SUBTRACT: case OP_BIT_GET_INT: - if (get_bool_from_pyargs(err, SIGN_KEY, op_dict, &sign) != + case OP_BIT_LSCAN: + case OP_BIT_RSCAN: + + const char *bool_key = VALUE_KEY; + switch (operation_code) { + case OP_BIT_ADD: + case OP_BIT_SUBTRACT: + case OP_BIT_GET_INT: + bool_key = SIGN_KEY; + break; + } + + if (get_bool_from_pyargs(err, bool_key, op_dict, &bool_value) != AEROSPIKE_OK) { goto exit; } @@ -176,17 +188,6 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; } - bool bool_value = false; - switch (operation_code) { - case OP_BIT_LSCAN: - case OP_BIT_RSCAN: - if (get_bool_from_pyargs(err, VALUE_KEY, op_dict, &bool_value) != - AEROSPIKE_OK) { - goto exit; - } - break; - } - as_bit_overflow_action action = AS_BIT_OVERFLOW_FAIL; switch (operation_code) { case OP_BIT_ADD: @@ -256,8 +257,9 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; case OP_BIT_ADD: // TODO: value argument is wrong type. This problem exists in dev - success = as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, int64_value, sign, action); + success = + as_operations_bit_add(ops, bin, NULL, &bit_policy, bit_offset, + bit_size, int64_value, bool_value, action); break; case OP_BIT_AND: success = @@ -269,7 +271,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; case OP_BIT_GET_INT: success = as_operations_bit_get_int(ops, bin, NULL, bit_offset, - bit_size, sign); + bit_size, bool_value); break; case OP_BIT_INSERT: success = @@ -303,9 +305,9 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, break; case OP_BIT_SUBTRACT: // TODO: value argument is wrong type. This problem exists in dev - success = - as_operations_bit_subtract(ops, bin, NULL, &bit_policy, bit_offset, - bit_size, int64_value, sign, action); + success = as_operations_bit_subtract(ops, bin, NULL, &bit_policy, + bit_offset, bit_size, int64_value, + bool_value, action); break; case OP_BIT_XOR: success = From 5ec39a9794cd949aae6628ed35e8aa4f317e02b8 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 16:09:18 -0700 Subject: [PATCH 22/24] Prevent discard const warning --- src/main/client/bit_operate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/client/bit_operate.c b/src/main/client/bit_operate.c index b53f712059..4d59a43e8f 100644 --- a/src/main/client/bit_operate.c +++ b/src/main/client/bit_operate.c @@ -81,7 +81,7 @@ as_status add_new_bit_op(AerospikeClient *self, as_error *err, case OP_BIT_LSCAN: case OP_BIT_RSCAN: - const char *bool_key = VALUE_KEY; + char *bool_key = VALUE_KEY; switch (operation_code) { case OP_BIT_ADD: case OP_BIT_SUBTRACT: From 09e9f0f7fad4ae64cb178fb481cae556c04872a5 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 16:13:12 -0700 Subject: [PATCH 23/24] Add missing required param --- test/new_tests/test_bitwise_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/new_tests/test_bitwise_operations.py b/test/new_tests/test_bitwise_operations.py index b279e768f5..7a2e443efa 100644 --- a/test/new_tests/test_bitwise_operations.py +++ b/test/new_tests/test_bitwise_operations.py @@ -1654,7 +1654,7 @@ def test_bit_xor_with_policy(self): "op", [ pytest.param( - bitwise_operations.bit_add(BIN_NAME_FOR_INVALID_PARAMS, 7, 8, 1, sign="true"), + bitwise_operations.bit_add(BIN_NAME_FOR_INVALID_PARAMS, 7, 8, 1, sign="true", action=aerospike.BIT_OVERFLOW_WRAP), id="invalid sign" ), pytest.param( From 6ed0cad09e09a8336c0974915cad6893203dde5e Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 18 May 2026 16:53:25 -0700 Subject: [PATCH 24/24] Add more test coverage --- test/new_tests/test_bitwise_operations.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/new_tests/test_bitwise_operations.py b/test/new_tests/test_bitwise_operations.py index 7a2e443efa..4302eeb2f1 100644 --- a/test/new_tests/test_bitwise_operations.py +++ b/test/new_tests/test_bitwise_operations.py @@ -1660,7 +1660,15 @@ def test_bit_xor_with_policy(self): pytest.param( bitwise_operations.bit_resize(BIN_NAME_FOR_INVALID_PARAMS, 7, policy=None, resize_flags={}), id="invalid resize flags" - ) + ), + pytest.param( + bitwise_operations.bit_add(BIN_NAME_FOR_INVALID_PARAMS, 7, 8, 1, sign="true", action="invalid action"), + id="invalid action" + ), + pytest.param( + bitwise_operations.bit_lshift(BIN_NAME_FOR_INVALID_PARAMS, 7, 8, shift=None), + id="invalid shift" + ), ] ) def test_invalid_args(self, op):