-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add the concurrent usage collector #800
feat: Add the concurrent usage collector #800
Conversation
Christopher-Chianelli
commented
Apr 18, 2024
- Renamed the consecutive interval collector to the concurrent usage collector and move it to core
- Added methods for finding maximum and minimum concurrent usage in the cluster
- Fix bugs relating to duplicate intervals in the concurrent usage collector
- Add docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's discuss the API. My two main comments:
-
The end of the range. Should it be exclusive, as is often the case in Java APIs?
-
The name "concurrent usages". I appreciate that you tried to give the collector some semantics, indicate what it's for - I think that's a good instinct. At the same time, I'm wondering if:
2a. Aren't we boxing ourselves in? If people use it for something else than concurrent resource use, they'll be confused. Maybe there is a better generic naming?
2b. Even if we want to keep semantics in the name, "concurrent usage" doesn't seem the best. Especially in the part "getConcurrentUsages", it really doesn't sound like proper English. Maybe this is a "concurrent use" collector then?
Finally - Sonar, please.
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintCollectors.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/ConcurrentUsage.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/ConcurrentUsageInfo.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/ConcurrentUsageInfo.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/IntervalBreak.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/common/IntervalBreak.java
Outdated
Show resolved
Hide resolved
...imefold/solver/core/impl/score/stream/collector/bi/ConcurrentUsageBiConstraintCollector.java
Outdated
Show resolved
Hide resolved
- Renamed the collector to "concurrent usage", since it is mostly useful for tracking the maximum usage of a limited resource - Add two new methods for getting the minimum and maximum concurrent usage - Fix bugs in the consecutive interval collector; in particular handling duplicate intervals (previously duplicate intervals were not added).
709acb3
to
9a3f3b2
Compare
.../ai/timefold/solver/core/impl/score/stream/collector/connectedRanges/ConnectedRangeImpl.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintCollectors.java
Outdated
Show resolved
Hide resolved
Disagree on https://sonarcloud.io/project/issues?pullRequest=800&open=AY7zJHLnJu5nr6ccd4B4&id=ai.timefold%3Atimefold-solver ; it removes a specific interval from the cluster and returns an iterator that creates the new interval clusters. Currently, it recalculates it from scratch, but it can possibly be made incremental by using the interval start points. For instance,
|
Are we talking about the same method?
The method doesn't use the argument. It's also not part of the public API, so it doesn't need to keep the argument just in case we decide to use it in the future. I honestly don't see how this method removes anything. |
Yes, that method iterator is what removes the interval, think of it as a |
And the
In other words:
The |
It currently unused, yes, but IMO, removing it makes the calling code less clear. Does |
To be honest, the code is very unclear as is - you're relying on side effects of other things; there is no obvious reason why the simple act of creating an instance of an iterator should cause the removal of anything. To make this situation a little bit less severe, you are adding an unused argument to the surrounding method, which only raises more questions. In my opinion, when you need to do strange things to make some other part of the code look better, you should rethink the code as a whole. |
The iterator did not remove anything, rather it any new interval clusters caused by the removal. Removed the method, kept the iterator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after minor comments resolved.
...mefold/solver/core/impl/score/stream/collector/connected_ranges/ConnectedRangeChainImpl.java
Outdated
Show resolved
Hide resolved
...ai/timefold/solver/core/impl/score/stream/collector/connected_ranges/ConnectedRangeImpl.java
Outdated
Show resolved
Hide resolved
- Also replaced a constructor of ConnectedRange with a static method that uses ConnectedSubrangeIterator
.../java/ai/timefold/solver/core/impl/score/stream/collector/connected_ranges/RangeGapImpl.java
Show resolved
Hide resolved
Quality Gate passedIssues Measures |