Skip to content

Make the segment pre-processor pluggable via SegmentPreProcessorProvider - #19369

Merged
Jackie-Jiang merged 1 commit into
apache:masterfrom
Jackie-Jiang:pluggable-segment-preprocessor
Aug 26, 2026
Merged

Make the segment pre-processor pluggable via SegmentPreProcessorProvider#19369
Jackie-Jiang merged 1 commit into
apache:masterfrom
Jackie-Jiang:pluggable-segment-preprocessor

Conversation

@Jackie-Jiang

Copy link
Copy Markdown
Contributor

Summary

Adds a minimal SPI to let plugins substitute the SegmentPreProcessor used at segment load:

  • SegmentPreProcessorProvider: creates the pre-processor for one preprocess run. Implementations are discovered through ServiceLoader, enumerated on the default classloader and on every plugin classloader (PluginManager#getPluginClassLoaders), with the highest-priority provider winning — the same convention as IndexPlugin.
  • SegmentPreProcessor.create(...): resolves the provider once and falls back to the plain SegmentPreProcessor when none is registered, so behavior is unchanged for deployments without a provider.
  • ImmutableSegmentLoader constructs the pre-processor through create(...) at its two call sites.

The motivation is resources that span every index handler of one preprocess run — e.g. staging a local copy of a remote source file that several handlers read. Handlers run in unspecified order relative to each other, so no single handler can own such a resource's lifecycle; a pre-processor subclass wrapping process() can open it before super.process(...) and release it in a finally.

Plugins can substitute a SegmentPreProcessor subclass to manage resources
spanning every index handler of one preprocess run - e.g. a locally staged
copy of a remote source file that several handlers read. Handlers run in
unspecified order relative to each other, so no single handler can scope
such a resource; a pre-processor subclass wrapping process() can.

Providers are discovered through ServiceLoader on the default classloader
and on every plugin classloader, with the highest-priority one winning
(the IndexPlugin convention). Without a registered provider, behavior is
unchanged.
@Jackie-Jiang Jackie-Jiang added the feature New functionality label Aug 26, 2026
@codecov-commenter

codecov-commenter commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.46%. Comparing base (0513b74) to head (36300fe).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ocal/segment/index/loader/SegmentPreProcessor.java 52.94% 5 Missing and 3 partials ⚠️
...ment/index/loader/SegmentPreProcessorProvider.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19369      +/-   ##
============================================
+ Coverage     67.44%   67.46%   +0.01%     
  Complexity     1430     1430              
============================================
  Files          3485     3486       +1     
  Lines        223874   223892      +18     
  Branches      35300    35304       +4     
============================================
+ Hits         150988   151041      +53     
+ Misses        60895    60857      -38     
- Partials      11991    11994       +3     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-25 67.46% <55.00%> (+0.01%) ⬆️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 67.46% <55.00%> (+0.01%) ⬆️
unittests 67.45% <55.00%> (+0.01%) ⬆️
unittests1 57.56% <55.00%> (+0.02%) ⬆️
unittests2 39.30% <55.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jackie-Jiang
Jackie-Jiang merged commit 4e12f1e into apache:master Aug 26, 2026
12 checks passed
@Jackie-Jiang
Jackie-Jiang deleted the pluggable-segment-preprocessor branch August 26, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants