refactor(mapper): add ResultToGraphChunks convenience for the map+split flow#243
Open
xytan0056 wants to merge 1 commit into
Open
refactor(mapper): add ResultToGraphChunks convenience for the map+split flow#243xytan0056 wants to merge 1 commit into
xytan0056 wants to merge 1 commit into
Conversation
…it flow Reintroduce a single public entry point that turns a targethasher.Result into the ordered []entity.GetTargetGraphResponse chunks that storage.WriteGraphStream consumes. The map -> SplitBySize -> SplitMetadata recipe was hand-assembled identically in nativeOrchestrator and query-bench, and off-module callers (e.g. CI-integrated orchestrators) could not reproduce it at all because streaming.SplitBySize / SplitMetadata live under internal/. ResultToGraphChunks keeps the split helpers internal while exposing the common "map, split, hand to WriteGraphStream" path. The two-step ResultToTargetGraph API stays for callers that need to control chunking. Both existing callsites collapse onto the new function (net -40 LOC).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
mapper.ResultToGraphChunks(ctx, result, maxBytes)— a single public entry point that turns atargethasher.Resultinto the ordered[]entity.GetTargetGraphResponsechunks thatstorage.WriteGraphStreamconsumes.Why
The
ResultToTargetGraph→streaming.SplitBySize→streaming.SplitMetadata→ assemble recipe was hand-copied identically inorchestrator/native_orchestrator.goandexample/cmd/query-bench/main.go. Worse, off-module callers cannot reproduce it at all:streaming.SplitBySize/SplitMetadatalive underinternal/, so a CI-integratedOrchestratorimplementation in a downstream repo has no supported way to serialize a computed graph for caching.This effectively reinstates the ergonomics of the old
common.ResultToGetTargetGraphResponse(removed in the proto→JSON refactor, #222) — but at the entity layer, byte-size based, and without leaking the internal split helpers into the public API.Design
streaming.SplitBySize/SplitMetadatastayinternal/— they're wire-format implementation details.ResultToTargetGraphAPI is unchanged, for callers that need to control or interleave chunking.ResultToGraphChunksis the convenience path for the common "map, split, hand toWriteGraphStream" flow.Changes
mapper.ResultToGraphChunks+ tests (single-chunk, tiny-budget split, context cancellation).Test plan
make build,make test(23/23 pass),make gazelleclean.