Skip to content
Visit booth 3171 at Google Cloud Next to see how to unlock real-time decisions at scaleMore info

Background queries

Use the Aerospike C client scan APIs to initialize and populate an as_scan object, and then use the following calls to execute a scan:

  • aerospike_scan_foreach() — Execute the scan and call a function for each record.
  • aerospike_scan_background() — Execute the scan without results, which provides the ability to check the scan status.

Checking Background Scan Status

Use aerospike_scan_background() to send a scan to the database to execute without the client waiting on results. The client is given a scan ID, used to check the status of the scan running in the database.

Use the scan ID to periodically check the scan status. Ideally, the application uses this information to determine how frequent to poll for status.

The information about a scan is populated into an instance of as_scan_info:

as_scan_info scan_info;
if (aerospike_scan_info(&as, &err, NULL, scan_id, &scan_info) != AEROSPIKE_OK) {
fprintf(stderr, "err(%d) %s at [%s:%d]\n", err.code, err.message, err.file, err.line);
}

This simple status check assumes that the check only occurs once.

Applications that track elapsed time between scans can estimate how long a scan will take after polling for status by inspecting the progress_pct field of as_scan_info.

Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?