uschindler commented on code in PR #13570: URL: https://github.com/apache/lucene/pull/13570#discussion_r1679741852
########## lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInputProvider.java: ########## @@ -125,4 +134,31 @@ private final MemorySegment[] map( } return segments; } + + public ConcurrentHashMap<String, RefCountedSharedArena> attachment() { + return new ConcurrentHashMap<>(); + } + + /** + * Gets an arena for the give path, potentially aggregating files from the same segment into a + * single ref counted shared arena. A ref counted shared arena, if created will be added to the + * given arenas map. + */ + static Arena getSharedArena(Path p, ConcurrentHashMap<String, RefCountedSharedArena> arenas) { + String filename = p.getFileName().toString(); + String segmentName = IndexFileNames.parseSegmentName(filename); + if (filename.length() == segmentName.length()) { + // no segment found; just use a shared segment + return Arena.ofShared(); Review Comment: The case you are looking here at is when there is no relationship to a specific segment of an index. If it is a file which does not belong to a segment it returns a new shared arena (fallback to default). For this case it MUST return a new shared segment as the file belongs to nothing else and the mmapped memory must be freed on close. If the file belongs to an index segment it also creates a shared arena for the first file, but other files belonging to same segment will increase refcount. For that it has its own implementation of Arena which includes refcounting. -- 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