Skip to content

BatchGetComplex doesn't work with ReadAllBins set to true #466

@yizha

Description

@yizha

Aerospike server version: 7.2.0.6_1
Aerospike client (golang) version: v7.8.0

Below code fails with ResultCode: PARAMETER_ERROR, Iteration: 0, InDoubt: false, Node: BB9060012AC4202 [::1]:3000: No operations were passed. when it calls BatchGetComplex(...).

package main

import (
	"fmt"
	"net"
	"strconv"

	"github.com/aerospike/aerospike-client-go/v7"
)

func p(err any) {
	if err != nil {
		panic(err)
	}
}

func createAerospikeClient(addr string) *aerospike.Client {
	host, portStr, err := net.SplitHostPort(addr)
	p(err)
	port, err := strconv.Atoi(portStr)
	p(err)
	client, err := aerospike.NewClient(host, port)
	p(err)
	return client
}

func main() {
	client := createAerospikeClient("localhost:3000")

	key, err := aerospike.NewKey("namespace", "set", "key")
	p(err)

	rec, err := client.Get(nil, key)
	p(err)
	fmt.Printf("Get() record: %+v\n", rec)

	read := aerospike.NewBatchRead(nil, key, nil)
	read.ReadAllBins = true
	// read := aerospike.NewBatchReadOps(nil, key, aerospike.GetOp())

	reads := []*aerospike.BatchRead{read}

	policy := aerospike.NewBatchPolicy()
	p(client.BatchGetComplex(policy, reads))
	fmt.Printf("BatchGetComplex() record: %+v\n", read.Record)
}

But if we replace

	read := aerospike.NewBatchRead(nil, key, nil)
	read.ReadAllBins = true

with

	read := aerospike.NewBatchReadOps(nil, key, aerospike.GetOp())

then BatchGetComplex(...) works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions