...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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); } @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 access the additional content of an incoming streaming object you can use the getAdditionalContents method to access all contents. If you only want to access a special field you can issue the getAdditionalContent(fieldName) method.
Support for optimization
To support the optimization of predicates, the methods getTimeComplexity and getSpaceComplexity can be implemented. Both functions should return a value 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 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.