How can I get more than 5000 keys in one batch call?

KazuhideKin wrote on Wed Apr 02, 2014 11:53 pm Hi,

How can I get more than 5000 keys in one batch call? An exception occured while trying to get more than 5000 keys.

Exception in thread “main” com.aerospike.client.AerospikeException: Error Code 4: Parameter error at com.aerospike.client.command.BatchCommandGet.parseRecordResults(BatchCommandGet.java:89) at com.aerospike.client.command.MultiCommand.parseResult(MultiCommand.java:63) at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:61) at com.aerospike.client.command.BatchExecutor$BatchThread.run(BatchExecutor.java:152) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722)

Here is my sample code:

int size = 5001;

AerospikeClient cc = new AerospikeClient("localhost", 3000);

WritePolicy wp = new WritePolicy();
wp.expiration = 0;
Key[] keys = new Key[size];
for( int i = 0; i < size; i++){
  String skey = String.format("mykey%06d", i);
  keys[i] = new Key("test","myset",skey );
  Bin bin = new Bin("mybin","value");
  cc.put( wp, keys[i], bin);
}

Policy pc = new Policy();
Record[] rc = cc.get( pc, keys);

This is something configured in the server configuration file (/etc/aerospike/aerospike.conf). It defaults to 5,000. What you will need to do is put a variable in the “service” stanza called “batch-max-requests” to a higher value like 10,000 like this:

Select allservice {
    ...
    batch-max-requests 10000
}