← Back to Pull requests

[ZEPPELIN-6465] Extract magic numbers in EmbeddingSearch.saveIndex() into named constants #5489

Closed
unknown closed this pull request without merging on Sep 20, 2026 02:11 UTC
View on GitHub
unknown unknown commented on Sep 18, 2026 17:02 UTC
Author

What is this PR for?


EmbeddingSearch declares its tuning values as named private static final int constants near the top of the class (EMBEDDING_DIM, MAX_TEXT_LENGTH, MAX_INDEX_ENTRIES), but the two truncation limits in saveIndex() were left as bare literals. Each value appeared twice — once in the length check and once in the substring(0, ...) call — so changing only one occurrence would silently let the check bound and the truncation bound drift apart.

This extracts 2000 and 1000 into MAX_PERSISTED_TEXT_LENGTH and MAX_PERSISTED_OUTPUT_LENGTH, following the constant style already used in the class, and replaces all four usages.

The names deliberately distinguish these persistence limits from the existing MAX_TEXT_LENGTH (1500), which bounds in-memory processing before embedding and is a different value for a different purpose. Javadoc on the new text constant makes that distinction explicit.

Values are unchanged, so behavior and the persisted binary format are identical and INDEX_VERSION does not need to move. loadIndex() has no corresponding truncation logic and is untouched.

What type of PR is it?


Refactoring

Todos


  • Extract the two truncation limits into named constants

  • Replace all four literal usages in saveIndex()
  • What is the Jira issue?


    https://issues.apache.org/jira/browse/ZEPPELIN-6465

    How should this be tested?


    The EmbeddingSearch tests are gated behind ZEPPELIN_EMBEDDING_TEST and require the embedding model to be installed first:

    bash bin/install-search-model.sh
    ZEPPELIN_EMBEDDING_TEST=true ./mvnw test -pl zeppelin-server -Dtest='EmbeddingSearch'

    All 12 tests pass. grep -n "2000\|1000" EmbeddingSearch.java shows the values only at the two constant declarations, with no bare literals left in saveIndex().

    Screenshots (if appropriate)


    N/A

    Questions:


    Does the license files need to update? No
    Is there breaking changes for older versions? No
  • Does this needs documentation? No
  • Diff: 255 lines (+191 / -64) across 3 files Reviewer: ParkGyeongTae Review duration: 1989m
    All Vouch review confidence checks passed
    Residual risk 0.15 = 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 · 255 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.332
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5489"
    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.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    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.4% · Safe to merge
    15.4%