implement all point update operation constructors#7424
Conversation
4850009 to
c22974f
Compare
c22974f to
6a3523e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
lib/edge/python/src/types/point_vectors.rs (1)
9-23: New PyPointVectors wrapper — good; add Python signature for discoverability.Constructor is clean and infallible. Add an explicit Python signature for help() output.
#[pymethods] impl PyPointVectors { - #[new] + #[new] + #[pyo3(text_signature = "(id, vector)")] pub fn new(id: PyPointId, vector: PyVector) -> Self { Self(PointVectorsPersisted { id: PointIdType::from(id), vector: VectorStructPersisted::from(vector), }) } }lib/edge/python/src/update.rs (3)
34-51: Param naming consistency: use “filter” instead of “condition”.All other constructors use
filter. Rename for a consistent Python API.- pub fn upsert_points_conditional(points: Vec<PyPoint>, condition: PyFilter) -> Self { + pub fn upsert_points_conditional(points: Vec<PyPoint>, filter: PyFilter) -> Self { let points = points.into_iter().map(PointStructPersisted::from).collect(); let points_op = PointInsertOperationsInternal::PointsList(points); - let condition = Filter::from(condition); + let condition = Filter::from(filter);
133-157: Add text_signature for Python help() across constructors.Many methods expose non-obvious arg orders. Add
#[pyo3(text_signature = "...")]for parity with existing payload methods.Examples:
#[staticmethod] +#[pyo3(text_signature = "(points)")] pub fn upsert_points(points: Vec<PyPoint>) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(points, filter)")] pub fn upsert_points_conditional(points: Vec<PyPoint>, filter: PyFilter) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(ids)")] pub fn delete_points(ids: Vec<PyPointId>) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(filter)")] pub fn delete_points_by_filter(filter: PyFilter) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(point_vectors)")] pub fn update_vectors(point_vectors: Vec<PyPointVectors>) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(point_vectors, filter)")] pub fn update_vectors_conditional(point_vectors: Vec<PyPointVectors>, filter: PyFilter) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(ids, vector_names)")] pub fn delete_vectors(ids: Vec<PyPointId>, vector_names: Vec<String>) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(filter, vector_names)")] pub fn delete_vectors_by_filter(filter: PyFilter, vector_names: Vec<String>) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(ids)")] pub fn clear_payload(ids: Vec<PyPointId>) -> Self { ... } #[staticmethod] +#[pyo3(text_signature = "(filter)")] pub fn clear_payload_by_filter(filter: PyFilter) -> Self { ... }Also applies to: 159-182, 184-202, 204-221, 242-266, 268-291
143-147: Error message can include parse failure detail for JsonPath.Currently raises the key string only. Prefer the parser’s error to aid debugging.
- .map(|k| JsonPath::from_str(&k).map_err(|_| PyErr::new::<PyValueError, _>(k))) + .map(|k| JsonPath::from_str(&k) + .map_err(|e| PyErr::new::<PyValueError, _>(format!("invalid json path '{}': {}", k, e))))Also applies to: 169-172, 189-193, 209-212, 252-255, 279-281
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
lib/edge/python/src/lib.rs(1 hunks)lib/edge/python/src/types/mod.rs(1 hunks)lib/edge/python/src/types/point_vectors.rs(1 hunks)lib/edge/python/src/update.rs(1 hunks)lib/edge/python/src/update/upsert.rs(0 hunks)
💤 Files with no reviewable changes (1)
- lib/edge/python/src/update/upsert.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs
📄 CodeRabbit inference engine (.github/review-rules.md)
**/*.rs: Prefer explicit SomeType::from(x) over implicit x.into() in Rust code
Do not use transmute_from_u8, transmute_to_u8, transmute_from_u8_to_slice, transmute_from_u8_to_mut_slice, transmute_to_u8_slice in new code; use bytemuck or zerocopy instead
Files:
lib/edge/python/src/types/mod.rslib/edge/python/src/types/point_vectors.rslib/edge/python/src/lib.rslib/edge/python/src/update.rs
**/src/**/*.rs
📄 CodeRabbit inference engine (.github/review-rules.md)
**/src/**/*.rs: Prefer exhaustive match arms over a catch-all _ arm to avoid missing new enum variants (except in tests/benchmarks or when provably safe)
Prefer explicit field ignoring with : _ over .. in struct patterns (except in tests/benchmarks or when provably safe)
Files:
lib/edge/python/src/types/mod.rslib/edge/python/src/types/point_vectors.rslib/edge/python/src/lib.rslib/edge/python/src/update.rs
🧬 Code graph analysis (1)
lib/edge/python/src/update.rs (6)
lib/segment/src/json_path/parse.rs (1)
json_path(28-40)lib/edge/python/src/types/filter/condition.rs (8)
from(29-51)from(55-80)PyErr(92-92)PyErr(109-109)new(90-97)new(107-113)new(123-126)new(136-138)lib/edge/python/src/types/point_id.rs (1)
into_rust_vec(15-18)lib/edge/python/src/types/point.rs (2)
payload(36-38)new(15-23)lib/edge/python/src/types/point_vectors.rs (1)
new(17-22)lib/edge/python/src/types/filter.rs (1)
new(26-46)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: rust-tests (macos-latest)
- GitHub Check: rust-tests (ubuntu-latest)
- GitHub Check: rust-tests-no-rocksdb (ubuntu-latest)
- GitHub Check: lint
- GitHub Check: rust-tests (windows-latest)
- GitHub Check: integration-tests
- GitHub Check: integration-tests-consensus
🔇 Additional comments (3)
lib/edge/python/src/types/mod.rs (1)
5-5: Module re-export looks good.New
point_vectorsmodule and re-export are correct and consistent with the types surface.Also applies to: 13-13
lib/edge/python/src/lib.rs (1)
51-51: Exporting PyPointVectors — LGTM.
PyPointVectorsis now reachable underqdrant_edge. No issues.lib/edge/python/src/update.rs (1)
112-122: Review comment is incorrect. VectorNameBuf is a type alias for String, not a custom struct.VectorNameBuf is defined as
pub type VectorNameBuf = String, makingVec<VectorNameBuf>equivalent toVec<String>. PyO3 provides fullFromPyObjectsupport forVec<String>, so the current method signatures are already compatible with Python interop. The suggested fix is unnecessary as it would only convertStringtoVectorNameBuf(String), which is redundant. No changes are required.Likely an incorrect or invalid review comment.
| pub fn update_vectors(point_vectors: Vec<PyPointVectors>) -> Self { | ||
| let points = point_vectors | ||
| .into_iter() | ||
| .map(PointVectorsPersisted::from) | ||
| .collect(); | ||
|
|
||
| let operation = CollectionUpdateOperations::VectorOperation( | ||
| vector_ops::VectorOperations::UpdateVectors(vector_ops::UpdateVectorsOp { | ||
| points, | ||
| update_filter: None, | ||
| }), | ||
| ); | ||
|
|
||
| Self(operation) | ||
| } |
There was a problem hiding this comment.
Compile error: From for PointVectorsPersisted is not implementable (orphan rule). Use Into instead.
map(PointVectorsPersisted::from) won’t compile; From can’t be implemented for a foreign target type. Convert via the local wrapper’s Into.
pub fn update_vectors(point_vectors: Vec<PyPointVectors>) -> Self {
- let points = point_vectors
- .into_iter()
- .map(PointVectorsPersisted::from)
- .collect();
+ let points = point_vectors
+ .into_iter()
+ .map(std::convert::Into::into)
+ .collect();
pub fn update_vectors_conditional(
point_vectors: Vec<PyPointVectors>,
filter: PyFilter,
) -> Self {
- let points = point_vectors
- .into_iter()
- .map(PointVectorsPersisted::from)
- .collect();
+ let points = point_vectors
+ .into_iter()
+ .map(std::convert::Into::into)
+ .collect();Also applies to: 95-110
🤖 Prompt for AI Agents
In lib/edge/python/src/update.rs around lines 77 to 91 (and similarly at 95 to
110), the code uses PointVectorsPersisted::from in map(...) which fails the
orphan rule because From<PyPointVectors> for PointVectorsPersisted cannot be
implemented; change those conversions to use Into by replacing
map(PointVectorsPersisted::from) with map(Into::into) or map(|pv:
PyPointVectors| pv.into()) so the local wrapper's Into impl is used; apply the
same change to the other block at 95-110.
No description provided.