Skip to content

Add endpoint to run topk aggregation - #452

Open
zipdoki wants to merge 22 commits into
feature/per-entity-top-k-metafrom
feature/per-entity-top-k-agg
Open

Add endpoint to run topk aggregation#452
zipdoki wants to merge 22 commits into
feature/per-entity-top-k-metafrom
feature/per-entity-top-k-agg

Conversation

@zipdoki

@zipdoki zipdoki commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an endpoint that runs a topk aggregation for a batch of edge events. For each event, the service queries the group's aggregation and writes the score row into the topk score table.

Changes

  • Add POST /graph/v3/aggregations — accepts an AggregationItemRequest and returns per-item AggregationResult.
  • Add AggregationService.aggregate(type, items) — fans items out to events, dispatches per aggregation type, resolves ranges ({source} / {target} / {_source} / {_target} / user properties), writes score entries to the score table keyed by ${entity}|${topkName}.
  • Add EdgeAggregationEvent domain model for the item × group unit.

How to Test

  • ./gradlew :engine:test --tests "com.kakao.actionbase.engine.service.AggregationServiceSpec"
  • ./gradlew :server:test --tests "com.kakao.actionbase.server.api.graph.v3.metadata.MetadataAggControllerE2ETest"

AI Assistance

  • This PR was written largely with AI assistance.
    • Tool / model: Claude Code (Opus 4.7)

zipdoki and others added 19 commits July 8, 2026 17:13
…top-k-agg

# Conflicts:
#	engine/src/main/kotlin/com/kakao/actionbase/engine/service/AggregationService.kt
#	engine/src/test/kotlin/com/kakao/actionbase/engine/service/AggregationServiceSpec.kt
…urce and target entities; update tests to validate directional behavior.
…top-k-agg

# Conflicts:
#	core/src/main/kotlin/com/kakao/actionbase/core/metadata/common/AggregationConstants.kt
#	engine/src/main/kotlin/com/kakao/actionbase/engine/service/AggregationService.kt
#	engine/src/main/kotlin/com/kakao/actionbase/v2/engine/v3/V2BackedEngine.kt
#	engine/src/main/kotlin/com/kakao/actionbase/v2/engine/v3/V3TableDescriptor.kt
#	engine/src/test/kotlin/com/kakao/actionbase/engine/service/AggregationServiceSpec.kt
#	server/src/main/kotlin/com/kakao/actionbase/server/api/graph/v3/metadata/MetadataAggController.kt
#	server/src/test/kotlin/com/kakao/actionbase/server/api/graph/v3/metadata/MetadataAggControllerE2ETest.kt
…top-k-agg

# Conflicts:
#	core/src/main/kotlin/com/kakao/actionbase/core/metadata/common/AggregationConstants.kt
#	server/src/test/kotlin/com/kakao/actionbase/server/api/graph/v3/metadata/MetadataAggControllerE2ETest.kt
Refresh handling moves to a separate API, so the aggregate flow no longer
needs to detect expire CDC items and reroute them. Drops:
- `isExpire` branching in `createTopkEvent` / `processTopk` / `aggregateTopk`
- `isExpire` field on `EdgeAggregationEvent` and its properties-based `of` overload

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Follow-up on the terminology change from #400: the score row is still
valid at the refresh timestamp, just due for a rebuild. Applied end-to-
end so the aggregate flow and its persisted schema line up:

- `AggregationConstants`: `TOPK_EXPIRE_TABLE` / `_PARTITIONS` and
  `expireSource` / `expireTarget` renamed
- `AggregationService`: local `expiresAt` and property key
  `"expiresAt"` renamed
- Refresh tracker table schema: column `expiresAt` → `refreshAt`,
  index `expires_at_asc` → `refresh_at_asc`, table comment updated

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…top-k-agg

# Conflicts:
#	server/src/test/kotlin/com/kakao/actionbase/server/api/graph/v3/metadata/MetadataAggControllerE2ETest.kt
@zipdoki zipdoki self-assigned this Jul 22, 2026
@zipdoki
zipdoki requested a review from em3s as a code owner July 22, 2026 09:51
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Jul 22, 2026
…top-k-agg

# Conflicts:
#	server/src/test/kotlin/com/kakao/actionbase/server/filter/ReadOnlyRequestFilterTest.kt
@zipdoki
zipdoki force-pushed the feature/per-entity-top-k-agg branch from 4301f7f to d0cca8a Compare July 23, 2026 01:18
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant