[Red Hat JIRA] (DROOLS-1422) Make AccumulateFunction interface simpler and more powerful
by Mario Fusco (Jira)
[ https://issues.redhat.com/browse/DROOLS-1422?page=com.atlassian.jira.plug... ]
Mario Fusco resolved DROOLS-1422.
---------------------------------
Resolution: Won't Do
> Make AccumulateFunction interface simpler and more powerful
> -----------------------------------------------------------
>
> Key: DROOLS-1422
> URL: https://issues.redhat.com/browse/DROOLS-1422
> Project: Drools
> Issue Type: Feature Request
> Components: core engine
> Reporter: Geoffrey De Smet
> Assignee: Mario Fusco
> Priority: Major
>
> * Replace the AccumulateFunction interface with the AccumulateFunction2 interface:
> ** All core runtime code uses the AccumulateFunction2 interface.
> ** Deprecate AccumulateFunction and use a bridge class at DRL compilation time so old implementations still work because they are bridged into the new interface
> * Changes of the AccumulateFunction2:
> ** Methods no longer throw checked exceptions (no "throws Exception"), so drools doesn't have to catch them. This might improve performance.
> ** Remove "Serializable context". The class itself contains the state.
> *** Remove method createContext()
> *** Replace method init(Serializeble) with constructor call (no-args normally)
> *** Remove parameter Serializable from accumulate(value), reserve(value) and getResult() methods
> *** Instead of making 1 AccFunction instance and n context instances, make n AccFunction instances. This uses less memory.
> *** This might improve performance (data locality).
> ** It should Serializable, but doesn't have to Externalizable. Removes methods writeExternal() and readExternal() in the user implementation.
> * Interface ReversableAccumulateFunction2 extends AccumulateFunction2
> ** Only ReversableAccumulateFunction2 has method reverse(value)
> ** Remove method supportsReverse(): the custom accumulate is reverseable if it also implements this interface
> * Opportunities
> ** construction parameters. For example: fixed average for standard deviation (very useful for OptaPlanner)
> ** Multi-argument accumulates, for example in DRL: `$total : standardDeviation($groupBy, $weight)`
> Notice how clean the user implementation would become.
> {code}
> // NEW
> public class SumAccumulateFunction
> implements ReversableAccumulateFunction2<Integer, Integer> {
> public int total;
> public SumAccumulateFunction() {
> total = 0;
> }
> public void accumulate(Integer value) {
> total += value;
> }
> public void reverse(Integer value) {
> total -= value;
> }
> public Integer getResult() {
> return total;
> }
> }
> {code}
> *Compare that with the old way:*
> {code}
> // OLD
> public class SumAccumulateFunction implements AccumulateFunction {
> public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { }
> public void writeExternal(ObjectOutput out) throws IOException { }
> protected static class SumData implements Externalizable {
> public double total = 0;
> public SumData() {}
> public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
> total = in.readDouble();
> }
> public void writeExternal(ObjectOutput out) throws IOException {
> out.writeDouble(total);
> }
> }
> public Serializable createContext() {
> return new SumData();
> }
> public void init(Serializable context) {
> SumData data = (SumData) context;
> data.total = 0;
> }
> public void accumulate(Serializable context,
> Object value) {
> SumData data = (SumData) context;
> data.total += ((Number) value).doubleValue();
> }
> public void reverse(Serializable context,
> Object value) {
> SumData data = (SumData) context;
> data.total -= ((Number) value).doubleValue();
> }
> public Object getResult(Serializable context) {
> return ((SumData) context).total;
> }
> public boolean supportsReverse() {
> return true;
> }
> public Class<?> getResultType() {
> return Double.class;
> }
> }
> {code}
> Some other cases:
> Different result type than value type:
> {code}
> public class AverageAccumulateFunction
> implements ReversableAccumulateFunction2<Integer, Double> {
> public int total;
> public int count;
> public AverageAccumulateFunction() {
> total = 0;
> count = 0;
> }
> public void accumulate(Integer value) {
> total += value;
> count++;
> }
> public void reverse(Integer value) {
> total -= value;
> count--;
> }
> public Double getResult() {
> return (double) total / count;
> }
> }
> {code}
> Construction parameter:
> {code}
> public class StdDeviationAccumulateFunction
> implements ReversableAccumulateFunction2<Integer, Double> {
> public final double average;
> public double variance;
> public StdDeviationAccumulateFunction(double average) {
> this.average = average;
> variance = 0;
> }
> public void accumulate(double value) {
> variance += (value - average)²; // TODO
> }
> public void reverse(double value) {
> variance -= (value - average)²; // TODO
> }
> public Double getResult() {
> return Math.sqrt(variance);
> }
> }
> {code}
> TODO multi-argument accumulate:
> ...
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
3 years, 8 months
[Red Hat JIRA] (DROOLS-5952) Improve RangeIndexANCTest to check rangeIndex use
by Toshiya Kobayashi (Jira)
Toshiya Kobayashi created DROOLS-5952:
-----------------------------------------
Summary: Improve RangeIndexANCTest to check rangeIndex use
Key: DROOLS-5952
URL: https://issues.redhat.com/browse/DROOLS-5952
Project: Drools
Issue Type: Task
Components: core engine
Affects Versions: 7.48.0.Final
Reporter: Toshiya Kobayashi
Assignee: Toshiya Kobayashi
Currently RangeIndexANCTest asserts the results but doesn't actually check if range index is used by the execution (So I checked the generated code). Improve the test to assert it automatically.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
3 years, 8 months
[Red Hat JIRA] (WFCORE-5169) Migrate all tests to use version AM26 of Apache DS
by Sonia Zaldana (Jira)
[ https://issues.redhat.com/browse/WFCORE-5169?page=com.atlassian.jira.plug... ]
Sonia Zaldana reassigned WFCORE-5169:
-------------------------------------
Assignee: Sonia Zaldana
> Migrate all tests to use version AM26 of Apache DS
> --------------------------------------------------
>
> Key: WFCORE-5169
> URL: https://issues.redhat.com/browse/WFCORE-5169
> Project: WildFly Core
> Issue Type: Bug
> Components: Security, Test Suite
> Reporter: Darran Lofthouse
> Assignee: Sonia Zaldana
> Priority: Major
>
> We are presently using version M24 so should upgrade all tests to AM26.
> All testsuite poms should be checked to ensure we bring in individual dependencies and not the shaded ApacheDS artefact as that shades in other packages such as bouncycastle which conflict with the version we pull in.
> It may be time for a single common LDAP project in our testsuite to act as an aggregation point / holding point for our various utilities. As we move to later versions quite often the APIs change so a central point to deal with these changes will be cleaner.
> Couple of known issues to work through:
> ApacheDS expects the KeyStore to only contain a single entry, it may be sufficient to remove the CA certificate from the KeyStore.
> The APIs to configure the cache have been removed, it appears these lines can just be removed from our initialisation.
> At this point there are new test failures that will need to be debugged, the first being filtered attributes are added to the attribute map twice - not sure if this is an ApacheDS bug or something Elytron should handle better.
> Two further tests also start to fail but I have not debugged them yet.
--
This message was sent by Atlassian Jira
(v8.13.1#813001)
3 years, 8 months