Multiple ops on same bin of a record


Is there a way to submit multiple operations on the same bin of a record and return two different values?

For e.g., let us say I have a set academics with a Map field students that stores score => studentId mapping.

{score: studentId}

Let us say, I want to query for the size of this map as well as the studentId with the topmost score, I’d do this the following way in Python:

import aerospike
from aerospike_helpers.operations import map_operations as mapops
from aerospike_helpers.operations import operations as op_helpers

# Configure the client
config = {
 'hosts': [ ('', 3000) ]

# Create a client and connect it to the cluster
  client = aerospike.client(config).connect()
  import sys
  print("failed to connect to the cluster with", config['hosts'])

key = ('ns', 'academics', 'physics')
ops = []
op = mapops.map_size("students")

op = mapops.get_by_rank("students", -1, aerospike.MAP_RETURN_VALUE)

_, _, bins = client.operate(key, ops)

Unfortunately the output of the 2nd op overwrites the output of the 1st op. Is there a way to achieve this?


Per the API documentation for operate() states that “the returned record tuple will only contain one element per bin, even if multiple operations were performed on the bin”. Please try operate_ordered() to get multiple values for a bin.

© 2021 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.