Skip to content

Refactor request handler's doHandleRequest() into focused maintainable phases#163

Open
siddharthteotia wants to merge 1 commit into
masterfrom
steotia/refactor-do-handle-request
Open

Refactor request handler's doHandleRequest() into focused maintainable phases#163
siddharthteotia wants to merge 1 commit into
masterfrom
steotia/refactor-do-handle-request

Conversation

@siddharthteotia

@siddharthteotia siddharthteotia commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

JIRA: OA-850

  • Extracts five private methods from the 495-line doHandleRequest(), reducing it to ~175 lines with each processing phase clearly labeled

  • prepareOfflineAndRealtimeRequests() – hybrid/offline/realtime branching, time-boundary attachment, expression/timestamp overrides, query optimizer, always-false/true filter pruning

  • collectRoutingWarnings() – accumulates non-fatal routing warnings (partially-disabled tables, unavailable segments)

  • configureQueryTimeouts() – per-table timeout configuration; lets TimeoutException propagate to the caller for clean handling

  • configureServerResponseOptions() – max serialized response size per server and the single-server final-result flag

  • finalizeResponse() – replica group metadata, exception propagation, phase metrics, query logging

  • No behavioral changes.

  • Timing semantics are preserved: executionEndTimeNs is captured via System.nanoTime() in doHandleRequest() immediately after processBrokerRequest() returns and passed into finalizeResponse().

Also cleaned up 5 now-unnecessary local variable unpacks from routeInfo at the top of the post-routing block

Test plan

All 14 existing broker request tests pass.

  • BaseSingleStageBrokerRequestHandlerTest – 5 tests pass
  • LiteralOnlyBrokerRequestTest – 8 tests pass
  • BrokerRequestOptionsTest – 1 test passes
  • mvn compile -pl pinot-broker – clean compilation

🤖 Generated with Claude Code

…ocused phases

Extract five cohesive private methods from the 495-line doHandleRequest():
- prepareOfflineAndRealtimeRequests(): hybrid/offline/realtime branching, time-boundary
  attachment, expression/timestamp overrides, optimizer, always-false/true pruning
- collectRoutingWarnings(): disabled table names and unavailable segment warnings
- configureQueryTimeouts(): per-table timeout configuration (throws TimeoutException)
- configureServerResponseOptions(): max response size and single-server final-result flag
- finalizeResponse(): replica groups, exception propagation, metrics emission, query logging

doHandleRequest() is now ~175 lines (down from ~495) with each phase clearly labeled.
No behavioral changes; timing semantics preserved by capturing executionEndTimeNs before
finalizeResponse().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@siddharthteotia siddharthteotia force-pushed the steotia/refactor-do-handle-request branch from 01f87bb to 081b818 Compare March 27, 2026 11:49
@siddharthteotia siddharthteotia changed the title Refactor BaseSingleStageBrokerRequestHandler.doHandleRequest() into focused phases Refactor request handler's doHandleRequest() into focused maintainable phases Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant