Function getByValueRelRankRange

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

    Parameters

    • bin: string

      The name of the bin. The bin must contain a List value.

    • value: number

      Find list items nearest to this value and greater.

    • rank: number

      Rank of the 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: lists.returnType

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

    Returns InvertibleListOp

    List operation that can be used with the Client#operate command.

    This operation returns the data specified by returnType.

    Examples for ordered list [0, 4, 5, 9, 11, 15]:

    • (value, rank, count) = [selected items]
    • (5, 0, 2) = [5, 9]
    • (5, 1, 1) = [9]
    • (5, -1, 2) = [4, 5]
    • (3, 0, 1) = [4]
    • (3, 3, 7) = [11, 15]
    • (3, -3, 2) = []

    Without count:

    • (value, rank) = [selected items]
    • (5, 0) = [5, 9, 11, 15]
    • (5, 1) = [9, 11, 15]
    • (5, -1) = [4, 5, 9, 11, 15]
    • (3, 0) = [4, 5, 9, 11, 15]
    • (3, 3) = [11, 15]
    • (3, -3) = [0, 4, 5, 9, 11, 15]

    Requires Aerospike Server v4.3.0 or later.

    v3.5.0

    const Aerospike = require('aerospike')
    const lists = Aerospike.lists
    const key = new Aerospike.Key('test', 'demo', 'listKey')
    // 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, { list: [0, 4, 5, 9, 11, 15] })
    await client.operate(key, [ lists.setOrder('list', lists.order.ORDERED) ])
    let result = await client.operate(key, [
    lists.getByValueRelRankRange('list', 5, -1, 2)
    .andReturn(lists.returnType.VALUE)])
    console.log(result.bins.list) // => [ 4, 5 ]
    client.close()
    })
MMNEPVFCICPMFPCPTTAAATR