espertechinc / esper

Esper Complex Event Processing, Streaming SQL and Event Series Analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to correctly use the "context" keyword and get the result

BridgeCH opened this issue · comments

Thank you very much for reading this in your busy schedule

this is my EPL statement:

`create objectarray schema SubjectEntry(subject Subject, transaction Transaction);、

create window SubjectWindow.std:unique(id) as SubjectMatcher;

insert into SubjectWindow select * from SubjectMatcher;

//SubjectFactory.subject() Is a function that converts Subject
@name("TransactionLevel1")
on Transaction t
insert into SubjectEntry
select SubjectFactory.subject(a.code) subject, t transaction
from SubjectWindow a
where (t.condition= a.condition or a.condition= '*')
and a.level = 1;
`

Aassume:
I have 50000 SubjectMatcher events and 200 Transaction event, According to @name("TransactionLevel1") described:There should product 10000000 SubjectEntry events.

Now I want to use context to improve performance,However, I got into some trouble:

`create objectarray schema SubjectEntry(subject Subject, transaction Transaction);、

create context SubjectMatcherContext as coalesce consistent_hash_crc32(sid) from SubjectMatcher, consistent_hash_crc32(tid) from Transaction granularity 8 preallocate;

context SubjectMatcherContext create window SubjectWindow.std:unique(id) as SubjectMatcher;

@name("AccountingWindow")
context SubjectMatcherContext insert into SubjectWindow select * from SubjectMatcher;

@name("TransactionLevel1")
context SubjectMatcherContext
on Transaction t
insert into SubjectEntry
select SubjectFactory.subject(a.code) subject, t transaction
from SubjectWindow a
where (t.condition= a.condition or a.condition= '*')
and a.level = 1; `

I set 8 context partitions,which leads me to get the number of results of only one partition, that is 1250000 SubjectEntry events. I don't know how to get the result of the other 7 partitions correctly. I just guess it's related to the thread, but I looked up the document and didn't get the relevant information to tell me what to do.

Thank you very much whether you help me solve the problem or not

Please help me, thank you.

The "sid" and "tid" should really be same key, for instance user-id in login-event and logout-event. Maybe that is where your troubles come in.

The "sid" and "tid" should really be same key, for instance user-id in login-event and logout-event. Maybe that is where your troubles come in.

Thanks a lot ,Sir.
But I'm still in trouble.In my new EPL statement, I assign the same key to two different events(SubjectMatcher,Transaction ),But I still can only get the result of one of the partitions.How can I get the results of all the partitions?

(In short, I can only get one eighth of the results, how can I get the full number of results?)

post the new EPL? There isn't anything special one needs to do and a listener just always receives the results of all partitions

post the new EPL? There isn't anything special one needs to do and a listener just always receives the results of all partitions

sorry,sir.
I checked my code again,It's my fault.
Thank you very much for your kind help!