I am using go client to create or replace 100 records at a time. In batch mode,
I could not find an operation
that accepts a BinMap and replaces the whole record with that BinMap. I could find only the PutOp
operation that writes a single bin.
I could programmatically build a series of PutOp operations (for each bin one operation) and then invoke the NewBatchWrite
, however that does not solve the requirement of “replace” the whole record. I mean, if there is already a record for this key, with some bins (which I am not updating in my batch PutOp), the result is not a complete replace of this record. ie. the record is going to have the old bins + the bins I write newly.
It would be great if we have a PutBins that accept a BinMap and replaces the whole record with this BInMap. Or is there any other way to achieve this ?
Below is the code that deals with single bin per operation.
for i := 0; i < len(recs); i++ {
ops := make([]*aerospike.Operation, len(recs[i].bins))
for binNum, bin := range recs[i].bins {
ops[binNum] = aerospike.PutOp(bin)
}
aeroBatch = append(aeroBatch, aerospike.NewBatchWrite(nil, recs[i].key, ops...))
}
err := cli.BatchOperate(nil, aeroBatch)
...