batch count

This commit is contained in:
Priec
2026-09-05 09:16:27 +02:00
parent 52cfbd7070
commit b4fdf706ef
8 changed files with 208 additions and 2 deletions

View File

@@ -12,6 +12,8 @@ service Searcher {
// Returns live authorized row data and one-based filtered navigation bounds.
// A missing position returns NOT_FOUND. Search and row reads are not a snapshot.
rpc GetFilteredRow(SearchRequest) returns (komp_ac.tables_data.GetTableDataResponse);
// Up to 64 independent counts. Results preserve request order; errors are per item.
rpc BatchCount(BatchCountRequest) returns (BatchCountResponse);
rpc Count(SearchRequest) returns (SearchCountResponse);
}
@@ -127,3 +129,18 @@ message SearchResponse {
}
repeated Hit hits = 1;
}
message BatchCountRequest {
repeated SearchRequest requests = 1;
}
message BatchCountResult {
oneof outcome {
uint64 count = 1;
string error = 2;
}
}
message BatchCountResponse {
repeated BatchCountResult results = 1;
}

Binary file not shown.

View File

@@ -150,6 +150,35 @@ pub mod search_response {
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCountRequest {
#[prost(message, repeated, tag = "1")]
pub requests: ::prost::alloc::vec::Vec<SearchRequest>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BatchCountResult {
#[prost(oneof = "batch_count_result::Outcome", tags = "1, 2")]
pub outcome: ::core::option::Option<batch_count_result::Outcome>,
}
/// Nested message and enum types in `BatchCountResult`.
pub mod batch_count_result {
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Outcome {
#[prost(uint64, tag = "1")]
Count(u64),
#[prost(string, tag = "2")]
Error(::prost::alloc::string::String),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BatchCountResponse {
#[prost(message, repeated, tag = "1")]
pub results: ::prost::alloc::vec::Vec<BatchCountResult>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum MatchMode {
@@ -379,6 +408,31 @@ pub mod searcher_client {
.insert(GrpcMethod::new("komp_ac.search.Searcher", "GetFilteredRow"));
self.inner.unary(req, path, codec).await
}
/// Up to 64 independent counts. Results preserve request order; errors are per item.
pub async fn batch_count(
&mut self,
request: impl tonic::IntoRequest<super::BatchCountRequest>,
) -> std::result::Result<
tonic::Response<super::BatchCountResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/komp_ac.search.Searcher/BatchCount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("komp_ac.search.Searcher", "BatchCount"));
self.inner.unary(req, path, codec).await
}
pub async fn count(
&mut self,
request: impl tonic::IntoRequest<super::SearchRequest>,
@@ -433,6 +487,14 @@ pub mod searcher_server {
tonic::Response<super::super::tables_data::GetTableDataResponse>,
tonic::Status,
>;
/// Up to 64 independent counts. Results preserve request order; errors are per item.
async fn batch_count(
&self,
request: tonic::Request<super::BatchCountRequest>,
) -> std::result::Result<
tonic::Response<super::BatchCountResponse>,
tonic::Status,
>;
async fn count(
&self,
request: tonic::Request<super::SearchRequest>,
@@ -603,6 +665,51 @@ pub mod searcher_server {
};
Box::pin(fut)
}
"/komp_ac.search.Searcher/BatchCount" => {
#[allow(non_camel_case_types)]
struct BatchCountSvc<T: Searcher>(pub Arc<T>);
impl<
T: Searcher,
> tonic::server::UnaryService<super::BatchCountRequest>
for BatchCountSvc<T> {
type Response = super::BatchCountResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::BatchCountRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Searcher>::batch_count(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = BatchCountSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/komp_ac.search.Searcher/Count" => {
#[allow(non_camel_case_types)]
struct CountSvc<T: Searcher>(pub Arc<T>);