Return more than one tuple

Category: sql server streaminsight

Question

A.Cormen on Sun, 23 Nov 2014 13:26:02


I have a query like this in StreamInsight:

                var actionQuery = from e in query
                                  where e.severity >= 1
                                  select new Message { severity = e.severity ...}

How can i return more than one tuple? For example, selecting two generated Messages in the above sample? I think it is somehow related to select many but i could not make it work!

Replies

pituach on Sun, 23 Nov 2014 15:42:04


Hi,

Why not just return e and then you can create the new entity? something like

 var actionQuery = from e in query
                                  where e.severity >= 1
                                  select e

* Your original query should work ok and bring all element that fit the filter and not only one if there are more.
Can you post the class code?


signature   Ronen Ariely
 [Personal Site]    [Blog]    [Facebook]


DevBiker on Sun, 23 Nov 2014 20:15:50


A user-defined operator (UDO ... for windows) or a user defined stream operator (UDSO) will let you return multiple items from a single input event. So you'd need to create one of them. From the looks of your query, a UDSO would be appropriate.

A.Cormen on Mon, 24 Nov 2014 05:46:20


Hi,

Yes i am using UDSO now but just considering if there exists a better and more gentle solution. As a matter of fact, i am designing my all queries using UDSO (which is practically easier than normal StreamInsight LINQ queries) and i doubt if StreamInsight brings me a real added value!!!




DevBiker on Mon, 24 Nov 2014 11:55:51


A UDSO is actually pretty efficient. However, I would question why you are designing all of your queries using a UDSO. If you are using them because of their statefulness, then it's very likely that you could accomplish what you need with the right temporal operators ... which would typically be more efficient.

A.Cormen on Tue, 25 Nov 2014 11:44:30


Hi,

because timestamp issues are really annoying esp. when you use some operators like union and anti join ... but UDSO, on the other side, is very flexible and cool esp. for stateful and pattern based queries.

DevBiker on Tue, 25 Nov 2014 12:51:41


Which just highlights my point ;-)

Understanding how time and timestamps work in StreamInsight is certainly the most difficult part of developing apps. It's a paradigm shift from the way we typically handle data but once you "get" it, it's extremely powerful and will give you more flexibility and better performance than using UDSOs to "get around" timestamp "issues".