Dzmitry

09-27-2013, 01:56 PM

Hi all.

I am working on some improvements for Pentaho Formula Editor/Open formula. (related to PRD-4739, PRD-4713 in jira and some other improvements)

package org.pentaho.reporting.libraries.formula.function.math

I have forked to my private github account and surfing through CE version of Report Designer source code.

I found 2 types of SUM and SUMA functions.

Looking in code - they are behave in same way.

for example - SUMA is backed by class

public class SumAFunction extends SumFunction

...

protected boolean isStrictSequenceNeeded()

{

return false;

}

just overriding isStrictSequenceNeeded from parent class, then -

in

public class SumFunction implements Function

...

final NumberSequence sequence = typeRegistry.convertToNumberSequence(type, value, isStrictSequenceNeeded());

is strict sequence needed is used only when converting to NumberSequence,

and inside implementation of runtime typeRegistry -

and this is the

package org.pentaho.reporting.libraries.formula.typing;

public class DefaultTypeRegistry implements TypeRegistry

...

public NumberSequence convertToNumberSequence(final Type type, final Object value, final boolean strict)

...

line 620: // else scalar

if (type.isFlagSet(Type.SCALAR_TYPE) || type.isFlagSet(Type.NUMERIC_TYPE))

{

return new DefaultNumberSequence

(new StaticValue(convertToNumber(type, value), NumberType.GENERIC_NUMBER), context);

}

will be evaluated even not consider to isStrictSequenceNeeded boolean flag.

This way seems that SUM and SUMA behaives in simple way in CE version of code.

Is it the the expected result?

What the real purpose for SUMA function?

Thank you.

PS And formula editor by itself and formulas implementations contains more bugs, hope will recover them with your help.

I am working on some improvements for Pentaho Formula Editor/Open formula. (related to PRD-4739, PRD-4713 in jira and some other improvements)

package org.pentaho.reporting.libraries.formula.function.math

I have forked to my private github account and surfing through CE version of Report Designer source code.

I found 2 types of SUM and SUMA functions.

Looking in code - they are behave in same way.

for example - SUMA is backed by class

public class SumAFunction extends SumFunction

...

protected boolean isStrictSequenceNeeded()

{

return false;

}

just overriding isStrictSequenceNeeded from parent class, then -

in

public class SumFunction implements Function

...

final NumberSequence sequence = typeRegistry.convertToNumberSequence(type, value, isStrictSequenceNeeded());

is strict sequence needed is used only when converting to NumberSequence,

and inside implementation of runtime typeRegistry -

and this is the

package org.pentaho.reporting.libraries.formula.typing;

public class DefaultTypeRegistry implements TypeRegistry

...

public NumberSequence convertToNumberSequence(final Type type, final Object value, final boolean strict)

...

line 620: // else scalar

if (type.isFlagSet(Type.SCALAR_TYPE) || type.isFlagSet(Type.NUMERIC_TYPE))

{

return new DefaultNumberSequence

(new StaticValue(convertToNumber(type, value), NumberType.GENERIC_NUMBER), context);

}

will be evaluated even not consider to isStrictSequenceNeeded boolean flag.

This way seems that SUM and SUMA behaives in simple way in CE version of code.

Is it the the expected result?

What the real purpose for SUMA function?

Thank you.

PS And formula editor by itself and formulas implementations contains more bugs, hope will recover them with your help.