Skip to content

Primary index

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

The Aerospike Rust client provides the ability to query all records in a specified namespace and set.

Querying records

This example counts the number of records in the query result:

use aerospike::{Bins, Client, ClientPolicy, Error, QueryPolicy, Statement};
use aerospike::query::PartitionFilter;
use futures::stream::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Error> {
let hosts = std::env::var("AEROSPIKE_HOSTS")
.unwrap_or_else(|_| "localhost:3000".to_string());
let client = Client::new(&ClientPolicy::default(), &hosts).await?;
let policy = QueryPolicy::default();
let stmt = Statement::new("test", "demo", Bins::None);
let rs = client.query(&policy, PartitionFilter::all(), stmt).await?;
let mut stream = rs.into_stream();
let mut count: usize = 0;
while let Some(result) = stream.next().await {
match result {
Ok(_record) => count += 1,
Err(err) => println!("Error during scan: {}", err),
}
}
println!("Records: {}", count);
client.close().await?;
Ok(())
}

📖 API reference: Client::new | Client::scan

📖 API reference: Client::new() | Client::query() | Statement::new() | PartitionFilter::all() | Recordset::into_stream()

The query executes asynchronously. If an error occurs while executing the query, parallel query tasks to other nodes are terminated and the error propagates back through the record stream.

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?