Clarification on TODO intent
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 34.7k
- Forks
- 2.7k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 187
Description
Context
I’m contributing in the REST conversion layer and wanted to clarify the intent of this TODO:
impl From<VectorStructInternal> for VectorStructOutput {
fn from(value: VectorStructInternal) -> Self {
// ToDo: this conversion should be removed
match value {
VectorStructInternal::Single(vector) => VectorStructOutput::Single(vector),
VectorStructInternal::MultiDense(vector) => {
VectorStructOutput::MultiDense(vector.into_multi_vectors())
}
VectorStructInternal::Named(vectors) => VectorStructOutput::Named(
vectors
.into_iter()
.map(|(k, v)| (k, VectorOutput::from(v)))
.collect(),
),
}
}
}
The TODO says: “this conversion should be removed”.
The conversion in question is the internal-to-REST mapping from VectorStructInternal to VectorStructOutput, used when building REST ScoredPoint responses:
impl From<segment::types::ScoredPoint> for ScoredPoint {
fn from(value: segment::types::ScoredPoint) -> Self {
let segment::types::ScoredPoint {
id,
version,
score,
payload,
vector,
shard_key,
order_value,
} = value;
ScoredPoint {
id,
version,
score,
payload,
vector: vector.map(VectorStructOutput::from),
shard_key,
order_value,
}
}
}
#[derive(Serialize, JsonSchema, Clone, Debug)]
pub struct ScoredPoint {
/// Vector of the point
#[serde(skip_serializing_if = "Option::is_none")]
pub vector: Option<VectorStructOutput>,
}
Interpretation options
I see 2 possible interpretations:
-
Helper function approach
Remove the globalFromimpl and use a local explicit helper, e.g.vector_struct_output_from_internal(...), called only at the REST boundary. -
Inline mapping approach
Remove the globalFromimpl and inline thematchdirectly at the call site (no helper function).
Clarification request
Could you confirm which interpretation you intended for that TODO?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the From for VectorStructOutput implementation and the REST ScoredPoint conversion shown in the issue. Read the surrounding REST conversion code and tests to determine the intended boundary for this mapping. Done means the TODO's intended refactor is implemented without changing serialized ScoredPoint vector responses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100