Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aerospike-core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ impl Client {
}

let task_id: u64 = rand::random();
let scan = statement.filters.is_none();
let scan = statement.filter().is_none();

let mut last_err: Option<Error> = None;
for node in &nodes {
Expand Down Expand Up @@ -2034,7 +2034,7 @@ impl Client {
}

let task_id: u64 = rand::random();
let scan = statement.filters.is_none();
let scan = statement.filter().is_none();

let mut last_err: Option<Error> = None;
for node in &nodes {
Expand Down
2 changes: 1 addition & 1 deletion aerospike-core/src/commands/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ impl Buffer {
node_partitions: Option<&NodePartitions>,
execute_where: Option<&[u8]>,
) -> Result<()> {
let filter = statement.filters.as_ref().map(|filters| &filters[0]);
let filter = statement.filter();
let is_background = direction.is_background();
let supports_ops_ext = node.version().supports_query_ops_projection_ext();
let records_per_second = direction.records_per_second();
Expand Down
2 changes: 1 addition & 1 deletion aerospike-core/src/commands/query_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Command for QueryCommand<'_> {

fn command_type(&self) -> crate::metrics::CommandType {
// A statement with secondary-index filters is a query; otherwise a scan.
if self.statement.filters.is_some() {
if self.statement.filter().is_some() {
crate::metrics::CommandType::Query
} else {
crate::metrics::CommandType::Scan
Expand Down
6 changes: 6 additions & 0 deletions aerospike-core/src/query/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ impl Statement {
}
}

/// The secondary-index filter this statement queries by, or `None` for a
/// scan. An empty `filters` list is a scan, the same as `None`.
pub(crate) fn filter(&self) -> Option<&Filter> {
self.filters.as_ref().and_then(|filters| filters.first())
}

/// Set Lua aggregation function parameters.
pub fn set_aggregate_function(
&mut self,
Expand Down
26 changes: 26 additions & 0 deletions tests/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ async fn query_single_consumer() {
client.close().await.unwrap();
}

#[aerospike_macro::test]
async fn query_empty_filter_list_scans() {
let client = common::client().await;
let namespace = common::namespace();
let set_name = create_test_set(&client, 20).await;
let qpolicy = QueryPolicy::default();

let mut statement = Statement::new(namespace, &set_name, Bins::All);
statement.filters = Some(vec![]);
let rs = client
.query(&qpolicy, PartitionFilter::all(), statement)
.await
.unwrap();
let mut count = 0;
let mut rs = rs.into_stream();
while let Some(res) = rs.next().await {
match res {
Ok(_) => count += 1,
Err(err) => panic!("{:?}", err),
}
}
assert_eq!(count, 20);

client.close().await.unwrap();
}

#[aerospike_macro::test]
async fn query_single_consumer_with_cursor() {
let client = common::client().await;
Expand Down
Loading