Skip to content

fix: fix overriding prefetch limit in local mode#1081

Merged
joein merged 2 commits into
devfrom
fix-local-query-points-groups
Oct 27, 2025
Merged

fix: fix overriding prefetch limit in local mode#1081
joein merged 2 commits into
devfrom
fix-local-query-points-groups

Conversation

@joein

@joein joein commented Oct 1, 2025

Copy link
Copy Markdown
Member

@netlify

netlify Bot commented Oct 1, 2025

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 32e3cce
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/68fbc8e8e26eea0008528998
😎 Deploy Preview https://deploy-preview-1081--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 1, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

qdrant_client/local/local_collection.py: query_groups now deep-copies the provided prefetch structure and applies limits via a new iterative routine. The recursive helper was removed and replaced by set_prefetch_limit_iteratively(prefetch, limit), which walks nested Prefetch objects (and lists) using an explicit stack and mutates .limit in-place, returning None. tests/congruence_tests/test_query.py: adds dense_queries_rescore_group_single_prefetch to exercise a nested single-outer-prefetch scenario and updates test_query_group to run and compare results against the existing rescoring flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • generall
  • coszio
  • timvisee

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive The pull request description consists only of a reference to issue "#1078" without any additional explanation or context about what the changeset does or why the fix is needed. While this reference technically points to related issue information, the description itself is extremely vague and generic—it provides no meaningful information about the actual changes being made, such as replacing the recursive prefetch limit function with an iterative one or the rationale behind this change. A reader would need to independently look up the linked issue to understand what is being fixed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "fix: fix overriding prefetch limit in local mode" is directly and clearly related to the main change in the changeset. The PR modifies prefetch limit handling by replacing a recursive approach with an iterative one in the local collection query logic, which is precisely what the title describes. The title is concise, specific enough to convey the core issue being addressed, and would help a teammate understand the primary purpose of this change when scanning history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-local-query-points-groups

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca239dd and 32e3cce.

📒 Files selected for processing (1)
  • qdrant_client/local/local_collection.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
qdrant_client/local/local_collection.py (2)
qdrant_client/grpc/points_pb2.pyi (3)
  • prefetch (2807-2808)
  • prefetch (2879-2880)
  • prefetch (3020-3021)
qdrant_client/http/models/models.py (1)
  • Prefetch (1914-1938)
⏰ 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). (8)
  • GitHub Check: Redirect rules - poetic-froyo-8baba7
  • GitHub Check: Header rules - poetic-froyo-8baba7
  • GitHub Check: Pages changed - poetic-froyo-8baba7
  • GitHub Check: Python 3.10.x on ubuntu-latest test
  • GitHub Check: Python 3.13.x on ubuntu-latest test
  • GitHub Check: Python 3.12.x on ubuntu-latest test
  • GitHub Check: Python 3.9.x on ubuntu-latest test
  • GitHub Check: Python 3.11.x on ubuntu-latest test
🔇 Additional comments (1)
qdrant_client/local/local_collection.py (1)

1018-1022: Good practice: deep-copying before mutation.

The deep copy ensures the original user-provided prefetch structure isn't mutated, which is the correct approach.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@joein joein force-pushed the fix-local-query-points-groups branch from d5c929d to ca239dd Compare October 24, 2025 11:53
@joein joein requested a review from tbung October 24, 2025 11:55
Comment thread qdrant_client/local/local_collection.py Outdated
Comment on lines +2847 to +2858
def set_prefetch_limit_recursively(prefetch: types.Prefetch, limit: int) -> types.Prefetch:
if prefetch is not None:
def set_prefetch_limit_recursively(
prefetch: Union[types.Prefetch, list[types.Prefetch]], limit: int
) -> None:
if isinstance(prefetch, list):
for p in prefetch:
set_prefetch_limit_recursively(p, limit)
elif isinstance(prefetch, types.Prefetch):
prefetch.limit = limit

if isinstance(prefetch.prefetch, list):
return types.Prefetch(
limit=limit,
prefetch=[set_prefetch_limit_recursively(p, limit) for p in prefetch.prefetch],
)
else:
return types.Prefetch(limit=limit, prefetch=list())
for p in prefetch.prefetch:
set_prefetch_limit_recursively(p, limit)
elif isinstance(prefetch.prefetch, types.Prefetch):
set_prefetch_limit_recursively(prefetch.prefetch, limit)

@tbung tbung Oct 24, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we really care, but there should probably be a cycle check/max depth or something here, or at least a try/except for RecursionError with a instructive message. Because not only could prefetch be arbitrarily deeply nested, you can also technically put a prefetch object into the list inside itself.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since this is user-controlled there definitely should be something here.

@joein joein requested a review from tbung October 25, 2025 11:17
"""Set .limit on all nested Prefetch objects without recursion."""
stack: list[Union[types.Prefetch, list[types.Prefetch]]] = [prefetch]

while stack:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could still get stuck in an infinite loop I guess, but I guess putting a prefetch object in its own list won't happen on accident, so it's fine.

@joein joein merged commit 6b031b3 into dev Oct 27, 2025
14 checks passed
joein added a commit that referenced this pull request Nov 14, 2025
* fix: fix overriding prefetch limit in local mode

* fix: replace recursion with a while loop in prefetch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants