Skip to content

Commit c39d04a

Browse files
committed
Merge remote-tracking branch 'origin/v20' into CLIENT-681-2025
2 parents 85726ea + f8bb0d3 commit c39d04a

21 files changed

Lines changed: 161 additions & 458 deletions

aerospike-stubs/aerospike.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ class Client:
461461
def index_map_values_create(self, ns: str, set: str, bin: str, index_datatype: int, name: str, policy: dict = ..., ctx: Optional[list] = ...) -> None: ...
462462
def index_set_create(self, ns: str, set: str, name: str, policy: dict = ...) -> None: ...
463463

464-
def index_cdt_create(self, ns: str, set: str, bin: str, index_type: int, index_datatype: int, name: str, ctx: list, policy: dict = ...) -> int: ...
465464
def index_expr_create(self, ns: str, set: str, index_type: int, index_datatype: int, expressions: list, name: str, policy: dict = ...) -> None: ...
466465

467466
def index_remove(self, ns, name: str, policy: dict = ...) -> None: ...
@@ -479,7 +478,7 @@ class Client:
479478
def put(self, key: tuple, bins: dict, meta: dict = ..., policy: dict = ..., serializer = ...) -> None: ...
480479
def query(self, namespace: str, set: Optional[str] = None) -> Query: ...
481480
def query_apply(self, ns: str, set: str, predicate: tuple, module: str, function: str, args: list = ..., policy: dict = ...) -> int: ...
482-
def remove(self, key: tuple, meta: dict = ..., policy: dict = ...) -> None: ...
481+
def remove(self, key: tuple, policy: dict = ...) -> None: ...
483482
def remove_bin(self, key: tuple, list: list, meta: dict = ..., policy: dict = ...) -> None: ...
484483
def scan(self, namespace: str, set: Optional[str] = None) -> Scan: ...
485484
def scan_apply(self, ns: str, set: str, module: str, function: str, args: list = ..., policy: dict = ..., options: dict = ...) -> int: ...

