ZhYQ1 opened a new pull request, #432:
URL: https://github.com/apache/hugegraph-ai/pull/432

   Closes #431
   
   ## Summary
   
   `QueryService.traverse` issued one repository read per id per hop. Add an 
internal batch primitive `link_members_by_ids` and use it in the hop loop, so 
each hop costs one read for the whole frontier. Results are merged in 
`current_ids` order; single-object reads keep using `_linked_ids`.
   
   ## Changes
   
   - `stores/repo.py` — new `link_members_by_ids(session, link_name, ids, *, 
from_source, at=None) -> dict[str, list[str]]`. Join table uses one `IN (...)` 
on `src_id`/`dst_id`; FK source side one `IN (...)` on the fk column; FK target 
side one `IN (...)` on the pk column (was one `repo.get` per id). Empty id set 
returns `{}` without a query.
   - `engine/service.py` — new `_linked_ids_many` wrapper; the traverse hop 
loop batches reads and merges per id.
   - `tests/test_engine_functions.py` — three tests: per-hop batch counts for a 
two-hop FK traverse, a join-table traverse, and an equivalence check of the 
batch primitive against per-id `_linked_ids` across all links and both 
directions.
   
   ## Query count
   
   Per hop: N reads → 1 read. In the FK fixture (2 work centres, 5 operations) 
a two-hop traverse goes from 7 reads to 2.
   
   ## Behavior
   
   No public API or signature change. `_linked_ids` is untouched for 
single-object reads; edge attribution is verified so ids cannot contaminate 
each other.
   
   ## Test plan
   
   From `ontogeny`:
   
       ruff check server/ontogeny/engine/service.py 
server/ontogeny/stores/repo.py tests/test_engine_functions.py
       ruff format --check server/ontogeny/engine/service.py 
server/ontogeny/stores/repo.py tests/test_engine_functions.py
       pytest tests/test_engine_functions.py -q -k "batch or link"
   
   Result: targeted tests pass, ruff clean. Unrelated `os.fchmod` fixture 
errors occur on Windows only.
   
   ## Notes
   
   - Baseline: `ontogeny @e3b98ec`.
   - Rollback is a single revert of this commit.


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to