Coder Social home page Coder Social logo

espertechinc / esper Goto Github PK

View Code? Open in Web Editor NEW
825.0 66.0 256.0 46.56 MB

Esper Complex Event Processing, Streaming SQL and Event Series Analysis

License: GNU General Public License v2.0

HTML 0.24% Java 99.63% GAP 0.13% Batchfile 0.01% Shell 0.01%
cep complex-event-processing open-source compiler streaming-sql espertech event-series-analysis esper java

esper's People

Contributors

bernhardttom avatar bernhardttom2 avatar dependabot[bot] avatar icholy avatar jc064522 avatar jlleitschuh avatar kaicao avatar markcshelton avatar raguessner avatar yangguang760 avatar

Stargazers

 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  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  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  avatar  avatar  avatar  avatar

esper's Issues

9 failures, 4 errors on Maven tests (version 5.3.0)

After making the fixes detailed in #34, #35, #36 on my forked branch, I run:

mvn -Dgpg.skip=true install | tee mvn_install.log

I get these results:

Failed tests:
  testInvalidScriptJS(com.espertech.esper.regression.script.TestScriptExpression)
  testParserMVELSelectNoArgConstant(com.espertech.esper.regression.script.TestScriptExpression)
  testContextMultistmt(com.espertech.esper.multithread.TestMTContextNestedNonOverlapAtNow)
  testParse(com.espertech.esper.regression.client.TestDeployParse)
  testEPLGraphOnly(com.espertech.esper.regression.dataflow.TestExampleVwapFilterSelectJoin)
  testSPI(com.espertech.esper.regression.client.TestStatementAnnotation)
  testSceneTwo(com.espertech.esper.multithread.TestMTDeterminismInsertInto)
  testFireAndForget(com.espertech.esper.regression.client.TestVirtualDataWindow)
  testSingleRowSplitAndType(com.espertech.esper.regression.view.TestContainedEventSplitExpr)

Tests in error:
  testDocSamples(com.espertech.esper.regression.script.TestScriptExpression)
  testScripts(com.espertech.esper.regression.script.TestScriptExpression)
  testSetMapProps(com.espertech.esper.regression.epl.TestUpdateMapIndexProps)
  testJSR223Sandboxed(com.espertech.esper.regression.script.TestScriptSandboxJSR223)

Tests run: 3726, Failures: 9, Errors: 4, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Esper .............................................. FAILURE [13:42 min]
[INFO] EsperIO-AMQP ....................................... SKIPPED
[INFO] EsperIO-CSV ........................................ SKIPPED
[INFO] EsperIO-DB ......................................... SKIPPED
[INFO] EsperIO-HTTP ....................................... SKIPPED
[INFO] EsperIO-Socket ..................................... SKIPPED
[INFO] EsperIO-SpringJMS .................................. SKIPPED
[INFO] EsperIO-Stax ....................................... SKIPPED
[INFO] Esper Examples ..................................... SKIPPED
[INFO] Esper Examples - AutoID ............................ SKIPPED
[INFO] Esper Examples - Benchmark ......................... SKIPPED
[INFO] Esper Examples - CycleDetect ....................... SKIPPED
[INFO] Esper Examples - MarketDataFeed .................... SKIPPED
[INFO] Esper Examples - MatchMaker ........................ SKIPPED
[INFO] Esper Examples - NamedWinQuery ..................... SKIPPED
[INFO] Esper Examples - OHLCPlugInView .................... SKIPPED
[INFO] Esper Examples - QualityOfServiceSLA ............... SKIPPED
[INFO] Esper Examples - RFIDAssetZone ..................... SKIPPED
[INFO] Esper Examples - RuntimeConfig ..................... SKIPPED
[INFO] Esper Examples - ServerShell ....................... SKIPPED
[INFO] Esper Examples - StockTicker ....................... SKIPPED
[INFO] Esper Examples TerminalSvc - Common ................ SKIPPED
[INFO] Esper Examples TerminalSvc - Receiver .............. SKIPPED
[INFO] Esper Examples TerminalSvc - Sender ................ SKIPPED
[INFO] Esper Examples TerminalSvc - MDB ................... SKIPPED
[INFO] Esper Examples TerminalSvc - EAR ................... SKIPPED
[INFO] Esper Examples TerminalSvc ......................... SKIPPED
[INFO] Esper Examples - TerminalServiceJSE ................ SKIPPED
[INFO] Esper Examples - Transaction ....................... SKIPPED
[INFO] Esper Examples - Trivia Geeks Club ................. SKIPPED
[INFO] Esper .............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13:42 min
[INFO] Finished at: 2016-01-12T19:28:47-08:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test (default-test) on project esper: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/davidj/dev/gigafone/esper/esper/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Escape characters for schema package names do not work

If a package name contains a keyword, then you can't define a schema for it:

create schema OrderEvent as com.tld.app.common.`order`.OrderEvent;

Does not find the package (it seems it looks for it with the backtick). Without the escaping it won't compile with error:
Caused by: com.espertech.esper.client.EPStatementSyntaxException: Incorrect syntax near '.' expecting end-of-input but found a dot '.' at line 5 column 52

Destroy nestedcontext

We did some tests to destroy a context partition.
We notices that, when we retrieve the context partitions from the engine. The destroyed context partition is also returned and is not destroyed.
When we send a new event for that partition, we notice that the event is not processed (which is good).
We are destroying the context to free some memory but it doesn't work as expected.

Subscriber single-row delivery on NamedWindow produces ClassCastException

Example:

create window AWindow.std:lastevent() as (a A)"
insert into AWindow select a from A as a
on pattern [every timer:at (*, *, *, *, *, */5)] select a from AWindow as a

When attaching the following Subscriber to the last statement:

public void update(A a) {}

I get the following exception:

17:16:55.485 [com.espertech.esper.Timer-default-0] ERROR com.espertech.esper.core.service.ResultDeliveryStrategyImpl - Invocation exception when invoking method 'update' of class 'ch.algotrader.test.esper.EsperDeadlockTest$1' passing parameters [BeanEventBean eventType=BeanEventType name=A clazz=ch.algotrader.test.esper.EsperDeadlockTest$A bean=ch.algotrader.test.esper.EsperDeadlockTest$A@f933c35] for statement '4ab0af25-f070-4d3f-854f-e18069c11c2f': ClassCastException : com.espertech.esper.event.bean.BeanEventBean cannot be cast to ch.algotrader.test.esper.EsperDeadlockTest$A
java.lang.ClassCastException: com.espertech.esper.event.bean.BeanEventBean cannot be cast to ch.algotrader.test.esper.EsperDeadlockTest$A
at ch.algotrader.test.esper.EsperDeadlockTest$1$$FastClassByCGLIB$$27191106.invoke(<generated>) ~[cglib-nodep-3.1.jar:?]
at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53) ~[cglib-nodep-3.1.jar:?]

Add support for a statement aware subscriber

The documentation suggests using a subscriber instead of an UpdateListener to get the best performance. However, there is no subscriber equivalent to StatementAwareListener.

One possible approach is to include the statement when the last parameter of the update method is of type EPStatement.

Expression with bracket-syntax table access causes string constant validation exception

Test class:

import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.deploy.DeploymentException;
import com.espertech.esper.client.deploy.Module;
import com.espertech.esper.client.deploy.ParseException;

import java.io.IOException;

public class EsperBreaker {
    public static void main(String ... args) throws ParseException, DeploymentException, IOException {
        EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();

        Module module = epService.getEPAdministrator().getDeploymentAdmin().parse("" +
                "create schema OrderIssue(id int, instrumentId int);\n" +
                "create window Positions.win:keepall() as (id int, instrumentId int, instrumentName string);\n" +
                "create table Instruments(id int primary key, name string);\n" +
                "create expression getInstrumentName {o => Instruments[o.instrumentId].name};\n" +
                "on OrderIssue oi\n" +
                "insert into Positions(id, instrumentId, instrumentName)\n" +
                "    select id, instrumentId, getInstrumentName(oi);"
        );
        epService.getEPAdministrator().getDeploymentAdmin().deploy(module, null);
    }
}

Deployment error appears:

com.espertech.esper.epl.expression.core.ExprValidationException: Failed to validate select-clause expression 'getInstrumentName(oi)': Error validating expression declaration 'getInstrumentName': Failed to validate declared expression body expression 'Instruments["o.instrumentId"].name': Incompatible type returned by a key expression for use with table 'Instruments', the key expression '"o.instrumentId"' returns 'java.lang.String' but the table expects 'java.lang.Integer'
    at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtree(ExprNodeUtility.java:306) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.core.ResultSetProcessorFactoryFactory.validateSelectAssignColNames(ResultSetProcessorFactoryFactory.java:773) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.core.ResultSetProcessorFactoryFactory.getProcessorPrototype(ResultSetProcessorFactoryFactory.java:133) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.core.start.EPStatementStartMethodOnTrigger.handleContextFactorySplitStream(EPStatementStartMethodOnTrigger.java:353) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.core.start.EPStatementStartMethodOnTrigger.startInternal(EPStatementStartMethodOnTrigger.java:140) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.core.start.EPStatementStartMethodBase.start(EPStatementStartMethodBase.java:57) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.StatementLifecycleSvcImpl.startInternal(StatementLifecycleSvcImpl.java:692) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.StatementLifecycleSvcImpl.start(StatementLifecycleSvcImpl.java:654) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createAndStart(StatementLifecycleSvcImpl.java:151) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.EPAdministratorImpl.createEPLStmt(EPAdministratorImpl.java:117) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.EPAdministratorImpl.createEPL(EPAdministratorImpl.java:91) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.deploy.EPDeploymentAdminImpl.deployInternal(EPDeploymentAdminImpl.java:174) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.deploy.EPDeploymentAdminImpl.deploy(EPDeploymentAdminImpl.java:102) [esper-5.2.0.jar:na]
    at EsperBreaker.main(EsperBreaker.java:23) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
Caused by: com.espertech.esper.epl.expression.core.ExprValidationException: Error validating expression declaration 'getInstrumentName': Failed to validate declared expression body expression 'Instruments["o.instrumentId"].name': Incompatible type returned by a key expression for use with table 'Instruments', the key expression '"o.instrumentId"' returns 'java.lang.String' but the table expects 'java.lang.Integer'
    at com.espertech.esper.epl.declexpr.ExprDeclaredNodeImpl.validate(ExprDeclaredNodeImpl.java:203) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtreeInternal(ExprNodeUtility.java:374) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtree(ExprNodeUtility.java:289) ~[esper-5.2.0.jar:na]
    ... 18 common frames omitted
Caused by: com.espertech.esper.epl.expression.core.ExprValidationException: Failed to validate declared expression body expression 'Instruments["o.instrumentId"].name': Incompatible type returned by a key expression for use with table 'Instruments', the key expression '"o.instrumentId"' returns 'java.lang.String' but the table expects 'java.lang.Integer'
    at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtree(ExprNodeUtility.java:306) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.declexpr.ExprDeclaredNodeImpl.validate(ExprDeclaredNodeImpl.java:199) ~[esper-5.2.0.jar:na]
    ... 20 common frames omitted
Caused by: com.espertech.esper.epl.expression.core.ExprValidationException: Incompatible type returned by a key expression for use with table 'Instruments', the key expression '"o.instrumentId"' returns 'java.lang.String' but the table expects 'java.lang.Integer'
    at com.espertech.esper.epl.expression.table.ExprTableNodeUtil.validateExpressions(ExprTableNodeUtil.java:44) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.table.ExprTableAccessNode.validateGroupKeys(ExprTableAccessNode.java:77) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.table.ExprTableAccessNodeSubprop.validateBindingInternal(ExprTableAccessNodeSubprop.java:51) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.table.ExprTableAccessNode.validate(ExprTableAccessNode.java:65) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtreeInternal(ExprNodeUtility.java:374) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtree(ExprNodeUtility.java:289) ~[esper-5.2.0.jar:na]
    ... 21 common frames omitted

I guess that now all fields accessed from expressions are supposed to be of String type. Type-checking of expressions should be performed for every usage or disabled at all.

Benchmark scripts have incorrect Java classpaths

cd examples/benchmark
chmod +x runServer.sh
./runServer.sh

Gives this error:

Error: Could not find or load main class com.espertech.esper.example.benchmark.server.Server

And... ./runClient.sh gives this error:

Error: Could not find or load main class com.espertech.esper.example.benchmark.client.Client

StackOverflowError when processing named window insert large batch

When running the following EPL:

create schema Event(id int);

create schema Incident(id int);

create window IncidentWindow.win:keepall() as Incident;

insert into Incident select * from Event.win:expr_batch(current_count >= 10000);

insert into IncidentWindow select * from Incident;

create dataflow EventsDataFlow
    BeaconSource -> events<Event> {id: 1, iterations: 10000}
    EventBusSink(events) {};

having EventsDataFlow started StackOverflowError is thrown:

java.lang.StackOverflowError: null
    at com.espertech.esper.epl.named.NamedWindowRootViewInstance.addNewData(NamedWindowRootViewInstance.java:101) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.epl.named.NamedWindowTailViewInstance.update(NamedWindowTailViewInstance.java:62) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.view.ViewSupport.updateChildren(ViewSupport.java:115) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.view.window.KeepAllView.update(KeepAllView.java:106) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.view.ViewSupport.updateChildren(ViewSupport.java:115) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.epl.named.NamedWindowRootViewInstance.update(NamedWindowRootViewInstance.java:126) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.view.ZeroDepthStreamNoIterate.insert(ZeroDepthStreamNoIterate.java:50) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.context.activator.ViewableActivatorFilterProxy$2.matchFound(ViewableActivatorFilterProxy.java:98) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterMultiple(EPRuntimeImpl.java:1198) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processMatches(EPRuntimeImpl.java:1071) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueueUnlatched(EPRuntimeImpl.java:934) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueueFront(EPRuntimeImpl.java:855) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:810) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processThreadWorkQueue(EPRuntimeImpl.java:836) ~[esper-5.3.0.jar:na]
...

Event Configuration ordering matters

Say you have

  • interface A
  • class Event implements A

then A needs to be registered against Esper before the subclass 'Event' in order for it to work in statements. However, in com.espertech.esper.client.Configuration the event types are stored in a HashMap and then iterated over on engine start when they are actually introduced to the engine. In java 7 and previous to that it managed to Just Work (TM) although this is really a lucky coincidence. In java 8 the iteration order of HashMaps has been changed and so this fails. This obviously depends on the number of entries in the HashMap etc for the iteration order. If the ordering is not correct then you get errors such as:

Caused by: com.espertech.esper.epl.expression.core.ExprValidationException: Segmented context '[ContextName]' requires that any of the event types that are listed in the segmented context also appear in any of the filter expressions of the statement, type '[A]' is not one of the types listed

The maps in Configuration should be changed to LinkedHashMaps so that ordering can be maintained.

Cheers,
Nick

NullPointerException with non-aggregated `having` clause and addListenerWithReplay

The following example illustrates a NullPointerException in ResultSetProcessorSimpleTransform when a query over a named window includes a simple having clause that initially yields no results:

import com.espertech.esper.client.*;

import java.util.Arrays;

public class EsperBug {
    static class TestEvent {
        private final String _origin;
        private final int _size;

        public TestEvent(final String origin, final int size) {
            _origin = origin;
            _size = size;
        }

        public String getOrigin() {
            return _origin;
        }

        public int getSize() {
            return _size;
        }
    }

    public static void main(final String... args) throws Throwable {
        final EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
        final EPRuntime runtime = epService.getEPRuntime();
        final EPAdministrator administrator = epService.getEPAdministrator();

        administrator.getConfiguration().addEventType("TestEvent", TestEvent.class);

        administrator.getDeploymentAdmin().parseDeploy(
            "create window TestEvents.win:keepall() as TestEvent;\n" +
            "insert into TestEvents select * from TestEvent;\n");

        runtime.sendEvent(new TestEvent("ORIGIN", 1));
        runtime.sendEvent(new TestEvent("ORIGIN", 2));

        final EPStatement epl = administrator.createEPL(
            "select origin, size from TestEvents\n" +
//            "group by origin\n" +
            "having size > 4000"
        );

        epl.start();

        epl.addListenerWithReplay(
            new UpdateListener() {
                @Override
                public void update(final EventBean[] newEvents, final EventBean[] oldEvents) {
                    System.out.println(Arrays.toString(newEvents));
                }
            }
        );
    }
}

The error stack trace is as follows:

Exception in thread "main" java.lang.NullPointerException
    at com.espertech.esper.epl.core.ResultSetProcessorSimpleTransform.transform(ResultSetProcessorSimpleTransform.java:36)
    at com.espertech.esper.collection.TransformEventIterator.next(TransformEventIterator.java:48)
    at com.espertech.esper.collection.TransformEventIterator.next(TransformEventIterator.java:20)
    at com.espertech.esper.core.service.EPStatementImpl.addListenerWithReplay(EPStatementImpl.java:366)
    at EsperBug.main(EsperBug.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

The exception site, ResultSetProcessorSimpleTransform::transform, attempts to access an element in an array of EventBean[] that happens to be null in this case:

public EventBean transform(EventBean theEvent)
{
    newData[0] = theEvent;
    UniformPair<EventBean[]> pair = resultSetProcessor.processViewResult(newData, null, true);
    return pair.getFirst()[0];
}

Adding a group by clause circumvents the exception, as can be seen by uncommenting the second line of the query.

Maven install failure on "Esper Examples TerminalSvc - EAR"

When I run mvn -DskipTests -Dgpg.skip=true install from the Esper project root directory:

I'm using the current Esper master (5.3.0) on Mac OS X 10.11.3.

[INFO] Reactor Summary:
[INFO]
[INFO] Esper .............................................. SUCCESS [  1.615 s]
[INFO] EsperIO-AMQP ....................................... SUCCESS [  2.689 s]
[INFO] EsperIO-CSV ........................................ SUCCESS [  0.646 s]
[INFO] EsperIO-DB ......................................... SUCCESS [  0.239 s]
[INFO] EsperIO-HTTP ....................................... SUCCESS [  0.350 s]
[INFO] EsperIO-Socket ..................................... SUCCESS [  0.157 s]
[INFO] EsperIO-SpringJMS .................................. SUCCESS [  1.206 s]
[INFO] EsperIO-Stax ....................................... SUCCESS [  0.822 s]
[INFO] Esper Examples ..................................... SUCCESS [  0.002 s]
[INFO] Esper Examples - AutoID ............................ SUCCESS [  0.068 s]
[INFO] Esper Examples - Benchmark ......................... SUCCESS [  0.115 s]
[INFO] Esper Examples - CycleDetect ....................... SUCCESS [  0.194 s]
[INFO] Esper Examples - MarketDataFeed .................... SUCCESS [  0.087 s]
[INFO] Esper Examples - MatchMaker ........................ SUCCESS [  0.075 s]
[INFO] Esper Examples - NamedWinQuery ..................... SUCCESS [  0.057 s]
[INFO] Esper Examples - OHLCPlugInView .................... SUCCESS [  0.066 s]
[INFO] Esper Examples - QualityOfServiceSLA ............... SUCCESS [  0.197 s]
[INFO] Esper Examples - RFIDAssetZone ..................... SUCCESS [  0.137 s]
[INFO] Esper Examples - RuntimeConfig ..................... SUCCESS [  0.055 s]
[INFO] Esper Examples - ServerShell ....................... SUCCESS [  0.068 s]
[INFO] Esper Examples - StockTicker ....................... SUCCESS [  0.115 s]
[INFO] Esper Examples TerminalSvc - Common ................ SUCCESS [  0.408 s]
[INFO] Esper Examples TerminalSvc - Receiver .............. SUCCESS [  0.033 s]
[INFO] Esper Examples TerminalSvc - Sender ................ SUCCESS [  0.036 s]
[INFO] Esper Examples TerminalSvc - MDB ................... SUCCESS [  0.752 s]
[INFO] Esper Examples TerminalSvc - EAR ................... FAILURE [  0.060 s]
[INFO] Esper Examples TerminalSvc ......................... SKIPPED
[INFO] Esper Examples - TerminalServiceJSE ................ SKIPPED
[INFO] Esper Examples - Transaction ....................... SKIPPED
[INFO] Esper Examples - Trivia Geeks Club ................. SKIPPED
[INFO] Esper .............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.419 s
[INFO] Finished at: 2016-01-12T14:53:06-08:00
[INFO] Final Memory: 59M/776M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project example-terminalsvc-ear: Could not resolve dependencies for project com.espertech:example-terminalsvc-ear:ear:1.0: Could not transfer artifact com.espertech:example-terminalsvc-mdb:jar:1.0 from/to local-repository (~/.m2/repository): Cannot access ~/.m2/repository with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access ~/.m2/repository using the registered transporter factories: WagonTransporterFactory: Unsupported transport protocol -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :example-terminalsvc-ear

It may be that I'm missing a step here; however, I see no mention of this in the documentation.

"Output after time_period" with external timer

In my scenario the output โ€œafter time_periodโ€ option does not work with external timer.
The statement
EPStatement cepStatement3a = cepAdm_.createEPL(
" insert into stream1 " +
" select minby(bid).bid as ibid , " +
" minby(bid).dtBid.getMillis() as idbid , " +
" maxby(bid).bid as abid , " +
" maxby(bid).dtBid.getMillis() as adbid , " +
" current_timestamp as ts , " +
" 'win1' as winsize " +
" from StockTick.win:time(60 sec) " +
// " output snapshot every 10 sec " +
// " output after 100 events snapshot every 10 sec " +
" output after 60 sec snapshot every 10 sec " +
works without "after option" and with option โ€œafter n events"
With option โ€œafter 60 secโ€ no event is produced

Using java method with SELECT ... GROUP BY produces duplicated events.

In SELECT ... GROUP BY statement, if I use java method in SELECT clause, Esper produces resulting events for each incoming events. I expect one event produced for each group.

For example, I registered following query.

select str, str.split(',')as splitted, count(*) as cnt from 

and send this event 5 times.

{"str": "a,b,c"}

Then, I get 5 events.

{str=a,b,c, splitted=[Ljava.lang.String;@5c4e50a5, cnt=5}
{str=a,b,c, splitted=[Ljava.lang.String;@7bb01550, cnt=5}
{str=a,b,c, splitted=[Ljava.lang.String;@1c2181ce, cnt=5}
{str=a,b,c, splitted=[Ljava.lang.String;@21a417fc, cnt=5}
{str=a,b,c, splitted=[Ljava.lang.String;@f41b015, cnt=5}

Is this expected behavior? How can I get just one event for each group?

Check that a property on an EventBean exists

Some of my EPL statements use window(*). In the EventListener in update(...) I'd like to check newEvents to see if any of them have that property, using for example newEvents[0].get("window(*)"). But if this the property, in my case window(*), doesn't exist then EventBean will throw a PropertyAccessException.

What do you think about adding a doesPropertyExist(String property) method to EventBean? I'm happy to do this if you think it's a good idea. But maybe I should be approaching this problem from another direction.

referencing window in context declared in different EPL module

In Esper 5.1, when I refer to a window within a context, where the window has been declared in another module (and without context) I get the following error:

Caused by: com.espertech.esper.epl.expression.core.ExprValidationException: Cannot create on-trigger expression: Named window 'TheWindow' was declared with context 'null', please use the same context instead

The EPL is:
context ContextA on pattern [ OtherEvent ] insert into SomeEvent select * from TheWindow;

That should be possible according to the doc at 4.6 saying
Named windows are globally-visible data window that may be referred to by multiple statements. You may refer to named windows in statements that declare a context without any special considerations.

When I change the EPL without the on-trigger expression, then the expression compiles, e.g.
context ContextA insert into SomeEvent select tw.* from TheWindow tw, pattern [timer:interval(0)] unidirectional;

NullPointerException for filter with global expression in context-partitioned stmt

Version: 5.2.0

When the EPAdministrator attempts to parse a statement that refers to a declared context and contains one or more aliases to a global expression, a NullPointerException is thrown with the following stack-trace:

at com.espertech.esper.core.context.mgr.ContextPropertyRegistryImpl.isContextPropertyPrefix(ContextPropertyRegistryImpl.java:57)
      at com.espertech.esper.epl.declexpr.ExprDeclaredNodeImpl.<init>(ExprDeclaredNodeImpl.java:68)
      at com.espertech.esper.epl.declexpr.ExprDeclaredHelper.getExistsDeclaredExpr(ExprDeclaredHelper.java:37)
      at com.espertech.esper.epl.parse.EPLTreeWalkerListener.exitEventProperty(EPLTreeWalkerListener.java:1443)
      at com.espertech.esper.epl.generated.EsperEPL2GrammarParser$EventPropertyContext.exitRule(EsperEPL2GrammarParser.java:17573)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.exitRule(ParseTreeWalker.java:71)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:54)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
      ...
      at com.espertech.esper.epl.parse.ParseHelper.walk(ParseHelper.java:56)
      at com.espertech.esper.core.service.EPAdministratorHelper.compileEPL(EPAdministratorHelper.java:108)
      at com.espertech.esper.core.service.EPAdministratorHelper.compileEPL(EPAdministratorHelper.java:72)
      at com.espertech.esper.core.service.EPAdministratorImpl.createEPLStmt(EPAdministratorImpl.java:116)
      at com.espertech.esper.core.service.EPAdministratorImpl.createEPL(EPAdministratorImpl.java:66)

For example, say I have the following statements:

Global Expression:
create expression TESTEXPR alias for {a='foo' and b='bar'}

Context Declaration:

create context context1 
    initiated @now and pattern[every(TestEvent(TESTEXPR))] 
    terminated after 10 minutes

Statement referring to Context Declaration and Global Expression:

context context1 
select * from pattern[every(e1=TestEvent(TESTEXPR) -> e2=TestEvent(a='hello'))]

The engine will fail to parse the third statement and will throw the error shown above. This will happen regardless of whether or not the context declaration contains an alias to a global expression. Iโ€™ve included a test class below that replicates the issue:

import static org.junit.Assert.assertEquals;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.espertech.esper.client.Configuration;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.UpdateListener;

public class EsperContextTest {

      private EPServiceProvider epServiceProvider;
      private TestEvent[] events;

      @Before
      public void setUp() throws Exception {

            // Configure EPServiceProvider
            Configuration config = new Configuration();
            config.addEventType("TestEvent", TestEvent.class);
            config.getEngineDefaults().getExecution().setPrioritized(true);
            config.getEngineDefaults().getLogging().setEnableExecutionDebug(false);
            config.getEngineDefaults().getLogging().setEnableQueryPlan(false);
            config.getEngineDefaults().getLogging().setEnableTimerDebug(false);
            config.getEngineDefaults().getMetricsReporting()
                        .setEnableMetricsReporting(false);
            epServiceProvider = EPServiceProviderManager.getDefaultProvider(config);

            // Add global Expression
            epServiceProvider.getEPAdministrator().createEPL(
                        "create expression TESTEXPR alias for {a='foo' and b='bar'}");

            // Test Events
            TestEvent e1 = new TestEvent("fizz", "bang", "buzz");
            TestEvent e2 = new TestEvent("foo", "bar", "buzz");
            TestEvent e3 = new TestEvent("hello", "world", "foo");

            events = new TestEvent[] { e1, e2, e3 };

      }

      // Test context declaration and statement w/ no global expression aliases (passes)
      @Test
      public void testNoGlobalExpressions() {
            String context = "create context context1 initiated @now and pattern[every(TestEvent(a='foo' and b='bar'))] terminated after 10 minutes";
            String statement = "context context1 select * from pattern[every(e1=TestEvent(a='foo' and b='bar') -> e2=TestEvent(a='hello'))]";
            createContextAndStatement(context, statement);
            sendEvents();
      }

      // Test context declaration and statement w/ global expression aliases (fails)
      @Test
      public void testGlobalExpressions() {
            String context = "create context context2 initiated @now and pattern[every(TestEvent(TESTEXPR))] terminated after 10 minutes";
            String statement = "context context2 select * from pattern[every(e1=TestEvent(TESTEXPR) -> e2=TestEvent(a='hello'))]";
            createContextAndStatement(context, statement);
            sendEvents();
      }

      // Test context declaration w/ global expression alias and statement w/ no
      // global expression alias (passes)
      @Test
      public void testContextGlobalExpression() {
            String context = "create context context2 initiated @now and pattern[every(TestEvent(TESTEXPR))] terminated after 10 minutes";
            String statement = "context context2 select * from pattern[every(e1=TestEvent(a='foo' and b='bar') -> e2=TestEvent(a='hello'))]";
            createContextAndStatement(context, statement);
            sendEvents();
      }

      // Test context declaration w/ no global expression alias and statement w/
      // global expression alias (fails)
      @Test
      public void testStatementGlobalExpressions() {
            String context = "create context context1 initiated @now and pattern[every(TestEvent(a='foo' and b='bar'))] terminated after 10 minutes";
            String statement = "context context1 select * from pattern[every(e1=TestEvent(TESTEXPR) -> e2=TestEvent(a='hello'))]";
            createContextAndStatement(context, statement);
            sendEvents();
      }

      // Add statement w/ corresponding context partition to the Esper engine.
      private void createContextAndStatement(String context, String statement) {
            epServiceProvider.getEPAdministrator().createEPL(context);
            epServiceProvider.getEPAdministrator().createEPL(statement)
                        .addListener(new TestListener());
      }

      // Send events to Esper engine
      private void sendEvents() {
            for (TestEvent event : events) {
                  epServiceProvider.getEPRuntime().sendEvent(event);
            }
      }

      // Reset EPServiceProvider for each test
      @After
      public void reset() {
            epServiceProvider.destroy();
      }

      private static class TestEvent {

            private String a;

            private String b;

            private String c;

            public TestEvent(String a, String b, String c) {
                  this.a = a;
                  this.b = b;
                  this.c = c;
            }

            public String getA() {
                  return a;
            }

            public void setA(String a) {
                  this.a = a;
            }

            public String getB() {
                  return b;
            }

            public void setB(String b) {
                  this.b = b;
            }

            public String getC() {
                  return c;
            }

            public void setC(String c) {
                  this.c = c;
            }

            public String toString() {
                  return "(" + a + "," + b + "," + c + ")";
            }
      }

      private static class TestListener implements UpdateListener {

            @Override
            public void update(EventBean[] newEvents, EventBean[] oldEvents) {
                  EventBean event = newEvents[0];
                  TestEvent e1 = (TestEvent) event.get("e1");
                  TestEvent e2 = (TestEvent) event.get("e2");

                  assertEquals(e1.toString(), "(foo,bar,buzz)");
                  assertEquals(e2.toString(), "(hello,world,foo)");
            }
      }

}

Thanks

CSV Input Adapter with immutable events

According to Esper IO documentation (http://www.espertech.com/esper/release-5.2.0/esperio-reference/html/adapter_file.html#csv-step-1) the CSVInputAdapter can only handle POJO events.

It would be nice to be able to use Immutable Objects (with final fields, Constructior and getter only).

Example:

private final BigDecimal open;
private final BigDecimal high;
private final BigDecimal low;
private final BigDecimal close;

public BarVO(BigDecimal open, BigDecimal high, BigDecimal low, BigDecimal close) {
    this.open = open;
    this.high = high;
    this.low = low;
    this.close = close;
}

Java8 lambdas and streams

Is there planned support for Java 8 lambda syntax and streams inside Esper? Or do you think the Enumeration Methods currently supported in Esper already fulfill that exact purpose?

It could be pretty powerful to expose a Stream<ValueObject> in Esper which is then queriable via normal stream methods such as:

insert into OutputEvent
select * from UpdateEvent
where trackerVariable.stream().filter(p -> p.getValue() > 10);

but I realise this is kind of in conflict with the Enumeration Methods.

NPE when accessing table from expression

When running the following class:

import com.espertech.esper.client.EPRuntime;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.deploy.DeploymentException;
import com.espertech.esper.client.deploy.Module;
import com.espertech.esper.client.deploy.ParseException;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class EsperBreaker {
    public static void main(String ... args) throws ParseException, DeploymentException, IOException {
        EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
        EPRuntime runtime = epService.getEPRuntime();

        Module module = epService.getEPAdministrator().getDeploymentAdmin().parse(
                "create schema OrderIssue(id string, instrumentId string);\n" +
                "create window Positions.win:keepall() as (id string, instrumentId string, instrumentName string);\n" +
                "create table Instruments(id string primary key, name string);\n" +
                "create expression getInstrumentName {o => Instruments[o.instrumentId].name};\n" +
                "on OrderIssue oi\n" +
                "insert into Positions(id, instrumentId, instrumentName)\n" +
                "    select id, instrumentId, getInstrumentName(oi);"
        );
        epService.getEPAdministrator().getDeploymentAdmin().deploy(module, null);

        runtime.executeQuery("insert into Instruments(id, name) values ('1', 'EUR/USD')");

        Map<String, Object> orderIssue = new HashMap<>();
        orderIssue.put("id", "1");
        orderIssue.put("instrumentId", "1");
        runtime.sendEvent(orderIssue, "OrderIssue");
    }
}

NPE is thrown:

ERROR c.e.e.c.s.ExceptionHandlingService - Exception encountered processing statement '1de7f8ec-b203-40e8-8a94-1b6980214948' statement text 'on OrderIssue oi
insert into Positions(id, instrumentId, instrumentName)
    select id, instrumentId, getInstrumentName(oi)' : null
java.lang.NullPointerException: null
    at com.espertech.esper.epl.expression.table.ExprTableAccessNodeSubprop.evaluate(ExprTableAccessNodeSubprop.java:78) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.declexpr.ExprDeclaredEvalBase.evaluate(ExprDeclaredEvalBase.java:84) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.core.eval.EvalBaseMap.process(EvalBaseMap.java:48) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.core.SelectExprResultProcessor.process(SelectExprResultProcessor.java:65) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.core.ResultSetProcessorHandThrough.getSelectEventsNoHaving(ResultSetProcessorHandThrough.java:99) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.epl.core.ResultSetProcessorHandThrough.processViewResult(ResultSetProcessorHandThrough.java:72) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.view.internal.RouteResultViewHandlerFirst.handle(RouteResultViewHandlerFirst.java:91) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.view.internal.RouteResultView.update(RouteResultView.java:84) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.view.ZeroDepthStreamNoIterate.insert(ZeroDepthStreamNoIterate.java:50) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.core.context.activator.ViewableActivatorFilterProxy$2.matchFound(ViewableActivatorFilterProxy.java:101) ~[esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterSingle(EPRuntimeImpl.java:1245) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processMatches(EPRuntimeImpl.java:1031) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.processWrappedEvent(EPRuntimeImpl.java:482) [esper-5.2.0.jar:na]
    at com.espertech.esper.core.service.EPRuntimeImpl.sendEvent(EPRuntimeImpl.java:286) [esper-5.2.0.jar:na]
    at EsperBreaker.main(EsperBreaker.java:34) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]

But if you substitute internals of the expression for its invocation, then everything go OK.

prepared statement alters pattern definition

I have the following prepared statement:

select * from pattern [every a=A -> (timer:at(?, *, *, *, 1:5) and not A)]

Once it is deployed its definition is changed to the following

select * from pattern [every a=A -> timer:at(?, *, *, *, 1:5) and not A]

Since the brackets have been removed it now has a different semantic.

see test class below:

public static void main(String[] args) throws InterruptedException {

    Configuration config = new Configuration();
    config.addEventType(A.class);

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);

    String epl = "select * from pattern [every a=A -> (timer:at(?, *, *, *, 1:5) and not A)]";

    EPPreparedStatement prepared = epService.getEPAdministrator().prepareEPL(epl);
    prepared.setObject(1, 0);

    EPStatementImpl statement = (EPStatementImpl) epService.getEPAdministrator().create(prepared);
    String newEpl = statement.getStatementContext().getEpStatementHandle().getEPL();
    System.out.println(newEpl);

    epService.getEPRuntime().sendEvent(new A());

    epService.destroy();
}

public static class A {
}

Context Inserting a Null event when used with time windows.

Hello,

I think I found a bug when trying to use context, time windows, and the window function. For some reason, the engine is inserting a NULL event after events leave the window function. For example, take the following EPLs:

String ctx = "CREATE CONTEXT Cell PARTITION BY x AND y FROM A";

String bugEPL = " CONTEXT Cell"
              + " INSERT INTO B"
              + " SELECT x AS x, y AS y, window(*) AS composite "
              + " FROM A.win:time(5 sec)";

String outEPL = " SELECT istream * FROM B";

When I insert the following events: A(1337, 1337, "Loop#1"), A(1337, 1337, "Loop#2") and sleep for a period over 5 seconds, the engine will output a NULL event to B. Precisely, if we print the incoming output of outEPL it will be:

Output:
Listener Call (Incoming Event)!
B (1337,1337): 1
Listener Call (Incoming Event)!
B (1337,1337): 2
Listener Call (Incoming Event)!
B (1337,1337): NULL ARRAY

Rather than the expected:

Expected Output:
Listener Call (Incoming Event)!
B (1337,1337): 1
Listener Call (Incoming Event)!
B (1337,1337): 2

Am I missing something, misusing the window function or there is an issue here?

Thanks in advance,
Marcos Roriz

MinimumWorkingExample.java

import com.espertech.esper.client.Configuration;
import com.espertech.esper.client.EPServiceProvider;
import com.espertech.esper.client.EPServiceProviderManager;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.UpdateListener;

public class MinimumWorkingExample {

    /** CEP Engine. */
    private EPServiceProvider cepEngine;

    public static void main(String[] args) throws Exception {
        MinimumWorkingExample mwe = new MinimumWorkingExample();
        mwe.setupCEP();
        mwe.reproduceBUG();
    }

    private void reproduceBUG() throws Exception {
        // Context indentifiers
        int x = 1337;
        int y = 1337;

        // Sending 2 events 
        for (int i = 0; i < 2; i++) {
            cepEngine.getEPRuntime().sendEvent(new A(x, y, "Loop #" + i));    
        }

        // Sleep > 5 seconds       
        Thread.sleep(6000);

        System.exit(0);
    }

    public void setupCEP() {
        // CEP Config
        Configuration cepConfig = new Configuration();
        cepConfig.addEventType("A", A.class.getName());
        cepConfig.addEventType("B", B.class.getName());

        // CEP
        cepEngine = EPServiceProviderManager.getProvider("ESPER", cepConfig);

        // EPL
        String ctx = "CREATE CONTEXT Cell PARTITION BY x AND y FROM A";

        String bugEPL = " CONTEXT Cell"
                      + " INSERT INTO B"
                      + " SELECT x AS x, y AS y, window(*) AS composite "
                      + " FROM A.win:time(5 sec)";

        String outEPL = " SELECT istream * FROM B";

        // Create EPLs
        cepEngine.getEPAdministrator().createEPL(ctx);
        cepEngine.getEPAdministrator().createEPL(bugEPL);
        cepEngine.getEPAdministrator().createEPL(outEPL).addListener(new MWEListener());
    }

    /** Listener Class. */
    public class MWEListener implements UpdateListener {

        @Override
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            if (newEvents != null) {
                System.out.println("Listener Call (Incoming Event)!");
                for (EventBean eb : newEvents) {
                    System.out.println(eb.getUnderlying());
                }
            }
        }
    }

    /** Event Class. */
    public class A {
        private int x;
        private int y;
        private String data;

        // No-arg constructor (reflection)
        public A() {}

        public A(int x, int y, String data) {
            this.x = x;
            this.y = y;
            this.data = data;
        }

        @Override
        public String toString() {
            return "A (" + x + "," + y +"): " + data;
        }

        // Gets and Sets
        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public String getData() {
            return data;
        }

        public void setX(int x) {
            this.x = x;
        }

        public void setY(int y) { 
            this.y = y;
        }

        public void setData(String data) {
            this.data = data;
        }
    }

    public class B {
        private int x;
        private int y;
        private A[] composite;

        // No-arg constructor (reflection)
        public B() {}

        public B(int x, int y, A[] dataComposite) {
            this.x = x;
            this.y = y;
            this.composite = dataComposite;
        }

        @Override
        public String toString() {
            if (composite != null) {
                return "B (" + x + "," + y +"): " + composite.length;
            } else {
                return "B (" + x + "," + y +"): NULL ARRAY";
            }
        }

        // Gets and Sets
        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public A[] getComposite() {
            return composite;
        }

        public void setX(int x) {
            this.x = x;
        }

        public void setY(int y) {
            this.y = y;
        }

        public void setComposite(A[] composite) {
            this.composite = composite;
        }
    }

}

Incorrect result for aggregation when multiple agg functions in same statement each take a declared expression as parameters and

One of our users reported to me that two expression-based columns in an Esper 5.3.0 query were producing identical values when the values should have been quite different. When one column was commented out, the remaining column produced the expected values, but when both were present, the second column contained the same value as the first.

In this case, the two columns each contain a sum aggregation. The operands of these sum aggregates are structurally similar, except that each one invokes a different lambda function. The lambdas themselves are structurally similar, but not equivalent.

A simplified example is as follows:

expression lambda1 { o => 1 * o.someValue } 
expression lambda2 { o => 3 * o.someValue } 

select sum(lambda1(e)) as value1
     , sum(lambda2(e)) as value2
  from SomeEvent as e

Given the query above, we expect value1 and value2 to contain 100 and 300 for an event having someValue = 100. But Esper produces the same result for both:

value1 value2
100 100

Esper has apparently determined that sum(lambda2(e)) is equivalent to sum(lambda1(e)) and substituted it in an attempt to reduce the number of aggregations computed. Clearly, these expressions are not equivalent.

We can work around this by tweaking the structure of the sum operand for value2 such that Esper no longer considers them equivalent. For example, we can add 0 to the original operand:

expression lambda1 { o => 1 * o.someValue } 
expression lambda2 { o => 3 * o.someValue } 

select sum(lambda1(e)) as value1
     , sum(lambda2(e) + 0) as value2
  from SomeEvent as e

The results for this query are what we expected to see for the first query. Since Esper no longer incorrectly considers the two sum aggregations equivalent, we get the correct results:

value1 value2
100 300

BigDecimal divide without MathContext

Hi

Unfortunately there are still three occurrences in Esper 5.2.0 where BidDecimal.divide is used without a MathContext which leads to

java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.

These are the locations:

  • com.espertech.esper.epl.agg.aggregator.AggregatorAvgBigDecimal (line 88)
  • com.espertech.esper.type.MathArithTypeEnum (line 501 and 770)

This is an example stack trace:

java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
    at java.math.BigDecimal.divide(BigDecimal.java:1690)
    at com.espertech.esper.type.MathArithTypeEnum$DivideBigDecConvComputer.compute(MathArithTypeEnum.java:770)
    at com.espertech.esper.epl.expression.ops.ExprMathNode.evaluate(ExprMathNode.java:141)
    at com.espertech.esper.epl.core.SelectExprInsertEventBeanFactory$SelectExprInsertNativeWidening.process(SelectExprInsertEventBeanFactory.java:615)
    at com.espertech.esper.epl.core.SelectExprResultProcessor.process(SelectExprResultProcessor.java:58)
    at com.espertech.esper.epl.core.ResultSetProcessorAggregateGrouped.generateOutputEventsView(ResultSetProcessorAggregateGrouped.java:248)
    at com.espertech.esper.epl.core.ResultSetProcessorAggregateGrouped.processViewResult(ResultSetProcessorAggregateGrouped.java:204)
    at com.espertech.esper.epl.view.OutputProcessViewDirect.update(OutputProcessViewDirect.java:48)
    at com.espertech.esper.view.ZeroDepthStreamNoIterate.insert(ZeroDepthStreamNoIterate.java:50)
    at com.espertech.esper.core.context.activator.ViewableActivatorPattern$1.matchFound(ViewableActivatorPattern.java:55)
    at com.espertech.esper.pattern.EvalRootStateNode.evaluateTrue(EvalRootStateNode.java:103)
    at com.espertech.esper.pattern.EvalFollowedByStateNode.evaluateTrue(EvalFollowedByStateNode.java:87)
    at com.espertech.esper.pattern.EvalAndStateNode.evaluateTrue(EvalAndStateNode.java:186)
    at com.espertech.esper.pattern.EvalEveryStateNode.evaluateTrue(EvalEveryStateNode.java:146)
    at com.espertech.esper.pattern.EvalFilterStateNode.evaluateTrue(EvalFilterStateNode.java:80)
    at com.espertech.esper.pattern.EvalFilterStateNode.matchFound(EvalFilterStateNode.java:134)
    at com.espertech.esper.core.service.EPRuntimeImpl.processStatementFilterMultiple(EPRuntimeImpl.java:1235)
    at com.espertech.esper.core.service.EPRuntimeImpl.processMatches(EPRuntimeImpl.java:1070)

Thanks
Andy

output first(n)

For output suppression Esper allows use of
group by output first every
which gives instant output for the first unique event, and throttles to maximum of 1 every

Issue created to support first(n), to allow more than 1 instant output every

TestEvent with two properties (id1,id2):
== event feed ==
insertEvent A1 = TestEvent("A","1")
incrementTimeBy(1 sec)
insertEvent A2 = TestEvent("A","2")
incrementTimeBy(1 sec)
insertEvent A3 = TestEvent("A","3")
incrementTimeBy(1 sec)

insertEvent B1 = TestEvent("B","1")
incrementTimeBy(1 sec)
insertEvent B2 = TestEvent("B","2")
incrementTimeBy(1 sec)
insertEvent B3 = TestEvent("B","3")
incrementTimeBy(1 hour)

insertEvent A4 = TestEvent("A","4")
incrementTimeBy(1 sec)
insertEvent B4 = TestEvent("B","4")
incrementTimeBy(1 hour)
== event feed end ==

The statement
"select * from TestEvent() group by id1 output first every 1 hour"

results in
== begin ==
TEST_Listener - 0 seconds later, listener called with 1 event(s)
TEST_Listener - * A1
TEST_Listener - 3 seconds later, listener called with 1 event(s)
TEST_Listener - * B1
TEST_Listener - 3605 seconds later, listener called with 1 event(s)
TEST_Listener - * A4
TEST_Listener - 3606 seconds later, listener called with 1 event(s)
TEST_Listener - * B4
== end ==

i.e an instant listener call to the for the first event for each id1 groupby.

Would like to add support for the statement
"select * from TestEvent() group by id1 output first(2) every 1 hour"

which should result in
== begin ==
TEST_Listener - 0 seconds later, listener called with 1 event(s)
TEST_Listener - * A1
TEST_Listener - 1 seconds later, listener called with 1 event(s)
TEST_Listener - * A2
TEST_Listener - 3 seconds later, listener called with 1 event(s)
TEST_Listener - * B1
TEST_Listener - 4 seconds later, listener called with 1 event(s)
TEST_Listener - * B2
TEST_Listener - 3605 seconds later, listener called with 1 event(s)
TEST_Listener - * A4
TEST_Listener - 3606 seconds later, listener called with 1 event(s)
TEST_Listener - * B4
== end ==

ExprConcatNode not threadsafe

When releasing an event that has gone to multiple contexts (by hash) the same ExprConcatNode instance is called from multiple threads. Updates to the StringBuffer (instance field) can then trample on one another.

See PR: #22

variable method invocation threading issue

Hi

Invoking methods on variables based on events that are sent from a different thread does not work.

Please see Java test case below.

Thanks

@Test
public void testThreadingWithVariables() throws Exception {

    Configuration config = new Configuration();
    config.addEventType("Signal", Signal.class);
    config.addVariable("stuffDoer", StuffDoer.class, null);

    final EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    final EPRuntime epRuntime = epService.getEPRuntime();

    StuffDoer stuffDoer = new StuffDoer();
    epRuntime.setVariableValue("stuffDoer", stuffDoer);

    EPAdministrator epAdministrator = epService.getEPAdministrator();

    EPStatement epStatement = epAdministrator.createEPL("select stuffDoer.doStuff() as value from Signal");

    final CountDownLatch latch = new CountDownLatch(2);
    final List<Double> values = new ArrayList<Double>();

    epStatement.setSubscriber(new Object() {

        public void update(final Map<?, ?> event) {

            System.out.println(event);

            Double value = (Double) event.get("value");
            values.add(value);
            latch.countDown();
        }

    });

    epRuntime.sendEvent(new Signal());

    // Test passes when sending events from the same thread
    //         epRuntime.sendEvent(new Signal());

    // and fails if events are sent from a different thread
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    executorService.execute(new Runnable() {
        public void run() {
            epRuntime.sendEvent(new Signal());
        }
    });

    latch.await();

    Assert.assertEquals(2, values.size());
    Assert.assertNotNull(values.get(0));
    Assert.assertNotNull(values.get(1));

    if (epService != null) {
        epService.destroy();
    }
}

static public class StuffDoer {

    public Double doStuff() {
        return 3.0;
    }

}

static public class Signal {

}

Help needed with a query and user defined function in Esper

I am trying to create an EPL statement that will show whether an order is possible or not.

There are two Events, EventA(processed) and EventB(non processed).

create schema EventA(type string, percentCompleted integer);
create schema EventB(type string);

The statement should match all processed elements, based on the type(string) of the element. The result should contain a Boolean value, which indicates whether an order should be processed or not.

I have got the statement below to return true when a successful match is made(and an order can be placed). However, I would also like to return a false when an order can not be placed.

Case tested here:
http://esper-epl-tryout.appspot.com/epltryout/mainform.html

create schema EventA(type string, percentCompleted integer);
create schema EventB(type string);

@name('Out') select * from pattern [every a=EventA -> every b=EventB(a.type = b.type AND a.percentCompleted > 20) ]
Sequence:

EventA={type="1",percentCompleted=0}
EventA={type="2",percentCompleted=0}
EventA={type="1",percentCompleted=20}
EventA={type="1",percentCompleted=40}
EventB={type="1"}
Result: (Only returns a true result):

Out-output={a={EventA={type='1', percentCompleted=40}}, b={EventB={type='1'}}}
I want my statement to return TRUE and "type" instead of the whole result, and also I want the query to return FALSE and "type" when a.percentCompleted < 20.

User defined functions with varargs not recognized

I am not able to use a user defined function with a variable number of arguments (called from EPL). I get:

com.espertech.esper.client.EPStatementException: Error starting statement: Failed to validate select-clause expression 'MapUtils.combine(l.extra,...(70 chars)': Failed to resolve 'MapUtils.combine' to a property, single-row function, aggregation function, script, stream or class name

The function I am calling is:

public static Map<String, String> combine(final Map<String, String> ...maps) { 
    Map<String, String> result = new HashMap<String, String>(); 
    for (Map<String, String> map: maps) { 
        if (map != null) { 
            result.putAll(map); 
        } 
    } 
    return result; 
} 

If OTOH I use this function instead:

public static Map<String, String> combine2(final Map<String, String> map1, 
                                           final Map<String, String> map2) { 
    return combine(map1, map2); 
} 

Esper is happy.

ESPER LIKE QUERY - CASE SENSITIVE

ESPER EPL LIKE QUERY IS CASE SENSITIVE. HOW DO I SOLVE IT. EX - select * from StockTick having symbol like '%YHOO%' . EVENTS HAVE SYMBOL AS 'yhoo'. GUYS SUGGEST. MANY THANKS

Can't use enum named 'NEW'

(issue migrated from http://jira.codehaus.org/browse/ESPER-812)

When using an imported enum which has an enum field called "NEW" then Esper does not parse the EPL code correctly. E.g. for the following on-expression:
on ExecutionEvent(status=ExecutionEventStatus.NEW) t
insert into AEvent
select t.status;
causes this exception:
"Caused by: com.espertech.esper.client.EPStatementSyntaxException: Incorrect syntax near 'NEW' (a reserved keyword) at line 1 column 46, please check the filter specification [on ExecutionEvent(status=ExecutionEventStatus.NEW) t"
This is tested on Esper 5.2.

Using PortfolioService methods from epl statements

Hi

I'm trying to use the following method inside an epl statement
method: portfolioService.getNetLiqValueDouble()

The problem is that i get the following error - " Ambiguous method name: method by name 'getNetLiqValueDouble' is overloaded in class 'ch.algotrader.service.PortfolioService' "

I did notice that there's an overloading on that method (one without parameters and one with a string) but i'm using the method without parameters and it does work within the java code (just not in the epl statement)

Does anyone know the reason for that error ?

Thanks in advance,
Shlomi

Cannot use reserved words as part of a property chain

I have a class named "GROUP" with constants. I am trying to get something like "select GROUP.FOO as bar ..." working but I always get an error.

With:

`GROUP`.FOO as bar

I get:

Failed to validate select-clause expression '`GROUP`.FOO': Failed to resolve property '`GROUP`.FOO' to a stream or nested property in a stream

With:

`GROUP.FOO` as bar

I get:

Failed to validate select-clause expression 'GROUP.FOO': Property named 'GROUP.FOO' is not valid in any stream".

This seems to be the same problem as ESPER-686 (http://esper.13850.n7.nabble.com/jira-ESPER-686-Cannot-use-reserved-words-as-part-of-a-property-chain-td6666.html).

I am using Esper 5.3.0.

Subscriber multi-row delivery on named window not allowing typed array footprint

(issue migrated from http://jira.codehaus.org/browse/ESPER-811)

Multi-Row Delivery from Named Window according to the documentation chapter "15.3.3.2.1. Wildcards" causes:
Subscriber method named 'update' for parameter number 1 is not assignable, expecting type 'MarketData' but found type 'MarketData[]'
when using
select * from MarketDataWin
to make it work one has to use:
select stream_0 from MarketDataWin
However the usage of "stream_0" is not mentioned anywhere in the documentation and should probably be added.
See attached test class at https://www.dropbox.com/s/9v6p7kp09514ga4/MultiRowDeliveryTest.java?dl=0

`mvn install` fails with "error: unmappable character for encoding UTF8"

I clone the repository and checkout master (currently the same as the 'release_5.3.0' tag).

When I run mvn install -e -X I get:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.3", arch: "x86_64", family: "mac"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG]   Imported: javax.enterprise.inject.* < plexus.core
[DEBUG]   Imported: javax.enterprise.util.* < plexus.core
[DEBUG]   Imported: javax.inject.* < plexus.core
[DEBUG]   Imported: org.apache.maven.* < plexus.core

(...I removed many intermediate lines...)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.959 s
[INFO] Finished at: 2016-01-12T13:26:13-08:00
[INFO] Final Memory: 15M/437M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project esper: Compilation failure
[ERROR] /Groups/dev/src/github/espertechinc/esper/esper/src/main/java/com/espertech/esper/epl/approx/CountMinSketchStateHashes.java:[20,8] error: unmappable character for encoding UTF8
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project esper: Compilation failure
/Groups/dev/src/github/espertechinc/esper/esper/src/main/java/com/espertech/esper/epl/approx/CountMinSketchStateHashes.java:[20,8] error: unmappable character for encoding UTF8


    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
/Groups/dev/src/github/espertechinc/esper/esper/src/main/java/com/espertech/esper/epl/approx/CountMinSketchStateHashes.java:[20,8] error: unmappable character for encoding UTF8


    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Is this OK? GPLv2ed project include Apache2.0 Licensed library

If my memory is correct, Apache 2.0 License is not compatible with GNU GPL version 2.
http://www.gnu.org/licenses/license-list.en.html#apache2

I read esper_3rdparties.license text, And I understood like this:

Esper[GPLv2] <-> Apache Commons Logging(etc...)[Apache 2.0]
            ^^^
         Can't linking legally

However, Apache 2.0 is compatible with GPLv3.
So copyright holder switch GPLed source code to GPLv3 (or GPLv2+),
And distribute larger-work under the GPLv3, this problem will solve quickly.

If you think it's not a problem leglly, please close this issue.

Suggestion: update the build documentation and add automated builds to keep an eye on it

I've found that the Building Esper documentation could be improved. When a project doesn't easily build and the documentation doesn't help, it leads to a bad developer experience.

I'm working my way through getting Esper's project-root maven build to work. As a minimal starting point, this is what I'm currently using:

mvn -DskipTests -Dgpg.skip=true install

I'd suggest this be added to the Esper documentation.

Also, I found in #34 that the build did not succeed for the current master.

Perhaps this situation could be improved by adding an automated build?

Documentation Error

4.2.3.3. Built-In Context Properties

The following context properties are available in your EPL statement when it refers to a keyed segmented context:

Table 4.2. Keyed Segmented Context Properties

I think in this part of documentation reference to keyed segmented context is wrong. It should be hash segmented context.

issue with context

Hi,

I am using context by hash something like below.

create context HashedByUserId as coalesce consistent_hash(userId) from templateEvent granularity 240 preallocate

and i have around 100 queries like

context HashedByUserId select userId from templateEvent(feature in('a','b','c')) where isCheckMet(1234);
context HashedByUserId select userId from templateEvent(feature in('a1','b1','c1')) where isCheckMet(2222);
context HashedByUserId select userId from templateEvent(feature in('a','b','c')) where isCheckMet(3333);
context HashedByUserId select userId from templateEvent(feature in('a1','b1','c1')) where isCheckMet(4444);

and so on....... where every Query has a unique identifier passed to isCheckMet();

what we have noticed here is , when i do sendEvent(templateEvent) to esper engine, its executing around 240 times each of my 100 Queries.

thus i am getting isCheckMet() called 240 times for id 1234.
same for other event ids as well.

If i change this granularity from 240 value to 300 , single query gets executed 300 times.
Can you please tell what could be wrong in context here?

I have tried putting granularity as 1 , it worked fine and query gets executed only once, but with this i am loosing parallel processing.

Note: consistent_hash(userId) is the hasking we are using which return an int value using consistent hashing algorithm

Thanks

Dataflow operator argument set via setter method does not allow expressions or variables

For ESPER 5.5.0 (environment doesn't matter, it is problem with implementation)

The evaluation implementation of variables (ExprVariableNodeImpl) is not provided an ExprEvaluatorContext. For expressions (ExprDeclaredNodeImpl), the error occurs in PopulateUtils.coerceProperty since the node does not have an expression evaluator and dies there.

This contradicts the provided documentation.

CREATE variable int var_int = 1

MyVariable ....
CREATE DATAFLOW MyDataflow
  MyOp: { 
    arg1: var_int 
  }

A null pointer exception is thrown:

Caused by: java.lang.NullPointerException
    at com.espertech.esper.epl.expression.core.ExprVariableNodeImpl.evaluate(ExprVariableNodeImpl.java:159)
    at com.espertech.esper.util.PopulateUtil.coerceProperty(PopulateUtil.java:308)
    at com.espertech.esper.util.PopulateUtil.populateObject(PopulateUtil.java:136)
    at com.espertech.esper.dataflow.core.DataFlowServiceImpl.injectObjectProperties(DataFlowServiceImpl.java:359)
    at com.espertech.esper.dataflow.core.DataFlowServiceImpl.instantiateOperator(DataFlowServiceImpl.java:320)
    at com.espertech.esper.dataflow.core.DataFlowServiceImpl.instantiateOperators(DataFlowServiceImpl.java:294)
    at com.espertech.esper.dataflow.core.DataFlowServiceImpl.instantiateInternal(DataFlowServiceImpl.java:226)
    at com.espertech.esper.dataflow.core.DataFlowServiceImpl.instantiate(DataFlowServiceImpl.java:126)
    ... 3 more

NullPointerException with wrong On-select syntax

Deploying a module with

on Event
select 1;

fails with the NullPointerException below, in Esper 5.2

Caused by: java.lang.NullPointerException
    at com.espertech.esper.core.service.StatementLifecycleSvcUtil.isWritesToTables(StatementLifecycleSvcUtil.java:235)
    at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createStopped(StatementLifecycleSvcImpl.java:264)
    at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createStoppedAssignName(StatementLifecycleSvcImpl.java:194)
    at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createAndStart(StatementLifecycleSvcImpl.java:148)
    at com.espertech.esper.core.service.EPAdministratorImpl.createEPLStmt(EPAdministratorImpl.java:117)
    at com.espertech.esper.core.service.EPAdministratorImpl.createEPL(EPAdministratorImpl.java:91)
    at com.espertech.esper.core.deploy.EPDeploymentAdminImpl.deployInternal(EPDeploymentAdminImpl.java:174)
    at com.espertech.esper.core.deploy.EPDeploymentAdminImpl.deploy(EPDeploymentAdminImpl.java:102)

Problem signing application based on Esper due to CGLIB 3.1 dependency

When trying to sign an application that is using Esper the following exception is thrown:

2016-07-12 17:13:48,674 WARN [main] [com.espertech.esper.event.bean.BeanEventType] .initialize Unable to obtain CGLib fast class and/or method implementation for class ch.algotrader.service.MarketDataService, error msg is java.lang.reflect.InvocationTargetException-->null net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237) ~[cglib-nodep-3.1.jar:?] at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:64) ~[cglib-nodep-3.1.jar:?] at net.sf.cglib.reflect.FastClass.create(FastClass.java:46) ~[cglib-nodep-3.1.jar:?] at com.espertech.esper.event.bean.BeanEventType.initialize(BeanEventType.java:359) [esper-5.3.0.jar:?] at com.espertech.esper.event.bean.BeanEventType.<init>(BeanEventType.java:91) [esper-5.3.0.jar:?] at com.espertech.esper.event.bean.BeanEventAdapter.createBeanType(BeanEventAdapter.java:142) [esper-5.3.0.jar:?] at com.espertech.esper.event.EventAdapterServiceImpl.addBeanType(EventAdapterServiceImpl.java:360) [esper-5.3.0.jar:?] at com.espertech.esper.epl.variable.VariableServiceImpl.createNewVariable(VariableServiceImpl.java:296) [esper-5.3.0.jar:?] at com.espertech.esper.core.service.EPServicesContextFactoryDefault.initVariables(EPServicesContextFactoryDefault.java:300) [esper-5.3.0.jar:?] at com.espertech.esper.core.service.EPServicesContextFactoryDefault.createServicesContext(EPServicesContextFactoryDefault.java:141) [esper-5.3.0.jar:?] at com.espertech.esper.core.service.EPServiceProviderImpl.doInitialize(EPServiceProviderImpl.java:498) [esper-5.3.0.jar:?] at com.espertech.esper.core.service.EPServiceProviderImpl.<init>(EPServiceProviderImpl.java:91) [esper-5.3.0.jar:?] at com.espertech.esper.client.EPServiceProviderManager.getProviderInternal(EPServiceProviderManager.java:132) [esper-5.3.0.jar:?] at com.espertech.esper.client.EPServiceProviderManager.getProvider(EPServiceProviderManager.java:88) [esper-5.3.0.jar:?] Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384) ~[cglib-nodep-3.1.jar:?] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) ~[cglib-nodep-3.1.jar:?] ... 124 more Caused by: java.lang.SecurityException: class "ch.algotrader.service.MarketDataService$$FastClassByCGLIB$$f9bb9a92_2"'s signer information does not match signer information of other classes in the same package at java.lang.ClassLoader.checkCerts(ClassLoader.java:895) ~[?:1.8.0_66] at java.lang.ClassLoader.preDefineClass(ClassLoader.java:665) ~[?:1.8.0_66] at java.lang.ClassLoader.defineClass(ClassLoader.java:758) ~[?:1.8.0_66] at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384) ~[cglib-nodep-3.1.jar:?] at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219) ~[cglib-nodep-3.1.jar:?] ... 124 more

According to the cglib/cglib@f9d2f6c this was fixed in CGLIB 3.2.4

Esper currently depends on CGLIB 3.1. But manually adding a dependency to CGLIB 3.2.4 fixes the issue

Prior function does not accept constant variable

The following EPL results in the exception below

create constant variable int x = 10;
select prior(x, price) from Trade;
Caused by: com.espertech.esper.client.EPStatementSyntaxException: Incorrect syntax near 'x' at line 1 column 13, please check the select clause [select prior(x, price) from Trade]

Please close the issue if this is expected behaviour, but would have thought a variable (at least constant variable) could be used in this statement.

Joining two named windows when using multiple thread and where both windows use "std:unique" produces incorrect results

I have a problem with using std:unique(key) to create windows containing only the latest version of a pojo based on it's String key field. Here is the syntax I am using:

statement 1:
create window PojoWin.std:unique(key) as com.xxx.Pojo
statement 2:
insert into PojoWin select * from com.xxx.Pojo

then I am sending instances of my pojo to esper using:
EPServiceProvider.getEPRuntime().sendEvent(pojo);

I then have a continuous query on my window joining another similarly defined window:
select * from PojoWin as p,
Pojo2Win as p2
where p.x = p2.x

Simple right?

The issue I'm having is 99.9% of the time this works as expected. Everytime a pojo is inserted, I get the most recent version of the Pojo based on it's key. However very occasionally I will, in addition to the most recent version, get an older version of the pojo with the same key. Based on the documentation I don't think this should be possible. You should only be getting one version of the pojo per key in any return results that query a window defined as std:unique(key).

I wish I could give you a test case that would reproduce this issue but I'm afraid it is not possible as I'm dealing with a complex system with a large quantity of data, and this issue occurs sporadically at best.

NPE trying to register a pattern that has a function with a subselect as an atom filter

Exception occurs on creating a atom filter as a custom function with a subselect as a parameter.

Here's my statement:
select * from pattern [Event(test((select * from MY_WIN)))]

And the error:
ERROR pool-8-thread-1 StatementLifecycleSvcImpl - Unexpected error compiling statement
java.lang.NullPointerException
at com.espertech.esper.epl.expression.subquery.ExprSubselectRowNode.getType(ExprSubselectRowNode.java:48)
at com.espertech.esper.epl.expression.core.ExprNodeUtility.resolveMethodAllowWildcardAndStream(ExprNodeUtility.java:764)
at com.espertech.esper.epl.expression.funcs.ExprPlugInSingleRowNode.validate(ExprPlugInSingleRowNode.java:139)
at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtreeInternal(ExprNodeUtility.java:375)
at com.espertech.esper.epl.expression.core.ExprNodeUtility.getValidatedSubtree(ExprNodeUtility.java:290)
at com.espertech.esper.filter.FilterSpecCompiler.validateAllowSubquery(FilterSpecCompiler.java:199)
at com.espertech.esper.filter.FilterSpecCompiler.makeFilterSpec(FilterSpecCompiler.java:91)
at com.espertech.esper.epl.spec.PatternStreamSpecRaw.recursiveCompile(PatternStreamSpecRaw.java:288)
at com.espertech.esper.epl.spec.PatternStreamSpecRaw.compileInternal(PatternStreamSpecRaw.java:150)
at com.espertech.esper.epl.spec.PatternStreamSpecRaw.compile(PatternStreamSpecRaw.java:89)
at com.espertech.esper.epl.spec.PatternStreamSpecRaw.compile(PatternStreamSpecRaw.java:47)
at com.espertech.esper.core.service.StatementLifecycleSvcImpl.compile(StatementLifecycleSvcImpl.java:1139)
at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createStopped(StatementLifecycleSvcImpl.java:277)
at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createStoppedAssignName(StatementLifecycleSvcImpl.java:199)
at com.espertech.esper.core.service.StatementLifecycleSvcImpl.createAndStart(StatementLifecycleSvcImpl.java:153)
at com.espertech.esper.core.service.EPAdministratorImpl.createEPLStmt(EPAdministratorImpl.java:118)
at com.espertech.esper.core.service.EPAdministratorImpl.createEPL(EPAdministratorImpl.java:67)
...

Attached is a .txt that is actually a sample java application that reproduces the issue. Also note that there is a commented out line that can be swapped out with the previous line that changes the subselect result and creates a different stack trace. Not sure if they both stem from the same problem or not.

PatternTest.txt

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.