aerospike_helpers/batch/records.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ def __init__(self, key: tuple) -> None:
6565
class Write(BatchRecord):
6666
""" Write is used for executing Batch write commands with batch_write and retrieving batch write results.
6767
68-
.. include:: ./deprecate_meta_ttl.rst
69-
7068
Attributes:
7169
key (:obj:`tuple`): The aerospike key to send the command to.
7270
record (:obj:`tuple`): The record corresponding to the requested key.
@@ -76,7 +74,7 @@ class Write(BatchRecord):
7674
to the server.
7775
ops (:ref:`aerospike_operation_helpers.operations`): A list of aerospike operation dictionaries to perform
7876
on the record at key.
79-
meta (dict): the metadata to set for this command
77+
meta (dict): the expected generation for this record
8078
policy (:ref:`aerospike_batch_write_policies`, optional): An optional dictionary of batch write policy
8179
flags.
8280
"""
@@ -120,9 +118,6 @@ def __init__(
120118
class Read(BatchRecord):
121119
""" Read is used for executing Batch read commands with batch_write and retrieving results.
122120
123-
.. deprecated:: 19.1.0 Deprecated the ``"ttl"`` option in the ``meta`` parameter. Use the policy parameter in a
124-
:py:obj:`~aerospike_helpers.batch.records.Write` BatchRecord to set the ``"ttl"`` instead.
125-
126121
Attributes:
127122
key (:obj:`tuple`): The aerospike key to send the command to.
128123
record (:obj:`tuple`): The record corresponding to the requested key.
@@ -132,7 +127,7 @@ class Read(BatchRecord):
132127
to the server.
133128
ops (:ref:`aerospike_operation_helpers.operations`): list of aerospike operation dictionaries to perform on
134129
the record at key.
135-
meta (dict): the metadata to set for this command
130+
meta (dict): the expected generation for this record
136131
read_all_bins (:obj:`bool`, optional): An optional bool, if True, read all bins in the record.
137132
policy (:ref:`aerospike_batch_read_policies`, optional): An optional dictionary of batch read policy flags.
138133
"""

doc/client.rst

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,9 @@ Record Commands
152152

153153
Create a new record, or remove / add bins to a record.
154154

155-
.. include:: ./deprecate_meta_ttl.rst
156-
157155
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
158156
:param dict bins: contains bin name-value pairs of the record.
159-
:param dict meta: record metadata to be set. see :ref:`metadata_dict`.
157+
:param dict meta: record generation to compare. see :ref:`metadata_dict`.
160158
:param dict policy: see :ref:`aerospike_write_policies`.
161159

162160
:param serializer: override the serialization mode of the client \
@@ -317,11 +315,9 @@ Record Commands
317315
(In Aerospike server versions prior to 3.6.0, non-existent bins being read will have a \
318316
:py:obj:`None` value. )
319317

320-
.. include:: ./deprecate_meta_ttl.rst
321-
322318
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
323319
:param list list: See :ref:`aerospike_operation_helpers.operations`.
324-
:param dict meta: record metadata to be set. See :ref:`metadata_dict`.
320+
:param dict meta: record generation to compare. See :ref:`metadata_dict`.
325321
:param dict policy: optional :ref:`aerospike_operate_policies`.
326322
:return: a :ref:`aerospike_record_tuple`.
327323
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
@@ -372,11 +368,9 @@ Record Commands
372368

373369
Write operations or read operations that fail will not return a ``(bin-name, result)`` tuple.
374370

375-
.. include:: ./deprecate_meta_ttl.rst
376-
377371
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
378372
:param list list: See :ref:`aerospike_operation_helpers.operations`.
379-
:param dict meta: record metadata to be set. See :ref:`metadata_dict`.
373+
:param dict meta: record generation to compare. See :ref:`metadata_dict`.
380374
:param dict policy: optional :ref:`aerospike_operate_policies`.
381375

382376
:return: a :ref:`aerospike_record_tuple`.
@@ -414,13 +408,9 @@ Record Commands
414408

415409
Touch the given record, setting its time-to-live and incrementing its generation.
416410

417-
.. versionchanged:: 19.1.0
418-
419-
Deprecated the ``meta["ttl"]`` parameter. Use the ``val`` parameter instead.
420-
421411
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
422412
:param int val: ttl in seconds, with ``0`` resolving to the default value in the server config.
423-
:param dict meta: record metadata to be set. see :ref:`metadata_dict`
413+
:param dict meta: record generation to compare. see :ref:`metadata_dict`
424414
:param dict policy: see :ref:`aerospike_operate_policies`.
425415

426416
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
@@ -446,16 +436,11 @@ Record Commands
446436
{'ttl': 2592000, 'gen': 1}
447437
{'ttl': 120, 'gen': 2}
448438

449-
.. method:: remove(key[meta: dict[, policy: dict]])
439+
.. method:: remove(key[, policy: dict])
450440

451441
Remove a record matching the *key* from the cluster.
452442

453-
.. versionchanged:: 19.1.0
454-
455-
Deprecated the ``meta`` parameter. Use the policy parameter to set ``gen`` instead.
456-
457443
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
458-
:param dict meta: contains the expected generation of the record in a key called ``"gen"``.
459444
:param dict policy: see :ref:`aerospike_remove_policies`. May be passed as a keyword argument.
460445

461446
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
@@ -468,7 +453,7 @@ Record Commands
468453

469454
# Try to remove it with the wrong generation
470455
try:
471-
client.remove(keyTuple, meta={'gen': 5}, policy={'gen': aerospike.POLICY_GEN_EQ})
456+
client.remove(keyTuple, policy={'gen': aerospike.POLICY_GEN_EQ, 'generation': 5})
472457
except ex.AerospikeError as e:
473458
print("Error: {0} [{1}]".format(e.msg, e.code))
474459

@@ -484,11 +469,9 @@ Record Commands
484469
Remove a list of bins from a record with a given *key*. Equivalent to \
485470
setting those bins to :meth:`aerospike.null` with a :meth:`~aerospike.Client.put`.
486471

487-
.. include:: ./deprecate_meta_ttl.rst
488-
489472
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
490473
:param list list: the bins names to be removed from the record.
491-
:param dict meta: record metadata to be set. See :ref:`metadata_dict`.
474+
:param dict meta: record generation to compare. See :ref:`metadata_dict`.
492475
:param dict policy: optional :ref:`aerospike_write_policies`.
493476

494477
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
@@ -817,12 +800,10 @@ String Operations
817800

818801
Append a string to the string value in bin.
819802

820-
.. include:: ./deprecate_meta_ttl.rst
821-
822803
:param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record.
823804
:param str bin: the name of the bin.
824805
:param str val: the string to append to the bin value.
825-
:param dict meta: record metadata to be set. See :ref:`metadata_dict`.
806+
:param dict meta: record generation to compare. See :ref:`metadata_dict`.
826807
:param dict policy: optional :ref:`aerospike_operate_policies`.
827808

828809
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
@@ -844,12 +825,10 @@ String Operations
844825

845826
Prepend the string value in *bin* with the string *val*.
846827

847-
.. include:: ./deprecate_meta_ttl.rst
848-
849828
:param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record.
850829
:param str bin: the name of the bin.
851830
:param str val: the string to prepend to the bin value.
852-
:param dict meta: record metadata to be set. See :ref:`metadata_dict`.
831+
:param dict meta: record generation to compare. See :ref:`metadata_dict`.
853832
:param dict policy: optional :ref:`aerospike_operate_policies`.
854833

855834
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
@@ -880,13 +859,11 @@ Numeric Operations
880859

881860
Increment the integer value in *bin* by the integer *val*.
882861

883-
.. include:: ./deprecate_meta_ttl.rst
884-
885862
:param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record.
886863
:param str bin: the name of the bin.
887864
:param int offset: the value by which to increment the value in *bin*.
888865
:type offset: :py:class:`int` or :py:class:`float`
889-
:param dict meta: record metadata to be set. See :ref:`metadata_dict`.
866+
:param dict meta: record generation to compare. See :ref:`metadata_dict`.
890867
:param dict policy: optional :ref:`aerospike_operate_policies`. Note: the ``exists`` policy option may not be: :py:data:`aerospike.POLICY_EXISTS_CREATE_OR_REPLACE` nor :py:data:`aerospike.POLICY_EXISTS_REPLACE`
891868
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
892869

@@ -1519,24 +1496,6 @@ Index Operations
15191496

15201497
client.index_geo2dsphere_create('test', 'pads', 'loc', 'pads_loc_geo')
15211498

1522-
.. method:: index_cdt_create(ns: str, set: str, bin: str, index_type, index_datatype, index_name: str, ctx: list[, policy: dict])
1523-
1524-
.. deprecated:: 19.1.0 Use the other non-deprecated index methods to create an index with a list of contexts.
1525-
1526-
Create an collection data type (CDT) index named *index_name* for a scalar, list values, map keys, or map values (as defined by *index_type*) and for
1527-
numeric, string, or GeoJSON values (as defined by *index_datatype*)
1528-
on records of the specified *ns*, *set* whose bin is a list or map.
1529-
1530-
:param str ns: the namespace in the aerospike cluster.
1531-
:param str set: the set name.
1532-
:param str bin: the name of bin the secondary index is built on.
1533-
:param index_type: whether we are querying a single scalar value or specific values of a CDT type. See :ref:`aerospike_index_types`.
1534-
:param index_datatype: the type of value being queried on. See :ref:`aerospike_index_datatypes`.
1535-
:param str index_name: the name of the index.
1536-
:param dict ctx: a :class:`list` of contexts produced by :mod:`aerospike_helpers.cdt_ctx` methods.
1537-
:param dict policy: optional :ref:`aerospike_info_policies`.
1538-
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
1539-
15401499
.. index::
15411500
single: Admin Operations
15421501

@@ -2032,8 +1991,9 @@ Metadata Dictionary
20321991

20331992
The metadata dictionary has the following key-value pairs:
20341993

2035-
* ``"ttl"`` (:class:`int`): record time to live in seconds. See :ref:`TTL_CONSTANTS` for possible special values.
2036-
* ``"gen"`` (:class:`int`): record generation
1994+
* ``"ttl"`` (:class:`int`): record time to live in seconds. This field is read only.
1995+
* ``"gen"`` (:class:`int`): record generation. If passing as input, this is the expected record generation.
1996+
If returned as an output, this is the current record generation.
20371997

20381998
.. _aerospike_policies:
20391999

doc/deprecate_meta_ttl.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/include/client.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ PyObject *AerospikeClient_Remove(AerospikeClient *self, PyObject *args,
157157
PyObject *kwds);
158158

159159
PyObject *AerospikeClient_Remove_Invoke(AerospikeClient *self, PyObject *py_key,
160-
PyObject *py_meta, PyObject *py_policy);
160+
PyObject *py_policy);
161161

