batch count
This commit is contained in:
@@ -1244,6 +1244,34 @@ impl GrpcClient {
|
||||
self.search_client.get_filtered_row(request).await
|
||||
}
|
||||
|
||||
pub async fn count_table_rows_batch(
|
||||
&mut self,
|
||||
profile_name: String,
|
||||
rows: Vec<(String, String, String)>,
|
||||
) -> Vec<std::result::Result<u64, String>> {
|
||||
let mut counts = Vec::with_capacity(rows.len());
|
||||
for chunk in rows.chunks(64) {
|
||||
let result = async {
|
||||
let request = self.authenticated_request(common::proto::komp_ac::search::BatchCountRequest {
|
||||
requests: chunk.iter().map(|(table, column, value)| SearchRequest {
|
||||
profile_name: profile_name.clone(),
|
||||
table_name: Some(table.clone()),
|
||||
must: vec![ColumnConstraint {
|
||||
column: column.clone(), query: value.clone(), mode: MatchMode::Exact as i32,
|
||||
}],
|
||||
..Default::default()
|
||||
}).collect(),
|
||||
})?;
|
||||
self.search_client.batch_count(request).await
|
||||
}.await;
|
||||
match result {
|
||||
Ok(results) => counts.extend(results),
|
||||
Err(error) => counts.extend((0..chunk.len()).map(|_| Err(error.to_string()))),
|
||||
}
|
||||
}
|
||||
counts
|
||||
}
|
||||
|
||||
pub async fn count_table_rows(
|
||||
&mut self,
|
||||
profile_name: String,
|
||||
|
||||
Reference in New Issue
Block a user