Add maxBytesPerRequest to NimbleIndexProjector#644
Open
tanjialiang wants to merge 2 commits intofacebookincubator:mainfrom
Open
Add maxBytesPerRequest to NimbleIndexProjector#644tanjialiang wants to merge 2 commits intofacebookincubator:mainfrom
tanjialiang wants to merge 2 commits intofacebookincubator:mainfrom
Conversation
Summary:
When `maxRowsPerLookup` truncates a lookup result, the caller previously had no way to know where to continue reading. This diff populates the `LookupResult::resumeKey` field to enable pagination of large result sets.
Changes:
- Add `ClusterIndexGroup::lookupChunkByRow()` to find a chunk by row position (reverse of `lookupChunk` which finds by key). Binary search on cumulative `chunk_rows`.
- Add `ClusterIndexReader::keyAtRow()` to read the encoded key at a given row position using the encoding API (reset + skip + materialize).
- In `NimbleIndexProjector::lookupRowRanges()`, when truncation occurs, call `keyAtRow()` on the first unread row to populate `resumeKey` with `{lowerKey=keyAtRow(endRow), upperKey=original.upperKey}`.
- Add `resumeKeys_` member to track resume keys per request across stripes.
Differential Revision: D98702773
Summary: Add a `maxBytesPerRequest` option to NimbleIndexProjector that limits the total bytes of serialized chunk data per lookup, complementing the existing `maxRowsPerRequest` row-based limit. Since byte sizes are only known after stripe serialization, byte-based truncation operates at stripe granularity: at least one stripe is always included (guaranteeing forward progress), then subsequent stripes are skipped if the byte budget is exceeded. A resume key is set to enable pagination. When both `maxRowsPerRequest` and `maxBytesPerRequest` are set, both limits apply independently — a lookup is saturated when either is reached. Row-based resume keys take priority over byte-based ones since they can point mid-stripe (more precise). Changes: - Add `maxBytesPerRequest` to `Options` (0 = no limit). - Add `bytesPerRequest_` member to track bytes per lookup across stripes. - Add `stripeEndResumeKey` to `RequestRange`, precomputed in `lookupRowRanges()` for use by byte-budget truncation in `buildStripeResult()` (where the index reader is no longer available). - In `project()`, filter saturated requests by both row and byte budgets. - In `buildStripeResult()`, track bytes and set byte-based resume keys. Differential Revision: D99391142
|
@tanjialiang has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99391142. |
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.
Summary:
Add a
maxBytesPerRequestoption to NimbleIndexProjector that limitsthe total bytes of serialized chunk data per lookup, complementing the
existing
maxRowsPerRequestrow-based limit.Since byte sizes are only known after stripe serialization, byte-based
truncation operates at stripe granularity: at least one stripe is always
included (guaranteeing forward progress), then subsequent stripes are
skipped if the byte budget is exceeded. A resume key is set to enable
pagination.
When both
maxRowsPerRequestandmaxBytesPerRequestare set, bothlimits apply independently — a lookup is saturated when either is
reached. Row-based resume keys take priority over byte-based ones since
they can point mid-stripe (more precise).
Changes:
maxBytesPerRequesttoOptions(0 = no limit).bytesPerRequest_member to track bytes per lookup across stripes.stripeEndResumeKeytoRequestRange, precomputed inlookupRowRanges()for use by byte-budget truncation inbuildStripeResult()(where the index reader is no longer available).project(), filter saturated requests by both row and byte budgets.buildStripeResult(), track bytes and set byte-based resume keys.Differential Revision: D99391142