← Back to Pull requests

refactor: Make shard spec collector an interface for extensibility #19689

Closed
unknown closed this pull request without merging on Jul 23, 2026 07:56 UTC
View on GitHub
unknown unknown commented on Jul 15, 2026 12:55 UTC
Author

This is a follow-up to https://github.com/apache/druid/pull/19571. This patch addresses this review comment https://github.com/apache/druid/pull/19571#discussion_r3399518855 by refactoring the logic into an interface so it's extensible and maintainable. No other functional change.

New abstractions (2 interfaces + 2 impls)

- StreamingPartitionsSpec — was a concrete class, now a polymorphic Jackson interface (@JsonTypeInfo with type property, defaultImpl = DimensionValueSetPartitionsSpec). Its only method is createCollector() for now.
- DimensionValueSetPartitionsSpec (type: "dim_value_set") — the built-in impl holding the old fields (partitionDimensions, maxValuesPerDimension, validation, equals/hashCode/toString). createCollector() returns null when there are no
dimensions (disabled by default), otherwise a DimensionValueSetCollector.
- StreamingShardSpecCollector — new interface defining the per-task lifecycle required for stamping the shard specs: collect(segmentId, row) (run-loop, per row), onSegmentsRestored(segmentIds) (startup, disables pruning for restart-spanned segments), annotate(segment)
(publish-time stamping), onSegmentPublished(segmentId)
.
- DimensionValueSetCollector — the concrete collector holding the state that used to live in the runner (observedPartitionDimValuesBySegment ConcurrentHashMap, restartSpannedSegments set) and all the value-recording, capping, sorting, null-handling, and stamping logic.

This PR has:

  • been self-reviewed.

  • added documentation for new or modified features or behaviors.

  • a release note entry in the PR description.

  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.

  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.

  • been tested in a test Druid cluster.
  • Diff: 267 lines (+200 / -67) across 3 files Reviewer: abhishekrb19 Review duration: 11221m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 267 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.334
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #19689"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.6% · Safe to merge
    15.6%
    Repository