Skip to content

Skip __count__ sentinel group in mutation path - #396

Merged
zipdoki merged 4 commits into
mainfrom
feat/skip-count-sentinel-mutation
Jul 8, 2026
Merged

zipdoki merged 4 commits into
mainfrom
feat/skip-count-sentinel-mutation

Conversation

@eazyhozy

@eazyhozy eazyhozy commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

__count__ is a sentinel group name reserved for AGG query interface compatibility and global topk metadata, added in #387. On read, it delegates to the native EdgeCount query instead of a real EdgeGroup lookup, so it never needs an EdgeGroup row of its own. The mutation path didn't know about this yet: if a table's groups metadata included __count__, every edge insert/update/delete would still emit an unnecessary EdgeGroupRecord (HBase Increment) for it.

Follow-up to #387, which introduced the __count__ sentinel on the read path.

Changes

  • core/.../edge/mutation/EdgeMutationBuilder.kt — buildGroupRecords() now skips any group whose name equals Constants.Group.COUNT_SENTINEL, before building its EdgeGroupRecords. This function is the single choke point for all three mutation transitions (CREATED / DELETED / UPDATED), so one guard covers the whole write path.
  • core/.../edge/mutation/EdgeMutationBuilderTest.kt — 3 new cases: CREATED with only a __count__ group produces no groupRecords (Edge and MultiEdge strategies); a __count__ group mixed with a real group is skipped while the real group's records are still produced correctly.

Out of scope: bulk-load doesn't have an EdgeGroup encoder yet (#389); the same skip will need to be added there once it exists.

How to Test

./gradlew :core:test --tests '*EdgeMutationBuilderTest'

Regression check for the existing sentinel read path:

./gradlew :engine:test --tests '*EdgeAggQuerySpec'
./gradlew :server:test --tests '*EdgeAggCountSentinelE2ETest'

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (claude-opus-4-8)

The `__count__` group is a sentinel reserved for AGG query interface
compatibility and topk metadata; reads delegate to native EdgeCount
instead of EdgeGroup. Without this guard, mutations on tables whose
groups include `__count__` would still emit an unnecessary
EdgeGroupRecord (HBase Increment).

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
@eazyhozy eazyhozy self-assigned this Jul 8, 2026
@eazyhozy
eazyhozy marked this pull request as ready for review July 8, 2026 00:59
@eazyhozy
eazyhozy requested a review from em3s as a code owner July 8, 2026 00:59
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 8, 2026
…-group case

Group validation isn't implemented yet, but the sentinel is intended to
only ever be registered with empty fields going forward, so the tests
reflect that instead of an arbitrary field list. Also add the
sentinel-mixed-with-a-real-group case to MultiEdgeStrategy to match the
existing Edge coverage.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
@eazyhozy eazyhozy changed the title fix: skip __count__ sentinel group in mutation path Skip __count__ sentinel group in mutation path Jul 8, 2026
@eazyhozy
eazyhozy requested a review from zipdoki July 8, 2026 01:06
@eazyhozy

eazyhozy commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Addressed offline review feedback from @em3s: don't special-case COUNT_SENTINEL alone in the mutation guard — use a reserved-name exclusion set so future sentinels don't require touching multiple places.

Follow-up commit replaces the standalone Constants.Group.COUNT_SENTINEL constant with Constants.Group.Reserved, an enum of reserved group names. EdgeMutationBuilder.buildGroupRecords() now checks membership via Reserved.contains(group.group) instead of comparing against a single constant, so adding a new reserved name is a one-line enum entry with no separate set to keep in sync.

Comparing directly against a single constant meant every future
reserved group name would need its own equality check wired in by
hand. Constants.Group.Reserved centralizes reserved names in one enum;
EdgeMutationBuilder now skips any group via Reserved.contains(), so
adding a new reserved name is a one-line enum entry with nothing else
to keep in sync.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jul 8, 2026
The enum added per-entry skipsGroupMutation tracking, but that's more
machinery than the read path uses for the same sentinel (QueryService
still does a plain equality check against COUNT_SENTINEL). Keep
Constants.Group.COUNT_SENTINEL as a single constant and move the
reserved-name set into EdgeMutationBuilder, where the mutation-skip
behavior actually lives.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 8, 2026
@eazyhozy

eazyhozy commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Follow-up on the exclude-set approach: I initially replaced the constant with a Reserved enum so future sentinels couldn't be added to Constants.Group without also declaring whether they skip group mutation. On reflection this was more machinery than the read path uses for the same sentinel — QueryService.agg still does a plain group == Constants.Group.COUNT_SENTINEL check, no enum involved. Reverted: Constants.Group.COUNT_SENTINEL stays a single constant, and the exclude set now lives in EdgeMutationBuilder (groupNamesExcludedFromMutation), next to the mutation-skip behavior it actually drives. Same effect as requested — new reserved names get added to that one set — without introducing a second mechanism.

@zipdoki

zipdoki commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Optimistic Merge

@zipdoki
zipdoki merged commit 1e9c4ae into main Jul 8, 2026
2 checks passed
@zipdoki
zipdoki deleted the feat/skip-count-sentinel-mutation branch July 8, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants