Function getByValueRelRankRange

  • Retrieves map items nearest to value and greater, by relative rank.

    Parameters

    • bin: string

      The name of the bin, which must contain a Map value.

    • value: number

      Find map items nearest to this value and greater.

    • rank: number

      Rank of items to be retrieved relative to the given value.

    • Optionalcount: number

      Number of items to retrieve. If undefined, the range includes all items nearest to value and greater, until the end.

    • OptionalreturnType: maps.returnType

      The return type indicating what data of the selected item(s) to return.

    Returns MapOperation

    Operation that can be passed to the Client#operate command.

    This operation returns the selected data specified by returnType.

    Examples for map { e: 2, j: 10, f: 15, a: 17 }:

    • (value, rank, count) = [selected items]
    • (11, 1, 1) = { a: 17 }
    • (11, -1, 1) = { j: 10 }

    Without count:

    • (value, rank) = [selected items]
    • (11, 1) = { a: 17 }
    • (11, -1) = { j: 10, f: 15, a: 17 }

    Instead of passing returnType, you can also use ~MapOperation#andReturn|MapOperation#andReturn to select what data to return.

    v3.5.0

    const Aerospike = require('aerospike')
    const maps = Aerospike.maps
    const key = new Aerospike.Key('test', 'demo', 'mapKey')
    // INSERT HOSTNAME AND PORT NUMBER OF AEROSPIKE SERVER NODE HERE!
    var config = {
    hosts: '192.168.33.10:3000',
    // Timeouts disabled, latency dependent on server location. Configure as needed.
    policies: {
    write : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout : 0}),
    operate : new Aerospike.OperatePolicy({socketTimeout : 0, totalTimeout : 0})

    }
    }
    Aerospike.connect(config)
    .then(async client => {
    await client.put(key, { map: { e: 2, j: 10, f: 15, a: 17 } })
    let result = await client.operate(key, [
    maps.getByValueRelRankRange('map', 11, 1, 1)
    .andReturn(maps.returnType.KEY_VALUE)])
    console.info(result.bins.map) // => [ 'a', 17 ]
    client.close()
    })
MMNEPVFCICPMFPCPTTAAATR