alessandrobenedetti commented on code in PR #4935:
URL: https://github.com/apache/solr/pull/4935#discussion_r4768152108


##########
solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java:
##########
@@ -42,14 +51,96 @@
  * behavior.
  *
  * <p>File based DirectoryFactory implementations generally extend this class.
+ *
+ * <p>The following parameters are supported:
+ *
+ * <ul>
+ *   <li>preload -- Which index files to load into the OS page cache when they 
are opened:
+ *       <ul>
+ *         <li>{@code ALL_FILES} or {@code true} -- all files.
+ *         <li>{@code false}, or not set -- no files.
+ *         <li>Comma separated alphanumeric file extensions, such as {@code 
vex,vec} -- only files
+ *             whose name ends with a listed extension. The leading {@code .} 
is optional.
+ *       </ul>
+ *       Values are matched case-insensitively. Any other value logs a warning 
and preloads no
+ *       files.
+ * </ul>
+ *
+ * <p>This parameter only applies when the underlying directory is an {@link 
MMapDirectory}, which
+ * is what {@link FSDirectory#open} selects on most platforms.
  */
 public class StandardDirectoryFactory extends CachingDirectoryFactory {
 
   private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
+  static final String PRELOAD_ALL_FILES = "ALL_FILES";
+  private static final Pattern PRELOAD_EXTENSION = 
Pattern.compile("\\.?[a-z0-9]+");
+
+  private BiPredicate<String, IOContext> preloadPredicate = 
MMapDirectory.NO_FILES;
+
+  @Override
+  public void init(NamedList<?> args) {
+    super.init(args);
+    SolrParams params = args.toSolrParams();
+    preloadPredicate = parsePreload(params.get("preload"));
+  }
+
+  private static BiPredicate<String, IOContext> parsePreload(String value) {
+    if (value == null) {
+      return MMapDirectory.NO_FILES;
+    }
+    String trimmed = value.trim();
+    if (trimmed.equalsIgnoreCase(PRELOAD_ALL_FILES) || 
trimmed.equalsIgnoreCase("true")) {

Review Comment:
   Ok, was not aware of the need of 'on/yes/off/no', I guess we can add the 
back-compatibility for those



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to