Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expression and expressionBatch window #1599

Merged
merged 6 commits into from
Dec 25, 2019

Conversation

suhothayan
Copy link
Contributor

@suhothayan suhothayan commented Dec 24, 2019

Purpose

To hold values in the window only until the given expression is satisfied. The expression window expires the oldest events until the given expression is not satisfied, and the expressionBatch window expires all events as a batch when the given expression is not satisfied.
Here the expression should be passed as a string, as it is executed within the window.
Fixes #1596

Goals

Support event expiry based on an expression.

Approach

Expression and ExpressionBatch window evaluates the events from the oldest (first) to the newest (last) and expires them if they do not satisfy the condition.
E.g.

from StockEventWindow#window.expression(
          'sum(price) < 100 and eventTimestamp(last) - eventTimestamp(first) < 3000')
select symbol, sum(price) as price
insert into OutputStream ;

Retain only the events having their sum(price) < 100, and the last and first events are within 3-second difference in a sliding manner.

from StockEventWindow#window.expressionBatch('last.symbol==first.symbol')
select symbol, sum(price) as price
insert into OutputStream ;

Output events as a batch when a new symbol type arrives.

@codecov-io
Copy link

Codecov Report

Merging #1599 into master will increase coverage by 0.13%.
The diff coverage is 76.07%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1599      +/-   ##
============================================
+ Coverage     67.73%   67.86%   +0.13%     
  Complexity       45       45              
============================================
  Files           651      654       +3     
  Lines         27524    27982     +458     
  Branches       4340     4403      +63     
============================================
+ Hits          18643    18990     +347     
- Misses         7062     7162     +100     
- Partials       1819     1830      +11
Impacted Files Coverage Δ Complexity Δ
...re/src/main/java/io/siddhi/core/window/Window.java 71.92% <ø> (-0.25%) 0 <0> (ø)
...processor/stream/window/HopingWindowProcessor.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ocessor/stream/window/GroupingWindowProcessor.java 96% <100%> (+1.26%) 0 <0> (ø) ⬇️
...ocessor/stream/window/BatchingWindowProcessor.java 100% <100%> (ø) 0 <0> (ø) ⬇️
...ddhi/core/util/parser/SingleInputStreamParser.java 87.82% <100%> (+0.21%) 0 <0> (ø) ⬇️
...a/io/siddhi/core/event/stream/MetaStreamEvent.java 94.36% <100%> (-4.17%) 0 <0> (ø)
.../io/siddhi/core/util/parser/AggregationParser.java 75.27% <100%> (ø) 0 <0> (ø) ⬇️
...cutor/function/EventTimestampFunctionExecutor.java 80% <100%> (+67.5%) 0 <0> (ø) ⬇️
...io/siddhi/core/aggregation/AggregationRuntime.java 53.11% <100%> (ø) 0 <0> (ø) ⬇️
...rocessor/stream/window/SlidingWindowProcessor.java 100% <100%> (ø) 0 <0> (ø) ⬇️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb3d43d...dd4f1a2. Read the comment docs.

@mohanvive mohanvive merged commit b2082be into siddhi-io:master Dec 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window feature which expires based on condition
3 participants