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


##########
solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java:
##########
@@ -42,14 +50,77 @@
  * behavior.
  *
  * <p>File based DirectoryFactory implementations generally extend this class.
+ *
+ * <p>Can set the following parameters:
+ *
+ * <ul>
+ *   <li>preload -- Whether to load each index file into the OS page cache 
when that file is opened.
+ *   <li>preloadExtensions -- Comma separated file extensions, such as {@code 
vex,vec}. Only files
+ *       whose name ends with a listed extension are loaded into the OS page 
cache when those files
+ *       are opened. Takes precedence over {@code preload}.
+ * </ul>
+ *
+ * <p>Both parameters only apply 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());
 
+  private boolean preload;
+  private Set<String> preloadExtensions = Set.of();
+
+  @Override
+  public void init(NamedList<?> args) {
+    super.init(args);
+    SolrParams params = args.toSolrParams();
+    preload = params.getBool("preload", false); // default turn-off
+    preloadExtensions = 
parsePreloadExtensions(params.get("preloadExtensions"));
+    if (preload && !preloadExtensions.isEmpty()) {
+      log.info(
+          "Ignoring preload=true because preloadExtensions was provided, so 
only loading files with extensions: {}",
+          preloadExtensions);
+    }
+  }
+
+  private static Set<String> parsePreloadExtensions(String value) {
+    if (value == null) {
+      return Set.of();
+    }
+    Set<String> extensions = new LinkedHashSet<>();

Review Comment:
   Why not a plain HashSet? I wouldn't expect the iteration order to matter 
here.



-- 
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