mirror of
https://github.com/qdrant/qdrant.git
synced 2026-09-28 00:47:32 -05:00
Replace the mixed read interface (internal types, explicit parameter enumeration, ad-hoc custom types) with edge-owned request structs, one file per request in src/requests/. Each has a new() constructor taking only the required parameters, a no-macro fluent builder in src/builders/, and a From conversion into the internal request type in requests/conversions/, grouped by request type. Conversions construct and destructure with full field lists, so a parameter added on either side fails compilation instead of being silently dropped. The old reexport aliases (ScrollRequest = ScrollRequestInternal, etc.) are replaced by the edge types under the same names; retrieve() takes a RetrieveRequest instead of a parameter triple. Python bindings wrap the edge types, and the published Rust examples use the builders. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
94 lines
2.3 KiB
Rust
94 lines
2.3 KiB
Rust
use bytemuck::TransparentWrapper as _;
|
|
use derive_more::Into;
|
|
use edge::ScrollRequest;
|
|
use pyo3::prelude::*;
|
|
use segment::data_types::order_by::OrderByInterface;
|
|
use segment::types::*;
|
|
|
|
use crate::query::PyOrderBy;
|
|
use crate::repr::*;
|
|
use crate::types::*;
|
|
|
|
#[pyclass(name = "ScrollRequest", from_py_object)]
|
|
#[derive(Clone, Debug, Into)]
|
|
pub struct PyScrollRequest(ScrollRequest);
|
|
|
|
#[pyclass_repr]
|
|
#[pymethods]
|
|
impl PyScrollRequest {
|
|
#[new]
|
|
#[pyo3(signature = (
|
|
offset = None,
|
|
limit = None,
|
|
filter = None,
|
|
with_payload = None,
|
|
with_vector = None,
|
|
order_by = None,
|
|
))]
|
|
pub fn new(
|
|
offset: Option<PyPointId>,
|
|
limit: Option<usize>,
|
|
filter: Option<PyFilter>,
|
|
with_payload: Option<PyWithPayload>,
|
|
with_vector: Option<PyWithVector>,
|
|
order_by: Option<PyOrderBy>,
|
|
) -> Self {
|
|
Self(ScrollRequest {
|
|
offset: offset.map(PointIdType::from),
|
|
limit,
|
|
filter: filter.map(Filter::from),
|
|
with_payload: with_payload.map(WithPayloadInterface::from),
|
|
with_vector: with_vector.map(WithVector::from).unwrap_or_default(),
|
|
order_by: order_by.map(OrderByInterface::from),
|
|
})
|
|
}
|
|
|
|
#[getter]
|
|
pub fn offset(&self) -> Option<PyPointId> {
|
|
self.0.offset.map(PyPointId)
|
|
}
|
|
|
|
#[getter]
|
|
pub fn limit(&self) -> Option<usize> {
|
|
self.0.limit
|
|
}
|
|
|
|
#[getter]
|
|
pub fn filter(&self) -> Option<&PyFilter> {
|
|
self.0.filter.as_ref().map(PyFilter::wrap_ref)
|
|
}
|
|
|
|
#[getter]
|
|
pub fn with_payload(&self) -> Option<&PyWithPayload> {
|
|
self.0.with_payload.as_ref().map(PyWithPayload::wrap_ref)
|
|
}
|
|
|
|
#[getter]
|
|
pub fn with_vector(&self) -> &PyWithVector {
|
|
PyWithVector::wrap_ref(&self.0.with_vector)
|
|
}
|
|
|
|
#[getter]
|
|
pub fn order_by(&self) -> Option<PyOrderBy> {
|
|
self.0.order_by.clone().map(PyOrderBy::from)
|
|
}
|
|
|
|
pub fn __repr__(&self) -> String {
|
|
self.repr()
|
|
}
|
|
}
|
|
|
|
impl PyScrollRequest {
|
|
fn _getters(self) {
|
|
// Every field should have a getter method
|
|
let ScrollRequest {
|
|
offset: _,
|
|
limit: _,
|
|
filter: _,
|
|
with_payload: _,
|
|
with_vector: _,
|
|
order_by: _,
|
|
} = self.0;
|
|
}
|
|
}
|