How to get top 1000 records at a time?


#1

by $0ftw@reE&g&eer » Thu May 08, 2014 10:37 am

Hi,

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.

Thanks in advance.


#2

You should be able to use the scanPercent attribute of the ScanPolicy class to set the percentage to scan.


#3

Is there a way to state the number of records instead of using the percentage to scan?

Thanks


#4

Hi joe99,

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.

I hope this helps.

Best, Dash


#5

Hi Dash,

Thanks for the response. I’ll look into using the scan percentage for our application.

Regards