Limit the number of entries in an aerospace selection request

I am trying to execute a query using aql (aerospace query language) in an aerospace set .
Suppose there are 1000 entries and I want to read 10 entries. Normally I would query for something like:

select * from test.demo limit 10; 

How do I execute a query using aql ?

+7
database aerospike
source share
2 answers

You cannot do this in aql at the moment, but you can use the BETWEEN predicate to determine the range for the query.

When you use the C client (or one of the language clients that wrap it), the scan ( as_scan_foreach ) can be limited by the percentage field in as_scan struct.

+4
source share

Here is an example of a "scan" in Java.

  **this.client.scanAll(scanPolicy, "test", "demo", new ScanCallback() { @Override public void scanCallback(Key key, Record record) throws AerospikeException { System.out.println("Record: " + record); } });** 

In that there is no order in scanning, the records are returned to your application in the order in which they are received from the nodes in the cluster.

+1
source share

All Articles