I have created a new single row function which takes collection of events as input parameter. I am able to to process single event parameters in EPL statement but not able to find out how to pass colection of events as parameter in EPL statement.
Suppose I have created a function named percent which takes event as only parameter and it is getting processed using below EPL query:
select * from MyEvent(percent(me)< 20) as me
But if i create a function which takes collection of events as parameter i am unable to pass it.
select * from Stock_Event_Rank(rank(me)) as me
Here I want to pass me as collection of events. Will be thankful for any help.
In the scope of a filter there is no collection of events.
The only collection of events is when there is a data window.
For example:select rank(window(*)) from StockEvent.win:length(10)
This is so because the Esper doesn't keep just events, unless there is a data window and that means Esper does keep a certain subset of events. I also recommend looking at aggregation functions or plugin aggregation functions or the "ranked" data-window. This is so because "rank(window(*))" would probably need to recompute ranks for every event that comes and goes.
Related
I want to implement this logic other than aggregator stage, basically through transformer stage to merge these records based on the ID column, and there is no possibility to get multiple values for same field in my case for same ID column.
I have this input data,
ID|VAL1|VAL2|VAL3|BAL1|BAL2|BAL3
10001|5|0|0|1000|0|0
10001|0|10|0|0|1200|0
10001|0|0|11|11|0|10500
and i want my output to be like:
ID|VAL1|VAL2|VAL3|BAL1|BAL2|BAL3
10001|5|10|11|1000|1200|10500
Is it possible to implement it and if, then thanks in advance!!!!
There are at least two options to do that:
Using the loop within the transformer
Storing the data of the previous row (with the help of stage variables) until LastRowInGroup
Some common things are
get the data sorted upfront the transformer
Use LastRowInGroup to use it as output constraint
remember that the stage & loop variables are processed top down so the sequence matters and enables one to point to an old (previous) content when referring to a variable further down from above
Be aware that this a little advanced - the aggregator would be probably the easier solution.
I have an Event model with multiple time slots(on and from attributes both are datetime)
I need to get distinct events based on some condition that is applied on the time slot model through joins and have is sorted in some order.
I tried a few approaches but it just works when i order on the event attribute and not on the time slot attribute.
Event.joins(:time_slots).order('time_slots.from asc').distinct
throws InvalidColumnReference error
Event.joins(:time_slots).order('events.id asc').distinct
works
How can I make the former query work?
I had to use Event.includes instead of Event.joins, and it actually worked as expected.
My problem is this:
I want to trigger a search help programatically.
I want to populate the initial select-options screen with default values (and set some as non-editable).
After the user choses aditional parameters (or changes the existing ones) I want to be able to implement the data selection logic myself.
My approach is using a search-help exit.
I've managed to fill in the initial select-options parameters, but then I couldn't modify the data selection logic. For this I filled the SHLP_TAB[]-INTERFACE table with data, and kept the CALLCONTROL-STEP = 'SELONE'.
I've managed to be able to be able to modify the data selection logic, by setting the CALLCONTROL-STEP = 'PRESEL'. but then I couldn't populate the initial screen with data either by filling the SHLP structure (INTERFACE table of it) or the SHLP_TAB table (same INTERFACE) component.
I want to both populate the initial screen, and control the data selection. (How) can this be done?
[EDIT]
*SOLVED*
The problem was that I was using an exit function module for a collective search help that I was calling.
This works differently from an elementary search help exit function.
The collective search help does indeed supply the parameters (thorugh the defined binding) for the PRESEL event, but the SELECT event is then performed in the elementary search help.
The Collective search help SELECT event is apparently called after skipping the PRESEL events of the elementary search helps, so that is why one should be careful when to use exit functions for either the Collective search help, or the elementary search help.
I've got an sqlite3 database that contains events. Each event is either "on" or "off" of something happening, and contains the time of the event as well as what the event is and some miscellaneous data which varies by event.
I want to query to find that last event of each type. So far this is the query I have come up with:
SELECT * from event where name='event1on' or name='event1off' ORDER BY t DESC LIMIT 1
This works, but it is slow when I have a lot of events I want to find the latest one of. I suspect this is because for each SELECT a full scan of the database must be made (several million rows), but I am at a loss to find a more efficient way to do this.
If you have SQLite 3.7.11 or later, you can use max to select other fields from the record that contains the maximum value:
SELECT *, max(t) FROM event GROUP BY name
To speed up this query, try creating one index on the name and t fields.
in my lightswitch application im trying to create a Customers Screen for customers who have balance value, and my balance value is a Calculated Field in the Customer Entity
when i tried to put the logic in the Process Query Event Like This
query =( from i in query
where(i.Balance>0)
select i );
i get an exception .. what is the best way to handle these kind of situations ??
i saw an answer here but i didn't know how to implement it exactly i need a sample code for it can anyone help me ??
thanks in advance
The query will be executed by the data provider, which doesn't know about calculated fields. What you can do is to filter what you want via LINQ, referring to the actual fields, not the calculated ones.
For example, let's say Balance is your calculated field, that you defined as Credit - Debit (which are normal fields). You want your query to return the rows where Balance > 0. This is how you'd write the query (in the PreprocessQuery event, note there is no ProcessQuery event):
partial void TestQuery_PreprocessQuery(ref IQueryable<Customer> query)
{
query = (
from c in query
where ((c.Credit - c.Debit) > 0)
select c);
}
Another theoretical way of solving the problem would be setting a filter in the Executed event handler. However, for whatever the reason, when I do it, the filter is not applied to the screen. But even if this method would work, still you'd be filtering on the client side, which might not be what you want.
I'm actually looking for a solution to this problem
(unfortunately I can't just include the calculation from the calculated field, because my calculation uses another calculated field which uses recursion)
A couple of pointers I thought you might find helpful:
#julio.g - for the Executed event handler, the "result" parameter is an IEnumerable parameter (as opposed to the PreProcess_Query event handler, where the "query" parameter is a ref IEnumerable) so any changes you make to the "result" will only be local to that method
#3oon - afaik, SQL Views are not supported in LightSwitch. The best option I've come across so far is to create a WCF RIA Service based on a Stored Procedure, then adding it as a datasource.
This blog post should help get you started.
http://tejana.wordpress.com/2010/12/09/microsoft-lightswitch-and-stored-procedures-using-wcf-ria-services/
Hope that helps!