Skip to content

Commit

Permalink
Merge pull request #151 from scijava/scijava-ops-api/remove-infotree
Browse files Browse the repository at this point in the history
OpEnvironment.infoTree() is no longer necessary with the Ops.infoTree() utility method
  • Loading branch information
hinerm authored Apr 18, 2024
2 parents b68366a + d7c68af commit cfd86a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,41 +161,6 @@ default <T> T op( //
<T> T op(final String opName, final Nil<T> specialType,
final Nil<?>[] inTypes, final Nil<?> outType, Hints hints);

/**
* Returns an {@link InfoTree} fitting the provided arguments. NB
* implementations of this method likely depend on the {@link Hints} set by
* {@link OpEnvironment#setDefaultHints(Hints)}, which provides no guarantee
* of thread-safety. Users interested in parallel Op matching should consider
* using {@link OpEnvironment#op(String, Nil, Nil[], Nil, Hints)} instead.
*
* @param opName the name of the Op
* @param specialType the generic {@link Type} of the Op
* @param inTypes the arguments (inputs) to the Op
* @param outType the return of the Op (note that it may also be an argument)
* @return an instance of an Op aligning with the search parameters
*/
default InfoTree infoTree( //
final String opName, //
final Nil<?> specialType, //
final Nil<?>[] inTypes, //
final Nil<?> outType //
) {
return infoTree(opName, specialType, inTypes, outType, getDefaultHints());
}

/**
* Returns an {@link InfoTree} fitting the provided arguments.
*
* @param opName the name of the Op
* @param specialType the generic {@link Type} of the Op
* @param inTypes the arguments (inputs) to the Op
* @param outType the return of the Op (note that it may also be an argument)
* @param hints the {@link Hints} that should guide this matching call
* @return an instance of an Op aligning with the search parameters
*/
InfoTree infoTree(final String opName, final Nil<?> specialType,
final Nil<?>[] inTypes, final Nil<?> outType, Hints hints);

default <T> T opFromInfoChain(InfoTree tree, Nil<T> specialType) {
return opFromInfoChain(tree, specialType, getDefaultHints());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ public <T> T op( //
return findOp(opName, specialType, inTypes, outType, hints).asOpType();
}

@Override
public InfoTree infoTree(String opName, Nil<?> specialType, Nil<?>[] inTypes,
Nil<?> outType, Hints hints)
{
return findOp(opName, specialType, inTypes, outType, hints).infoTree();
}

@Override
public InfoTree treeFromInfo(OpInfo info, Nil<?> specialType, Hints hints) {
return findOp(info, specialType, hints).infoTree();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import org.scijava.ops.api.Hints;
import org.scijava.ops.api.InfoTree;
import org.scijava.ops.api.OpMatchingException;
import org.scijava.ops.api.*;
import org.scijava.ops.engine.*;
import org.scijava.ops.engine.OpCandidate.StatusCode;
import org.scijava.ops.api.OpEnvironment;
import org.scijava.ops.api.OpInfo;
import org.scijava.ops.api.OpRequest;
import org.scijava.ops.engine.matcher.MatchingRoutine;
import org.scijava.ops.engine.matcher.OpMatcher;
import org.scijava.ops.engine.matcher.impl.DefaultOpRequest;
Expand Down Expand Up @@ -140,8 +135,12 @@ public OpCandidate findMatch(MatchingConditions conditions, OpMatcher matcher,
Nil<?>[] args = Arrays.stream(request.getArgs()).map(Nil::of)
.toArray(Nil[]::new);
Nil<?> outType = Nil.of(request.getOutType());
return env.infoTree(request.getName(), type, args, outType,
var op = env.op(request.getName(), type, args, outType,
adaptationHints);
// NB the dependency is interested in the INFOTREE of the match,
// not the Op itself. We want to instantiate the dependencies
// separately, so they can e.g. operate silently.
return Ops.infoTree(op);
}).collect(Collectors.toList());
// And return the Adaptor, wrapped up into an OpCandidate
Type adapterOpType = Types.substituteTypeVariables(adaptor.output()
Expand Down

0 comments on commit cfd86a1

Please sign in to comment.