ZhYQ1 opened a new issue, #431: URL: https://github.com/apache/hugegraph-ai/issues/431
### Search before asking - [x] I had searched in the [feature](https://github.com/apache/hugegraph-ai/issues?q=is%3Aissue+label%3A%22Feature%22) and found no similar feature requirement. ### Feature Description (功能描述) ## Problem `QueryService.traverse` walks links hop by hop. For every id in the current frontier it calls `_linked_ids`, which performs one repository read (`fk_linked_ids` / `link_members` / `repo.get`). With N ids in a hop that is N round trips per hop — e.g. a two-hop query over 2 work centres and 5 operations costs 7 reads. ## Proposal Add an internal repository primitive and use it in traverse: `link_members_by_ids(session, link_name, ids, *, from_source, at=None) -> dict[str, list[str]]` - join table: one `IN (...)` query on `src_id` or `dst_id` - FK source side: one `IN (...)` query on the fk column - FK target side: one `IN (...)` query on the pk column (previously one `repo.get` per id) - empty id set returns `{}` without touching the database Why a new primitive instead of extending `link_members`: `link_members` returns `(src, dst)` pairs filtered on one side and serves the single-object path; batching needs per-id grouping and a different return shape, so widening it would change the contract for existing callers. `_linked_ids` stays for single-object reads — no public API change. Both FK and join branches return the same `dict[id, list[id]]` shape, so traverse can merge results in `current_ids` order. Depends on #380 (this builds on the current shape of the traverse/link read path). I can send the PR with unit tests: per-hop batch counts for FK and join-table links, plus an equivalence check against the per-id reads. ### Are you willing to submit a PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
