You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/stream-analytics/stream-analytics-javascript-user-defined-aggregates.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
2
title: JavaScript user-defined aggregates in Azure Stream Analytics
3
3
description: This article describes how to perform advanced query mechanics with JavaScript user-defined aggregates in Azure Stream Analytics.
4
-
author: rodrigoaatmicrosoft
5
-
ms.author: rodrigoa
4
+
author: fleid
5
+
ms.author: fleide
6
6
7
7
ms.service: stream-analytics
8
8
ms.topic: conceptual
@@ -15,11 +15,11 @@ Azure Stream Analytics supports user-defined aggregates (UDA) written in JavaScr
15
15
16
16
## JavaScript user-defined aggregates
17
17
18
-
A user-defined aggregate is used on top of a time window specification to aggregate over the events in that window and produce a single result value. There are two types of UDA interfaces that Stream Analytics supports today, AccumulateOnly and AccumulateDeaccumulate. Both types of UDA can be used by Tumbling, Hopping, Sliding and Session Window. AccumulateDeaccumulate UDA performs better than AccumulateOnly UDA when used together with Hopping, Sliding and Session Window. You choose one of the two types based on the algorithm you use.
18
+
A user-defined aggregate is used on top of a time window specification to aggregate over the events in that window and produce a single result value. There are two types of UDA interfaces that Stream Analytics supports today, AccumulateOnly and AccumulateDeaccumulate. Both types of UDA can be used by Tumbling, Hopping, Sliding and Session Window. AccumulateDeaccumulate UDA performs better than AccumulateOnly UDA when used together with Hopping, Sliding, and Session Window. You choose one of the two types based on the algorithm you use.
19
19
20
20
### AccumulateOnly aggregates
21
21
22
-
AccumulateOnly aggregates can only accumulate new events to its state, the algorithm does not allow deaccumulation of values. Choose this aggregate type when deaccumulate an event information from the state value is impossible to implement. Following is the JavaScript template for AccumulatOnly aggregates:
22
+
AccumulateOnly aggregates can only accumulate new events to its state, the algorithm doesn’t allow deaccumulation of values. Choose this aggregate type when deaccumulate an event information from the state value is impossible to implement. Following is the JavaScript template for AccumulatOnly aggregates:
23
23
24
24
```JavaScript
25
25
// Sample UDA which state can only be accumulated.
@@ -73,7 +73,7 @@ Each JavaScript UDA is defined by a Function object declaration. Following are t
73
73
74
74
### Function alias
75
75
76
-
Function alias is the UDA identifier. When called in Stream Analytics query, always use UDA alias together with a "uda." prefix.
76
+
Function alias is the UDA identifier. When called in Stream Analytics query, always use UDA alias together with an "uda." prefix.
77
77
78
78
### Function type
79
79
@@ -93,33 +93,33 @@ The init() method initializes state of the aggregate. This method is called when
93
93
94
94
### Method – accumulate()
95
95
96
-
The accumulate() method calculates the UDA state based on the previous state and the current event values. This method is called when an event enters a time window (TUMBLINGWINDOW, HOPPINGWINDOW, SLIDINGWINDOW or SESSIONWINDOW).
96
+
The accumulate() method calculates the UDA state based on the previous state and the current event values. This method is called when an event enters a time window (TUMBLINGWINDOW, HOPPINGWINDOW, SLIDINGWINDOW, or SESSIONWINDOW).
97
97
98
98
### Method – deaccumulate()
99
99
100
100
The deaccumulate() method recalculates state based on the previous state and the current event values. This method is called when an event leaves a SLIDINGWINDOW or SESSIONWINDOW.
101
101
102
102
### Method – deaccumulateState()
103
103
104
-
The deaccumulateState() method recalculates state based on the previous state and the state of a hop. This method is called when a set of events leave a HOPPINGWINDOW.
104
+
The deaccumulateState() method recalculates state based on the previous state and the state of a hop. This method is called when a set of events leaves a HOPPINGWINDOW.
105
105
106
106
### Method – computeResult()
107
107
108
-
The computeResult() method returns aggregate result based on the current state. This method is called at the end of a time window (TUMBLINGWINDOW, HOPPINGWINDOW, SLIDINGWINDOW or SESSIONWINDOW).
108
+
The computeResult() method returns aggregate result based on the current state. This method is called at the end of a time window (TUMBLINGWINDOW, HOPPINGWINDOW, SLIDINGWINDOW, or SESSIONWINDOW).
109
109
110
110
## JavaScript UDA supported input and output data types
111
111
For JavaScript UDA data types, refer to section **Stream Analytics and JavaScript type conversion** of [Integrate JavaScript UDFs](stream-analytics-javascript-user-defined-functions.md).
112
112
113
113
## Adding a JavaScript UDA from the Azure portal
114
114
115
-
Below we walk through the process of creating a UDA from Portal. The example we use here is computing timeweighted averages.
115
+
Below we walk through the process of creating a UDA from Portal. The example we use here’s computing time-weighted averages.
116
116
117
117
Now let's create a JavaScript UDA under an existing ASA job by following steps.
118
118
119
-
1.Log on to Azure portal and locate your existing Stream Analytics job.
120
-
1. Then click on functions link under **JOB TOPOLOGY**.
121
-
1.Click on the **Add** icon to add a new function.
122
-
1. On the New Function view, select **JavaScript UDA** as the Function Type, then you see a default UDA template show up in the editor.
119
+
1.Sign in to Azure portal and locate your existing Stream Analytics job.
120
+
1. Then select functions link under **JOB TOPOLOGY**.
121
+
1.Select **Add** to add a new function.
122
+
1. On the New Function view, select **JavaScript UDA** as the Function Type, then you see a default UDA template shows up in the editor.
123
123
1. Fill in "TWA" as the UDA alias and change the function implementation as the following:
124
124
125
125
```JavaScript
@@ -162,9 +162,9 @@ Now let's create a JavaScript UDA under an existing ASA job by following steps.
162
162
}
163
163
```
164
164
165
-
1. Once you click the "Save" button, your UDA shows up on the function list.
165
+
1. Once you select the "Save" button, your UDA shows up on the function list.
166
166
167
-
1. Click on the new function "TWA", you can check the function definition.
167
+
1. Select the new function "TWA", you can check the function definition.
0 commit comments