-
Notifications
You must be signed in to change notification settings - Fork 0
Replace existing Transformation system with Op-based adaptations #44
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d8d7aea to
4a9b9f9
Compare
Member
|
@gselzer Exciting to see this progressing! Let me know when it is fully ready to go. |
6aabcd4 to
95a92ec
Compare
This could cause nasty ClassCastExceptions if users naively pass through lambdas that do not provide the needed types.
Allow the IterableTypeExtractor to determine the greatest common supertype of all of the elements in the Iterable. This required adding a 'greatest common supertype resolver' in Types.
We also generate a bunch of elementary adapt ops
Fixes made to the matcher in the process:
* Improve any checking in parameterizedTypes
Now, a Function<Function<I, O>, Function<Iterable<I>, Iterable<O>>> can
be matched to a Function<Any, Function<Iterable<Double>,
Iterable<Double>>>
* Improve TypeVariable assignability
Sometimes TypeVariables are assigned to Anys and sometimes this is
correct. Sometimes, however, this is incorrect, and we can later assign
this TypeVariable to a concrete object. (We do have to be careful,
though, to make sure that the TypeVariable actually is assignable to
that Object).
When using the matcher itself to find adaptor OpCandidates, we would
only get candidates that were assignable at compile time. This is bad,
because adaptations are runtime operations, and so long as the
function that we get out of the adaptation is safely assignable to
the type that was requested, the operation is safe and much more
flexible.
This allows adaptors to adapt Function<I, O> -> Function<List<I>,
List<O>> without creating another Op
These Ops adapt Function<I, O> to Computer<Iterable<I>, Iterable<O>> and Function<I, O> to Computer<Iterable<I>, Iterable<O>>
These were made redundant by the autogenerated tests
TODO: Resolve createOpInstance
Will be used to test the inplace -> function adapters
Now they lazily compute the output and return an Iterator instead of a List Note that we also do a lot of work on the complex lift adaptors here. This is because the output type of the the Function -> Iterable adaptors is a Function<Iterable<I>, Iterable<O>>, no longer a Function<Iterable<I>, List<O>>. Thus we had to change the type of these lifters that depend on this op, namely the complex lifters
A computer should not pass the same reference for both input and output. An inplace should not pass the same reference for both mutable input and other input.
Note: the existing inplace -> function transformation were not ensuring
the correct behavior (i.e. that the input should not be modified) and
were anyways redundant since they were just testing functionality, so
they were deleted.
TODO: these will probabaly be expensive, so we should find a way to hint
that it will be so
68846d4 to
cf0b75f
Compare
Now unnecessary since we have the adapt framework We also remove obsolete tests (usually non-code-generated) that were used to ensure proper transformation. They still run here, but they are obsolete.
We ensure that higher-priority Op Adaptations are attempted before lower-priority Op Adaptations
This was referenced Feb 28, 2020
ctrueden
added a commit
that referenced
this pull request
May 2, 2024
…i-discoverer Therapi-based Discovery
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces Op adaptations, a reworking of the Op Transformation system currently used to change the Functional Type of Ops.
Making an
adaptOp is as easy as making any other Op and is much easier than making a newOpTransformation. EachadaptOp must be aFunction(since you put one Op in and get another Op out). If youradaptOp does not haveOpDependencies, you can even make it a lambda!TODO:
OpRunners or multi-stage transformations. This branch exists on top ofpurge-ops-run, so if we do not merge this other PR first we will have to massage the history.