Siddhi自定义聚合函数文档疑问:示例调用与定义不符
Great question! This is a super common point of confusion when first building custom aggregate functions in Siddhi, and it all comes down to how Siddhi maps your code to the function name you use in queries.
Let me break it down simply:
- The class name of your custom aggregate function (like
StdAggregateFunctionin the docs example) is just a label for your Java code—it doesn't dictate what you call the function in Siddhi queries. - The actual name you use in queries is defined by the
functionNameparameter in the@Extensionannotation that decorates your function class.
For example, if the docs' sample code looks like this under the hood:
@Extension( namespace = "custom", functionName = "count", // This is the name Siddhi recognizes description = "Custom count aggregate function" ) public class StdAggregateFunction extends AbstractAggregateFunction { // Function implementation logic here }
Then calling custom:count(orderNo) in your query makes perfect sense—it's referencing the functionName specified in the annotation, not the class name.
The docs likely mixed up the descriptive name ("std" function) with the actual annotation configuration used in the sample, which is why you see the mismatch. The key takeaway is:
Always rely on the
functionNamevalue in your@Extensionannotation to know what name to use in Siddhi queries—your Java class name doesn't affect this at all.
内容的提问来源于stack exchange,提问作者Peter Rubi

