Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEclipse
languagejava
titleMEP Function stub
linenumberstrue
public class MyFunction extends AbstractFunction<Double> {

    public static final SDFDatatype[][] accTypes = new SDFDatatype[][] {{ SDFDatatype.DOUBLE },
                                                                        { SDFDatatype.DOUBLE }};

    public MyFunction() {
        super("myFunction", 2, accTypes, SDFDatatype.DOUBLE, 3, 5);
    }

    @Override
    public Double getValue() {
        double a = (double) this.getInputValue(0);
        double b = this.getNumericalInputValue(1);

        return a  +b;
    }

    @Override
    final public int getTimeComplexity() {
        return 3;
    }

    @Override
    final public int getSpaceComplexity() {
        return 5;
    }
 }

 

Access to function attributes

...

To support the optimization of predicates, the methods getTimeComplexity time and getSpaceComplexity space complexity can be implementedset in the constructor as the last two parameters. Both functions should return a value values should be in the range between 0-9 depending on their average expected complexity. Depending on the returned value, the MEP function will be placed differently in the resulting optimized predicate. A rule of thumb should be, MEP functions with logarithmic complexity should return have a value between 0-3,  linear complexity a value between 4-6, and exponential complexity a value between 7-9. However, this is just a first draft. The basic idea is to evaluate cheap functions first and avoid expensive functions if possible.

...