Skip to content

Commit 4d3d718

Browse files
authored
Merge pull request #186592 from spelluru/asawriter0217
Author: Rodrigo Souza -> Florian Eiden
2 parents 6ab6205 + eb363c9 commit 4d3d718

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

articles/stream-analytics/stream-analytics-javascript-user-defined-aggregates.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: JavaScript user-defined aggregates in Azure Stream Analytics
33
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
66

77
ms.service: stream-analytics
88
ms.topic: conceptual
@@ -15,11 +15,11 @@ Azure Stream Analytics supports user-defined aggregates (UDA) written in JavaScr
1515

1616
## JavaScript user-defined aggregates
1717

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.
1919

2020
### AccumulateOnly aggregates
2121

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:
2323

2424
```JavaScript
2525
// 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
7373

7474
### Function alias
7575

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.
7777

7878
### Function type
7979

@@ -93,33 +93,33 @@ The init() method initializes state of the aggregate. This method is called when
9393

9494
### Method – accumulate()
9595

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).
9797

9898
### Method – deaccumulate()
9999

100100
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.
101101

102102
### Method – deaccumulateState()
103103

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.
105105

106106
### Method – computeResult()
107107

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).
109109

110110
## JavaScript UDA supported input and output data types
111111
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).
112112

113113
## Adding a JavaScript UDA from the Azure portal
114114

115-
Below we walk through the process of creating a UDA from Portal. The example we use here is computing time weighted averages.
115+
Below we walk through the process of creating a UDA from Portal. The example we use here’s computing time-weighted averages.
116116

117117
Now let's create a JavaScript UDA under an existing ASA job by following steps.
118118

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.
123123
1. Fill in "TWA" as the UDA alias and change the function implementation as the following:
124124

125125
```JavaScript
@@ -162,9 +162,9 @@ Now let's create a JavaScript UDA under an existing ASA job by following steps.
162162
}
163163
```
164164

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.
166166

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.
168168

169169
## Calling JavaScript UDA in ASA query
170170

0 commit comments

Comments
 (0)