uschindler commented on code in PR #13570:
URL: https://github.com/apache/lucene/pull/13570#discussion_r1689595022
##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -83,6 +94,38 @@ public class MMapDirectory extends FSDirectory {
*/
public static final BiPredicate<String, IOContext> NO_FILES = (filename,
context) -> false;
+ /**
+ * This sysprop allows to control the total maximum number of mmapped files
that can be associated
+ * with a single shared {@link java.lang.foreign.Arena foreign Arena}. For
example, to set the max
+ * number of permits to 256, pass the following on the command line pass
{@code
+ * -Dorg.apache.lucene.store.MMapDirectory.sharedArenaMaxPermits=256}.
Setting a value of 1
+ * associates one file to one shared arena.
+ *
+ * @lucene.internal
+ */
+ static final String SHARED_ARENA_MAX_PERMITS_SYSPROP =
+ "org.apache.lucene.store.MMapDirectory.sharedArenaMaxPermits";
+
+ /** 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 -> {
+ if (!CODEC_FILE_PATTERN.matcher(filename).matches()) {
+ return Optional.empty();
+ }
+ String groupKey =
IndexFileNames.parseSegmentName(filename).substring(1);
+ try {
+ groupKey += IndexFileNames.parseGeneration(filename) == 0 ? "" :
"-g";
Review Comment:
its easier to read that way:
```java
// keep the original generation (=0) in base group, later generations in
extra group
if (IndexFileNames.parseGeneration(filename) > 0) {
groupKey += "-g";
}
```
##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -256,15 +336,31 @@ default IOException convertMapFailedIOException(
}
}
- private static MMapIndexInputProvider lookupProvider() {
+ private static Optional<Integer> getSharedArenaMaxPermitsSysprop() {
Review Comment:
OptionalInt?
IMHO, this should be an integer from beginning and initialized to default in
this class.
##########
lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java:
##########
@@ -83,6 +94,38 @@ public class MMapDirectory extends FSDirectory {
*/
public static final BiPredicate<String, IOContext> NO_FILES = (filename,
context) -> false;
+ /**
+ * This sysprop allows to control the total maximum number of mmapped files
that can be associated
+ * with a single shared {@link java.lang.foreign.Arena foreign Arena}. For
example, to set the max
+ * number of permits to 256, pass the following on the command line pass
{@code
+ * -Dorg.apache.lucene.store.MMapDirectory.sharedArenaMaxPermits=256}.
Setting a value of 1
+ * associates one file to one shared arena.
+ *
+ * @lucene.internal
+ */
+ static final String SHARED_ARENA_MAX_PERMITS_SYSPROP =
Review Comment:
should be public as it has Javadocs (to be conform to other sysprops in 9.x).
--
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]