The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

[SOLVED] Caching getParameterTypes?

UrhixidurUrhixidur Member Posts: 40 Contributor II
edited November 2018 in Help
I've noticed that the getParameterTypes method of my home-brew operator gets called quite often.  It gets called during RapidMiner's startup, when it loads the plugins (fair enough), but also twice every time my operator is selected in the Operators palette of the GUI:

Nov 26, 2012 2:06:16 PM com.rapidminer.tools.WrapperLoggingHandler log
INFO: LTFDataReader: CachedLTFExampleSource.getParameterTypes begins.
Nov 26, 2012 2:06:29 PM com.rapidminer.tools.WrapperLoggingHandler log
INFO: LTFDataReader: CachedLTFExampleSource constructor done.
...
Nov 26, 2012 2:06:30 PM com.rapidminer.tools.WrapperLoggingHandler log
INFO: LTFDataReader: CachedLTFExampleSource.getParameterTypes begins.
Nov 26, 2012 2:06:39 PM com.rapidminer.tools.WrapperLoggingHandler log
INFO: LTFDataReader: CachedLTFExampleSource constructor done.
Any thoughts/warnings/caveats concerning the possibility of rewriting my getParameterTypes so that it caches the List<ParameterType> it builds the first time, in order to return the cached List when it gets called again?  The cached values would be specific to each instance of the operator, right?
Tagged:

Answers

  • Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    Hi,

    yes, getParameterTypes is called quite often. Because of this it should not take too long to finish.
    If you want to cache your parameterTypes you could try to do something like this:

    public class TestOperator extends Operator {

    private static final String PARAMETER_CHUNK_SIZE = "chunk_size";
    private static final int DEFAULT_BATCH_SIZE = 10;

    /**
    * @param description
    */
    public TestOperator(OperatorDescription description) {
    super(description);
    }

    private List<ParameterType> parameterTypes = null;

    @Override
    public List<ParameterType> getParameterTypes() {
    if (parameterTypes == null) {
    parameterTypes = new LinkedList<ParameterType>();
    ParameterTypeInt type = new ParameterTypeInt(PARAMETER_CHUNK_SIZE, "???", 1, Integer.MAX_VALUE, DEFAULT_BATCH_SIZE);
    type.setOptional(false);
    parameterTypes.add(type);
    }
    return parameterTypes;
    }
    }
    And yes the cached values are specific for each instance of the operator.

    Best,
    Nils
Sign In or Register to comment.