-
Notifications
You must be signed in to change notification settings - Fork 160
feat: allow caching the results of an unfiltered UniStream (WIP) #1853
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
Conversation
...a/ai/timefold/solver/core/impl/score/director/stream/BavetConstraintStreamScoreDirector.java
Outdated
Show resolved
Hide resolved
This is surprisingly simple! Some high-level comments; leaving naming out of the picture for now:
I'm not a big fan of this. The programming model doesn't look very nice IMO.
Something like this would be more stream-y:
This brings its own problems. But both proposals share the same issue - chaining static streams. Nothing (other than run-time fail-fasts) prevents you from doing This was the main idea of |
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/tuple/RecordingTupleNode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/BavetRootNode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/uni/StaticDataUniNode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/uni/StaticDataUniNode.java
Outdated
Show resolved
Hide resolved
.../ai/timefold/solver/core/impl/score/stream/bavet/uni/BavetStaticDataUniConstraintStream.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintFactory.java
Outdated
Show resolved
Hide resolved
To bring an alternative API idea:
This would produce a In essence, this brings a very simple, clear API:
It does have a downside - it doesn't allow arbitrary static streams, such as groupBy, map, flatten etc. Right now, nobody is asking for it, and I think it is a decent trade-off to get the benefits; but we can possibly ask other people for their opinion on this. |
ed2dfa9
to
0f4e6d0
Compare
0f4e6d0
to
6e94d9e
Compare
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.
Submitting more comments as I get familiar with the changes.
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/StaticDataFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/StaticDataSupplier.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/AbstractStaticDataNode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/AbstractStaticDataNode.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/quad/PrecomputeQuadNode.java
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/TupleSourceRoot.java
Outdated
Show resolved
Hide resolved
.../java/ai/timefold/solver/core/impl/score/stream/bavet/common/BavetStaticDataBuildHelper.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/score/stream/common/RetrievalSemantics.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/common/TupleRecorder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/impl/bavet/uni/AbstractForEachUniNode.java
Outdated
Show resolved
Hide resolved
Also fix flaky spring boot yaml tests that cannot be run in parallel.
7e3f40a
to
d37698c
Compare
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.
I love this! Small comments.
Please submit a second PR with docs updates. I'll ask Tom to review that one.
core/src/main/java/ai/timefold/solver/core/api/score/stream/bi/BiConstraintStream.java
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/ConstraintFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/PrecomputeFactory.java
Show resolved
Hide resolved
core/src/main/java/ai/timefold/solver/core/api/score/stream/PrecomputeFactory.java
Show resolved
Hide resolved
...mefold/solver/core/impl/score/stream/common/bi/AbstractBiConstraintStreamPrecomputeTest.java
Outdated
Show resolved
Hide resolved
...fold/solver/spring/boot/autoconfigure/TimefoldSolverMultipleSolverAutoConfigurationTest.java
Outdated
Show resolved
Hide resolved
Previously, forEach node sharing did not takie into account retrival semantics, so each of these return the same stream despite having different retrival semantics affecting joins: - constraintFactory.forEachUnfiltered(Fact.class) - constraintFactory.from(Fact.class) - precomputeFactory.forEachUnfiltered(Fact.class) Now retrival semantics are considered when node sharing.
|
Introduces ConstraintFactory.staticData(Uni), which creates an independent NodeNetwork from the provided Uni stream.
Introduces TupleSourceRoot that represent top level tuple producers (the ForEach nodes now implement this, as well as a new StaticDataUniNode).
The StaticDataUniNode caches the results of its internal NodeNetwork and maps the tuples to new tuples compatiable with the external NodeNetwork
Inserts/retracts invalidate the cache and cause the output tuples to be updated.
Updates uses the cache and do not notify the internal NodeNetwork.