Skip to content

Add StreamPage DataLoader extensions and hash IncludeItems in branch keys - #5

Merged
michaelstaib merged 2 commits into
mst/stream-v2from
mst/dataloader-streampage
Sep 28, 2026
Merged

michaelstaib merged 2 commits into
mst/stream-v2from
mst/dataloader-streampage

Conversation

@michaelstaib

Copy link
Copy Markdown
Owner

This gives DataLoaders that return StreamPage<T> the same With, Select, Where and OrderBy extensions that Page<T> DataLoaders have. Both use the same branch keys and state keys, so GetPagingArguments and GetQueryContext work unchanged inside a stream fetch. The branch-key hashing now lives in one shared helper, and it includes PagingArguments.IncludeItems, so a count-only request no longer shares a branch with a rows request. The n: marker is written only when IncludeItems is false, so every existing branch key stays byte-identical; that is worth a second look since cached branches depend on it.

Closed tickets: hc-fork-1-oxx.1 (b901f6a, 1bd6943).

Stack: sits on #4 (ToStreamPageAsync and end cursors in EF paging, mst/ef-paging-streampage).

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 27, 2026 01:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

One or more issues must be addressed before approval.

Review effort: Lite
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Adds paging, selection, filtering, and sorting extensions for StreamPage<T> DataLoaders, while centralizing paging branch-key hashing.

Changes:

  • Added StreamPage DataLoader extensions and tests.
  • Shared Page/StreamPage branch creation and hashing logic.
  • Added IncludeItems to branch-key hashing.
File Description
src/​GreenDonut/​test/​GreenDonut.Data.Tests/​Internal/​ExpressionHasherTests.cs Updated as part of this pull request.
src/​GreenDonut/​test/​GreenDonut.Data.Tests/​Extensions/​StreamPagingDataLoaderExtensionsTests.cs Updated as part of this pull request.
src/​GreenDonut/​src/​GreenDonut.Data/​Internal/​DataLoaderStateHelper.cs Updated as part of this pull request.
src/​GreenDonut/​src/​GreenDonut.Data/​Extensions/​GreenDonutStreamPaginationBatchingDataLoaderExtensions.cs Updated as part of this pull request.
src/​GreenDonut/​src/​GreenDonut.Data/​Extensions/​GreenDonutPaginationBatchingDataLoaderExtensions.cs Updated as part of this pull request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +133 to +143
requiredBufferSize += EstimateIntLength(pagingArguments.Last);

if (pagingArguments.Before is not null)
{
requiredBufferSize += pagingArguments.Before?.Length ?? 0;
requiredBufferSize += 2;
}

// Only reserve space for the marker when items are excluded, so the hash of every
// existing argument combination (IncludeItems true) stays byte-identical.
if (!pagingArguments.IncludeItems)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Agree. IncludeTotalCount, EnableRelativeCursors and NullOrdering will be encoded in the branch key for non-default values, keeping today's default combination byte-identical. Follow-up PR (task hc-fork-1-oxx.2).

(DataLoaderBase<TKey, StreamPage<TValue>>)dataLoader,
branchKey);

ApplyPagingState(branch, state);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Agree. A fetch-based test will execute a branched stream loader and assert the captured GetPagingArguments()/GetQueryContext() (selector, predicate, sorting). Follow-up PR (task hc-fork-1-7v0.8).

@michaelstaib
michaelstaib added this pull request to stack #7 September 27, 2026 10:23
@michaelstaib
michaelstaib force-pushed the mst/dataloader-streampage branch from 1bd6943 to c1e3fd7 Compare September 27, 2026 20:58
@michaelstaib
michaelstaib force-pushed the mst/dataloader-streampage branch 3 times, most recently from 27f3368 to bc337f2 Compare September 28, 2026 08:08
Base automatically changed from mst/ef-paging-streampage to mst/stream-v2 September 28, 2026 08:11
@michaelstaib
michaelstaib force-pushed the mst/dataloader-streampage branch from bc337f2 to c716c14 Compare September 28, 2026 08:11
@michaelstaib
michaelstaib merged commit df92687 into mst/stream-v2 Sep 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants