Skip to content

11.0.0

Compare
Choose a tag to compare
@juliannguyen4 juliannguyen4 released this 29 Mar 15:39
· 313 commits to stage since this release
9272ceb

Breaking Changes

Batch methods: stop accepting a tuple of keys and bins

For the following functions:

  • client.get_many()
  • client.exists_many()

The keys parameter no longer takes in a tuple of keys. It only takes in a list of keys.

In addition, client.select_many() no longer takes in a tuple for the keys and bins parameters. Those parameters only take in a list of keys and bins, respectively.

Course of action:

Change code such as this:

keys = (("test", "demo", 1), ("test", "demo", 2))
bins = ("bin1", "bin2")
client.select_many(keys, bins)

...to this instead:

keys = [("test", "demo", 1), ("test", "demo", 2)]
bins = ["bin1", "bin2"]
client.select_many(keys, bins)

Expressions: add support for comparing KeyOrderedDicts (new server feature)

Before server 6.3, it is possible to compare maps in expressions if the maps were nested inside a list. For example, this code would work before server 6.3:

from aerospike_helpers.expressions import base as expr

client.put(key, {"bin": [{"a": 1}]})
exp = expr.Eq(expr.ListBin("bin"), [{"a": 1}]).compile()
record = client.get(key, {"expressions": exp})
print(record[2])
# {'bin': [{'a': 1}]}

This is now unsupported in server 6.3 because comparing unordered maps can potentially lead to inconsistent results. However, it is possible in server 6.3 to compare key-ordered maps in expressions.

Course of action:

For those using a server version < 6.3, no action is necessary. But it is recommended not to compare unordered maps in expressions.

For those upgrading to server 6.3, maps stored in the server must be key-ordered in order to be compared against in expressions. If the maps in the server are already key-ordered, and you would like to compare them in expressions, you must wrap any dictionaries in expressions with the KeyOrderedDict class.

For example, the code above must store the map as a key ordered map before comparing it in an expression:

from aerospike_helpers.expressions import base as expr
from aerospike import KeyOrderedDict

client.put(key, {"bin": [KeyOrderedDict({"a": 1})]})
exp = expr.Eq(expr.ListBin("bin"), [KeyOrderedDict({"a": 1})]).compile()
record = client.get(key, {"expressions": exp})
print(record[2])
# {'bin': [{'a': 1}]}

Return AEROSPIKE_ERR_NAMESPACE_NOT_FOUND instead of AEROSPIKE_ERR_CLIENT when a namespace cannot be found

Course of action:

Change code such as this:

from aerospike import exception as exc
key = ("nonexistent_namespace", "demo", 1)
try:
    client.get(key)
except exc.ClientError:
    print("Incorrect namespace")

...to this instead:

from aerospike import exception as exc
key = ("nonexistent_namespace", "demo", 1)
try:
    client.get(key)
except exc.NamespaceNotFound:
    print("Incorrect namespace")

Return last error code received when scan/query maxRetries is exceeded

When running a query or scan, if max_retries is exceeded, the transaction will return the last suberror that was received instead of a MaxRetriesExceeded error. For example, if you try to run a query on a non-indexed bin, the client will return an IndexNotFound error from the last attempt to query the bin.

This code will no longer work:

query = client.query("test", "demo")
query.select("bin_without_index")
query.where(p.equals("bin_without_index", 1))
def callback(input_tuple):
    pass

try:
    query.foreach(callback)
except exc.MaxRetriesExceeded:
    print("Query failed")

Course of action:

When handling a MaxRetriesExceeded exception, change it to the exact error that is expected to get thrown during the last query attempt. In this case, it is an IndexNotFound error:

try:
    query.foreach(callback)
except exc.IndexNotFound:
    print("Query failed")

New Features

  • [CLIENT-2176] Map operations: add support for MAP_ORDERED and MAP_UNORDERED return types.
  • [CLIENT-2144] Expressions: add support for comparing KeyOrderedDicts.
  • [CLIENT-2158] Add base64 API functions to aerospike module.

Improvements

  • [CLIENT-701] Batch methods: stop accepting a tuple of keys and bins.
  • [CLIENT-2197] Return AEROSPIKE_ERR_NAMESPACE_NOT_FOUND instead of AEROSPIKE_ERR_CLIENT when a namespace cannot be found.
  • [CLIENT-2143] Return last error code received when scan/query maxRetries is exceeded.
  • [CLIENT-2192] Add support for RHEL 9.

Bug Fixes

  • [CLIENT-1749] Documentation: add missing map return type MAP_RETURN_EXISTS.