Adding Builder pattern in MMapDirectory.java
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
### Description
[MMapDirectory.java](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java) has 4 constructors and setters like `setPreload()` and `setReadAdvice()`. I see two issues here:
- Adding new arguments require permutation of constructors arguments and could lead to more growth in number of constructors.
- Since these setters can be called anytime after creation of a MMapDirectory instance, I am not sure if they are safe. Because configuration is mutable via setters, a change made by one thread (e.g., toggling preload) can lead to inconsistent behavior in other threads?
I think Builder pattern could be better suited here, it would eliminate need of multiple constructors and would make the MMapDirectory instance immutable. I am happy to contribute a PR but would love to hear thoughts on it as it will be a big API change.
Contributor guide
Research direction
Start with lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java, reviewing its four constructors and the setPreload() and setReadAdvice() setters. The issue does not define an accepted API or implementation scope; completion would require maintainer agreement on the proposed design before a PR can be evaluated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100