162162
/**
163163
* Remove bin from the database.
@@ -374,15 +374,6 @@ PyObject *AerospikeClient_Index_Blob_Create(AerospikeClient *self,
374374
PyObject *AerospikeClient_Index_Expr_Create(AerospikeClient *self,
375375
PyObject *args, PyObject *kwds);
376376

377-
/**
378-
* Create secondary cdt index
379-
*
380-
* client.index_cdt_create(namespace, set, bin, index_type, index_datatype, index_name, ctx, policy)
381-
*
382-
*/
383-
PyObject *AerospikeClient_Index_Cdt_Create(AerospikeClient *self,
384-
PyObject *args, PyObject *kwds);
385-
386377
/**
387378
* Create secondary geospatial index
388379
*

src/include/conversions.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,10 @@ void initialize_bin_for_strictypes(AerospikeClient *self, as_error *err,
155155
PyObject *py_value, as_binop *binop,
156156
char *bin, as_dynamic_pool *dynamic_pool);
157157

158-
// Both as_operations and as_record have ttl and gen fields,
159-
// so we have ttl and gen as separate parameters instead of accepting either as_operations or as_record
160-
as_status check_and_set_meta(PyObject *py_meta, uint32_t *ttl_ref,
161-
uint16_t *gen_ref, as_error *err,
162-
bool validate_keys);
158+
// Both as_operations and as_record have gen fields,
159+
// so we have gen as a separate parameter instead of accepting either as_operations or as_record
160+
as_status check_and_set_meta(PyObject *py_meta, uint16_t *gen_ref,
161+
as_error *err, bool validate_keys);
163162

164163
as_status string_and_pyuni_from_pystring(PyObject *py_string,
165164
PyObject **pyuni_r, char **c_str_ptr,

src/main/aerospike.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ DEFINE_SET_OF_VALID_KEYS(hll_policy, "flags", NULL)
951951

952952
DEFINE_SET_OF_VALID_KEYS(admin_policy, "timeout", NULL)
953953

954-
DEFINE_SET_OF_VALID_KEYS(record_metadata, "gen", "ttl", NULL)
954+
DEFINE_SET_OF_VALID_KEYS(record_metadata, "gen", NULL)
955955

956956
// Use a struct to create pairs of pyobjects and list of strings defined above
957957
// When we initialize the module, we create sets for the valid keys that the client can use later

src/main/client/batch_write.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,10 @@ static PyObject *AerospikeClient_BatchWriteInvoke(AerospikeClient *self,
297297

298298
ops = as_operations_new(py_ops_size);
299299
garb->ops_to_free = ops;
300+
// as_operations_new defaults ttl to 0 (namespace default). Use the batch write policy ttl instead.
301+
ops->ttl = AS_RECORD_CLIENT_DEFAULT_TTL;
300302

301-
if (check_and_set_meta(py_meta, &ops->ttl, &ops->gen, err,
303+
if (check_and_set_meta(py_meta, &ops->gen, err,
302304
self->validate_keys) != AEROSPIKE_OK) {
303305
goto CLEANUP_ON_ERROR;
304306
}

src/main/client/cdt_operation_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ as_status get_enum_from_py_dict(
261261
bool *int_was_found)
262262
{
263263
return get_bound_int_from_py_dict(err, py_dict, key, int_pointer, min_bound,
264-
max_bound, is_optional, true, int_was_found);
264+
max_bound, is_optional, false, int_was_found);
265265
}
266266

267267
as_status get_int_from_py_dict(as_error *err, PyObject *py_dict, const char *key, int *int_pointer, bool is_optional, bool *int_was_found)

src/main/client/index.c

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -487,75 +487,3 @@ PyObject *AerospikeClient_Index_2dsphere_Create(AerospikeClient *self,
487487
return AerospikeClient_Index_Create_Deprecated_Helper(
488488
self, args, kwds, "index_geo2dsphere_create", AS_INDEX_GEO2DSPHERE);
489489
}
490-
491-
PyObject *AerospikeClient_Index_Cdt_Create(AerospikeClient *self,
492-
PyObject *args, PyObject *kwds)
493-
{
494-
int retval =
495-
PyErr_WarnEx(PyExc_DeprecationWarning,
496-
"index_cdt_create() is deprecated. Please use one of the "
497-
"other non-deprecated index_*_create() methods instead",
498-
STACK_LEVEL);
499-
if (retval == -1) {
500-
return NULL;
501-
}
502-
503-
// Initialize error
504-
as_error err;
505-
as_error_init(&err);
506-
507-
// Python Function Arguments
508-
PyObject *py_policy = NULL;
509-
PyObject *py_ns = NULL;
510-
PyObject *py_set = NULL;
511-
PyObject *py_bin = NULL;
512-
PyObject *py_indextype = NULL;
513-
PyObject *py_datatype = NULL;
514-
PyObject *py_name = NULL;
515-
516-
PyObject *py_ctx = NULL;
517-
518-
as_index_datatype data_type;
519-
as_index_type index_type;
520-
521-
// Python Function Keyword Arguments
522-
static char *kwlist[] = {
523-
"ns", "set", "bin", "index_type", "index_datatype",
524-
"name", "ctx", "policy", NULL};
525-
526-
// Python Function Argument Parsing
527-
if (PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOOO|O:index_list_create",
528-
kwlist, &py_ns, &py_set, &py_bin,
529-
&py_indextype, &py_datatype, &py_name,
530-
&py_ctx, &py_policy) == false) {
531-
return NULL;
532-
}
533-
534-
if (get_int_from_py_int(&err, py_indextype, (int *)&index_type,
535-
"index_type") != AEROSPIKE_OK) {
536-
goto CLEANUP_ON_ERROR;
537-
}
538-
539-
if (get_int_from_py_int(&err, py_datatype, (int *)&data_type,
540-
"index_datatype") != AEROSPIKE_OK) {
541-
goto CLEANUP_ON_ERROR;
542-
}
543-
544-
// convert_python_args_to_c_and_create_index, which is called by the new index create method API's,
545-
// accepts an optional value of None for ctx
546-
// This API call is the only exception where a list of ctx's is required
547-
if (Py_IsNone(py_ctx)) {
548-
as_error_update(&err, AEROSPIKE_ERR_PARAM, "ctx cannot be None");
549-
goto CLEANUP_ON_ERROR;
550-
}
551-
552-
// Even if this call fails, it will raise its own exception
553-
// and the err object here will not be set. We don't raise an exception twice
554-
return convert_python_args_to_c_and_create_index(
555-
self, py_policy, py_ns, py_set, py_bin, py_name, index_type, data_type,
556-
py_ctx, NULL);
557-
558-
CLEANUP_ON_ERROR:
559-
raise_exception_base(&err, Py_None, Py_None, Py_None, Py_None, py_name);
560-
return NULL;
561-
}

0 commit comments

Comments
 (0)