Repository navigation
Filter deferred points in read operations Part 1 (Search, Scroll, Count) - #8283
Conversation
85dc797 to
4bd14a7
Compare
9f4c85a to
d7433a6
Compare
d7433a6 to
61c39f0
Compare
61c39f0 to
7f19359
Compare
c505e95 to
fb9a5c6
Compare
|
What about adding helper methods on the Something like: trait IdTracker {
fn iter_internal_visible(&self, deferred_from: Option<PointOffsetType>)
-> Box<dyn Iterator<Item = PointOffsetType> + '_>
{
match deferred_from {
None => self.iter_internal(),
Some(d) => Box::new(self.iter_internal().take_while(move |&id| id < d)),
}
}
fn iter_from_visible(&self, external_id: Option<PointIdType>, deferred_from: Option<PointOffsetType>)
-> Box<dyn Iterator<Item = (PointIdType, PointOffsetType)> + '_>
{
match deferred_from {
None => self.iter_from(external_id),
Some(d) => Box::new(self.iter_from(external_id).filter(move |(_, iid)| *iid < d)),
}
}
} |
| None => { | ||
| let filtered_points = payload_index.query_points(filter, &hw_counter, &is_stopped); | ||
| let filtered_points = | ||
| payload_index.query_points(filter, &hw_counter, &is_stopped, None); |
There was a problem hiding this comment.
why are we not applying the deferred_id filter here?
the sparse vectors are always indexed even on an appendable segment
There was a problem hiding this comment.
If I remember correctly, we decided to not filter sparse vectors since they are always indexed and there is no need to hide them.
I'll tackle sparse vectors in a separate PR 👍🏻
| Self::is_internal_id_deferred(internal_id, self.deferred_internal_id) | ||
| } | ||
|
|
||
| pub fn is_internal_id_deferred( |
There was a problem hiding this comment.
I think it is time to rebase and use the new official function for this :)
There was a problem hiding this comment.
I don't see a new function for this. We take internal ID as parameter here, where the new functions from #8279 take the external ID.
There was a problem hiding this comment.
We can remove a duplicate method later because this PR will be merged earlier than #8279
9d45700 to
c761a90
Compare
c761a90 to
b1f3f8b
Compare
| pub fn get_vector_context( | ||
| &self, | ||
| vector_name: &VectorName, | ||
| deferred_internal_id: Option<PointOffsetType>, |
There was a problem hiding this comment.
I propose to remove ' deferred_internal_id ' here and move it to the higher level as a new VectorQueryContext::deferred_internal_id field. The motivation of the suggestion is to do like another help params: deleted points, hardware_counter ect
| fn iter_random(&self) -> Box<dyn Iterator<Item = (PointIdType, PointOffsetType)> + '_>; | ||
|
|
||
| /// Iterate over all internal IDs. Optionally filter all deferred points. | ||
| fn iter_internal_visible( |
There was a problem hiding this comment.
What if we move this filtering inside iter_internal? We will store a deferred id also as a field in the ID tracker by this proposal.
It's a question to discuss. I see pros and cons about it
There was a problem hiding this comment.
Motivation of such proposal:
There are new methods such as iter_random_visible and iter_from_visible. It would be nice if we can skip creation of this methods and use existing ones
There was a problem hiding this comment.
To be honest I don't think that adding this field to IdTracker makes it much cleaner. Also in my opinion, the caller should decide when to filter and when not, to prevent filtering at places where we must not.
What exactly is the issue with adding those helper functions?
There was a problem hiding this comment.
My concern is that we don't use iter_random anymore, a lot of glue and public api of ID tracker, which is unused.
My proposal about keeping deferred_point_id inside ID tracker is about keeping the public API of ID tracker unchanged (except for get-set methods). But it's a proposal, maybe it's enough just provide deferred id as an argument to old functions
| pub fn peek_top_all( | ||
| self, | ||
| is_stopped: &AtomicBool, | ||
| deferred_internal_id: Option<PointOffsetType>, |
There was a problem hiding this comment.
Can we provide this argument during scorer construction? Currently, we have peek_top_all and peek_top_iter with different usage - one requires parameters, the second one requires external filtering. I find it important to keep consistency between these methods
There was a problem hiding this comment.
I agree with your concerns about consistency. We already provide deferred_internal_id in the constructor of BatchFilteredSearcher but we can't apply it in peek_top_iter as the passed iterator can be of any order.
As an alternative approach, I'd suggest to pass it to both functions instead and remove it from the constructor/struct itself. Let me know which approach you prefer!
There was a problem hiding this comment.
I preferred to have deferred id inside the scorer.
My arguments about such an approach.
Deferred ID is a special kind of filter. We keep all the other filters inside the scorer (like the payload filter, point deleted, and vector deleted filter).
Maybe it's enough to use it in BatchFilteredSearcher only and modify the filter from BatchFilteredSearcher into this call
There was a problem hiding this comment.
Let me ask if we can keep deferred id in BatchFilteredSearcher and modify the filter inside BatchFilteredSearcher to filter deferred points if they are presented
| self.id_tracker | ||
| .borrow() | ||
| .available_point_count() | ||
| .saturating_sub(self.deferred_point_count_estimated()) |
There was a problem hiding this comment.
Inside deferred_point_count_estimated you define deferred points amount as internal_id value. Why do we perform more complicated estimation here instead of just taking internal_id?
IvanPleshkov
left a comment
There was a problem hiding this comment.
After discussion with @JojiiOfficial I decided to place an approval with the promise that my concerns will be refactored while chaos testing (or right after the release)
|
please rebase :) |
b1f3f8b to
097c0b8
Compare
…nt) (#8283) * Implement filtering: Search * Add tests for search and read_filtered * Implement filtering: read_ordered_filtered + Tests * Codespell + Clippy * Reduce code duplication in tests * Use helper methods of Id tracker * Implement filtering: Random Scroll * fixes after rebase * [Unittest] Only set deferred ID if deferred points exist * [Unit test] Reduce combinations in segment creation test --------- Co-authored-by: Ivan Pleshkov <[email protected]>
…nt) (#8283) * Implement filtering: Search * Add tests for search and read_filtered * Implement filtering: read_ordered_filtered + Tests * Codespell + Clippy * Reduce code duplication in tests * Use helper methods of Id tracker * Implement filtering: Random Scroll * fixes after rebase * [Unittest] Only set deferred ID if deferred points exist * [Unit test] Reduce combinations in segment creation test --------- Co-authored-by: Ivan Pleshkov <[email protected]>
Implements deferred point filtering for the following read operations:
It also partially implements filtering in other read operations, such as facet, since some operations sometimes use the same functions. Therefore I suggest to wait with merging until the remaining read operations are implemented, which will be done in a separate PR to not make this PR too big.
This PR is best reviewed on per-commit level. However, the unit tests might be best to review at the end.