Naresh Ravula on Fri, 20 May 2011 07:40:39
I am trying to pass a custom object to my UDF as shown below
var result = from e in input
where e.PacketUtilization > MyRule.ValidatePacketUtilization(e)
where 'e' is an object of type OCS.
Here is my UDF:
public class MyRule
public static double ValidatePacketUtilization(OCS call)
// logic to process the OCS object
when I Created query and binding it to the output adapter, I am getting "User-defined method call 'ValidatePacketUtilization(e)' has a parameter of type 'OCS', which is not supported." error.
I am not able to understand why my UDF is not supporting input of type 'OCS'. Please help me.
Thanks in advance.
DevBiker on Fri, 20 May 2011 12:07:23
From the StreamInsight documentation (here):
The parameters and the return value of a UDF must be of one of the StreamInsight primitive types.
You can find a list of the StreamInsight primitive types here.
Internally, StreamInsight does not use or process the objects that you use in the queries. These are used by the engine only to determine the schema of the queries, not for the actual processing. So ... when the query is running in the context of the engine, there is no object for it to pass. You need to pass the relevant properties as parameters.
I would also suggest that you make sure that this UDF is fast and doesn't do anything complex. If you are doing something that can take some time or block the thread, you should do this with an output adapter, not with a UDF. And, if possible, do it with the query, not a UDF; push as much as possible into the engine itself.
aka J Sawyer
If I answered your question, please mark as answer.
If my post was helpful, please mark as helpful.
Naresh Ravula on Fri, 20 May 2011 12:15:57
Thank you DevBiker for your response..
winterquery on Tue, 19 Feb 2013 14:26:50
If the UDF updates an SQL Server db, would you recommend instead calling this function in the output adapter?
TXPower125 on Tue, 19 Feb 2013 14:47:30
Yes, updating a database is better handled by an output adapter/sink.
winterquery on Wed, 20 Feb 2013 15:08:54