uschindler commented on code in PR #13570:
URL: https://github.com/apache/lucene/pull/13570#discussion_r1681841607


##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -167,6 +188,7 @@ public MMapDirectory(Path path, LockFactory lockFactory, 
long maxChunkSize) thro
       throw new IllegalArgumentException("Maximum chunk size for mmap must be 
>0");
     }
     this.chunkSizePower = Long.SIZE - 1 - 
Long.numberOfLeadingZeros(maxChunkSize);
+    this.groupingFunction = GROUP_BY_SEGMENT;

Review Comment:
   See above.



##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -102,6 +118,11 @@ public class MMapDirectory extends FSDirectory {
    */
   public static final long DEFAULT_MAX_CHUNK_SIZE;
 
+  /** A provider specific context object or null, that will be passed to 
openInput. */
+  final Object attachment = PROVIDER.attachment();
+
+  Function<String, Optional<String>> groupingFunction;

Review Comment:
   Maybe initialize it here (like for preload). Can also be private.



##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -184,6 +206,21 @@ public void setPreload(BiPredicate<String, IOContext> 
preload) {
     this.preload = preload;
   }
 
+  /**

Review Comment:
   Maybe add some short description also to class definition (like for preload).



##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -83,6 +86,19 @@ public class MMapDirectory extends FSDirectory {
    */
   public static final BiPredicate<String, IOContext> NO_FILES = (filename, 
context) -> false;
 
+  /** Argument for {@link #setGroupingFunction(Function)} that configures no 
grouping. */
+  public static final Function<String, Optional<String>> NO_GROUPING = 
filename -> Optional.empty();
+
+  /** Argument for {@link #setGroupingFunction(Function)} that configures 
grouping by segment. */
+  public static final Function<String, Optional<String>> GROUP_BY_SEGMENT =
+      filename -> {
+        String segmentName = IndexFileNames.parseSegmentName(filename);
+        if (filename.length() == segmentName.length()) {
+          return Optional.empty();
+        }
+        return Optional.of(segmentName);
+      };

Review Comment:
   Do we also have a function that parses the Long without reimplementing it 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to