Coder Social home page Coder Social logo

siddhi-io / siddhi-execution-math Goto Github PK

View Code? Open in Web Editor NEW
1.0 31.0 26.0 2.11 MB

Extension which provides useful mathematical functions

Home Page: https://siddhi-io.github.io/siddhi-execution-math

License: Apache License 2.0

Java 100.00%
siddhi math utility expression-evaluator extension execution

siddhi-execution-math's People

Contributors

ajkarki avatar anoukh avatar anugayan avatar ashensw avatar charukak avatar dilini-muthumala avatar dnwick avatar erangatl avatar gimantha avatar gokul avatar gomathyk avatar grainier avatar ksdperera avatar lasanthafdo avatar maheshika avatar mohanvive avatar nirmal070125 avatar nisalaniroshana avatar niveathika avatar pcnfernando avatar ramindu90 avatar raveensr avatar rolandhewage avatar sajithshn avatar senthuran16 avatar suhothayan avatar tishan89 avatar wso2-jenkins-bot avatar yvonnew avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

siddhi-execution-math's Issues

Percentile Function Call throwing IndexOutOfBoundsException

Description:
Method getPercentileValue is not protected to the possibility of valueList to be empty due to event expiration. This provokes an IndexOutOfBoundsException. I am currently working on a use case where we need to compute percentiles over a sliding window and caught this situation. Currently, I am using a modified version of the extension in order cope with my requirements, but I am available to contribute it via PR.

Exception obtained:

19:13:35.621 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=1000, data=[1, 10.0], isExpired=false}]
19:13:35.625 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=1200, data=[1, 10.0], isExpired=false}]
19:13:35.626 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=1500, data=[1, 10.0], isExpired=false}]
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
19:13:35.635 [main] ERROR io.siddhi.core.util.Scheduler - Error while sending timer events, Index -1 out of bounds for length 0
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
at io.siddhi.extension.execution.math.PercentileFunctionExtension.getPercentileValue(PercentileFunctionExtension.java:197) ~[classes/:?]
at io.siddhi.extension.execution.math.PercentileFunctionExtension.access$300(PercentileFunctionExtension.java:84) ~[classes/:?]
at io.siddhi.extension.execution.math.PercentileFunctionExtension$IntPercentileAttributeState.processRemove(PercentileFunctionExtension.java:325) ~[classes/:?]
at io.siddhi.extension.execution.math.PercentileFunctionExtension.processRemove(PercentileFunctionExtension.java:160) ~[classes/:?]
at io.siddhi.extension.execution.math.PercentileFunctionExtension.processRemove(PercentileFunctionExtension.java:50) ~[classes/:?]
at io.siddhi.core.query.selector.attribute.aggregator.AttributeAggregatorExecutor.processRemove(AttributeAggregatorExecutor.java:139) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.selector.attribute.aggregator.AttributeAggregatorExecutor.processAttributeArray(AttributeAggregatorExecutor.java:78) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.selector.attribute.aggregator.AttributeAggregatorExecutor.execute(AttributeAggregatorExecutor.java:61) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.selector.attribute.processor.AttributeProcessor.process(AttributeProcessor.java:41) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.selector.QuerySelector.processInBatchNoGroupBy(QuerySelector.java:284) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:86) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.processor.stream.window.TimeWindowProcessor.process(TimeWindowProcessor.java:168) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.processor.stream.window.TimeWindowProcessor.process(TimeWindowProcessor.java:58) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.processor.stream.window.SlidingWindowProcessor.processEventChunk(SlidingWindowProcessor.java:74) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.processor.stream.AbstractStreamProcessor.process(AbstractStreamProcessor.java:133) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.query.input.stream.single.EntryValveProcessor.process(EntryValveProcessor.java:51) ~[siddhi-core-5.1.21.jar:?]
at io.siddhi.core.util.Scheduler.sendTimerEvents(Scheduler.java:196) [siddhi-core-5.1.21.jar:?]
at io.siddhi.core.util.Scheduler.access$300(Scheduler.java:49) [siddhi-core-5.1.21.jar:?]
at io.siddhi.core.util.Scheduler$1.onTimeChange(Scheduler.java:95) [siddhi-core-5.1.21.jar:?]
at io.siddhi.core.util.timestamp.TimestampGeneratorImpl.setCurrentTimestamp(TimestampGeneratorImpl.java:114) [siddhi-core-5.1.21.jar:?]
at io.siddhi.core.stream.input.InputHandler.send(InputHandler.java:76) [siddhi-core-5.1.21.jar:?]
at io.siddhi.extension.execution.math.Test.main(Test.java:43) [classes/:?]
19:13:35.666 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=7000, data=[1, 10.0], isExpired=false}]
19:13:35.667 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=8000, data=[1, 10.0], isExpired=false}]
19:13:35.667 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=9000, data=[1, 10.0], isExpired=false}]
19:13:35.668 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=11000, data=[1, 10.0], isExpired=false}]
19:13:35.668 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=12000, data=[1, 10.0], isExpired=false}]
19:13:35.669 [main] INFO  io.siddhi.core.util.EventPrinter - [Event{timestamp=12000, data=[1, 10.0], isExpired=false}]

Process finished with exit code 0

Affected Product Version:
5.0.4+

OS, DB, other environment details and versions:
Linux x64. OpenJDK 1.8.

Steps to reproduce:
The following code snippet can be used to reproduce the issue:

        SiddhiManager siddhiManager = new SiddhiManager();

        String executionPlan = ("@app:playback "
                + "define stream inputStream (sensorId int, temperature int); "
                + "partition with (sensorId of inputStream)\n"
                + "begin "
                + "@info(name = 'query1') from inputStream#window.time(5 sec) "
                + "select sensorId, math:percentile(temperature, 97.0) as percentile "
                + "insert all events into outputStream; " +
                "end;");
        SiddhiAppRuntime siddhiAppRuntime = siddhiManager
                .createSiddhiAppRuntime(executionPlan);

        siddhiAppRuntime.addCallback("outputStream", new StreamCallback() {
            @Override
            public void receive(Event[] events) {
                EventPrinter.print(events);
            }
        });

        InputHandler inputHandler = siddhiAppRuntime.getInputHandler("inputStream");
        siddhiAppRuntime.start();

        inputHandler.send(new Event(1000L,new Object[]{1, 10}));
        inputHandler.send(new Event(1200L,new Object[]{1, 10}));
        inputHandler.send(new Event(1500L,new Object[]{1, 10}));
        inputHandler.send(new Event(7000L,new Object[]{1, 10}));
        inputHandler.send(new Event(8000L,new Object[]{1, 10}));
        inputHandler.send(new Event(9000L,new Object[]{1, 10}));
        inputHandler.send(new Event(11000L,new Object[]{1, 10}));
        inputHandler.send(new Event(12000L,new Object[]{1, 10}));

        siddhiAppRuntime.shutdown();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.