I am trying to process certain number of records in batch, not getting them all at a time.
I know AerospikeClient.ScanAll() will read all of them until an exception is thrown, and there is an alternative to count the read and throw an exception when it is done.
But would there be any other better way to read certain amount of rows instead of throw an exception? I am assuming not providing a list of primary keys but just fetching some rows.
Unfortunately, as of today, there isn’t a way to limit the number of records using the Scan API. Till we have such a feature implemented (no ETA), what you mentioned in your initial post might be the way to go. For example:
public void ScanCallback(Key key, Record record)
{
recordCount++;
if (recordCount == 1000)
{
//do something here...
}
}
Where recordCount is a variable defined in your application.