SOLR-18476: Support file suffix based MMapDirectory preload #4935
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 421 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.362
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4935"
general
weight: 0.35
sigram
https://issues.apache.org/jira/browse/SOLR-18476
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Solr:
https://issues.apache.org/jira/projects/SOLR
For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA.
To create a Jira issue, you will need to create an account there first.
The title of the PR should reference the Jira issue number in the form:
SOLR-####: <short description of problem or changes>
SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
Description
Existing usage of
preload=truewill attempt to load the entire index (filesystem) directory into OS page cache indiscriminately. This can be a problematic take on a good idea in 2 ways: 1) you may not want to run this long synchronous preload over the entire index and 2) you may not have enough physical memory to fit the whole index, so having the ability to prioritize some index files over others would be more practical/useful.Solution
Coded using Claude 5.0 Opus
Added "preloadExtensions" to StandardDirectoryFactory config definition (and all implementing classes like NRTCachingDirectoryFactory / MMapDirectoryFactory), which allows a comma separate list of file extensions to be provided (does not need to be used in conjunction with preload=true)
This also fixes an existing bug where preload=true was not respected at all by NRTCachingDirectoryFactory
StandardDirectoryFactory's create function uses a preload predicate depending on the configuration. Extensions predicate matches files with extension (after last "." in the filename) matching any of the provided in the configuration
Extensions provided are matched case-insensitively and "." is not required. Ordering of the extensions provided has no bearing on behavior
When preload=true is provided and preloadExtensions is provided, preloadExtensions behavior will take precedence (whole index not preloaded)
Tests
Add unit tests for MMapDirectoryFactory
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.