From ff91ce8da260f6c72812d863b736ddbb3510c381 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 29 Aug 2022 15:19:29 -0600 Subject: [PATCH] flux 0.181.0 release notes and stdlib (#4397) --- content/flux/v0.x/release-notes.md | 16 ++ .../stdlib/experimental/http/requests/peek.md | 4 +- .../v0.x/stdlib/experimental/json/parse.md | 8 +- .../stdlib/experimental/polyline/_index.md | 45 +++ .../v0.x/stdlib/experimental/polyline/rdp.md | 264 ++++++++++++++++++ content/flux/v0.x/stdlib/http/requests/get.md | 2 +- .../flux/v0.x/stdlib/http/requests/peek.md | 6 +- .../flux/v0.x/stdlib/http/requests/post.md | 86 +++++- .../influxdata/influxdb/monitor/deadman.md | 7 +- content/flux/v0.x/stdlib/universe/union.md | 8 +- 10 files changed, 427 insertions(+), 19 deletions(-) create mode 100644 content/flux/v0.x/stdlib/experimental/polyline/_index.md create mode 100644 content/flux/v0.x/stdlib/experimental/polyline/rdp.md diff --git a/content/flux/v0.x/release-notes.md b/content/flux/v0.x/release-notes.md index 0cbdd2644..c84d52278 100644 --- a/content/flux/v0.x/release-notes.md +++ b/content/flux/v0.x/release-notes.md @@ -10,6 +10,22 @@ aliases: - /influxdb/cloud/reference/release-notes/flux/ --- +## v0.181.0 [2022-08-29] + +### Features +- Add "headless" json-rpc based REPL. +- Support vectorized unary operators. +- Add [`experimental/polyline` package](/flux/v0.x/stdlib/experimental/polyline) + for downsampling data. +- Update function library to have its own arguments struct. + +### Bug fixes +- Update import path for the `Spec` package in the "headless" REPL. +- Update conditional vectorization to handle bad values for `test`, + `consequent`, or `alternate`. + +--- + ## v0.180.1 [2022-08-22] - _Internal code cleanup._ diff --git a/content/flux/v0.x/stdlib/experimental/http/requests/peek.md b/content/flux/v0.x/stdlib/experimental/http/requests/peek.md index 165f8d194..7fb23a387 100644 --- a/content/flux/v0.x/stdlib/experimental/http/requests/peek.md +++ b/content/flux/v0.x/stdlib/experimental/http/requests/peek.md @@ -87,12 +87,12 @@ requests.peek(response: requests.get(url: "https://api.agify.io", params: ["name Connection: keep-alive, Content-Length: 41, Content-Type: application/json; charset=utf-8, - Date: Mon, 22 Aug 2022 19:17:07 GMT, + Date: Mon, 29 Aug 2022 17:59:41 GMT, Etag: W/"29-klDahUESBLxHyQ7NiaetCn2CvCI", Server: nginx/1.16.1, X-Rate-Limit-Limit: 1000, X-Rate-Limit-Remaining: 998, - X-Rate-Reset: 16973 + X-Rate-Reset: 21619 ] | 200 | {{% /expand %}} diff --git a/content/flux/v0.x/stdlib/experimental/json/parse.md b/content/flux/v0.x/stdlib/experimental/json/parse.md index 3479db56d..6b0d4bd7c 100644 --- a/content/flux/v0.x/stdlib/experimental/json/parse.md +++ b/content/flux/v0.x/stdlib/experimental/json/parse.md @@ -196,10 +196,10 @@ array.from( #### Output data -| color | pendingDuration | id | -| ------ | ---------------- | -------- | -| red | 3 | 15612462 | -| blue | 16 | 15612462 | +| id | color | pendingDuration | +| -------- | ------ | ---------------- | +| 15612462 | red | 3 | +| 15612462 | blue | 16 | {{% /expand %}} {{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/experimental/polyline/_index.md b/content/flux/v0.x/stdlib/experimental/polyline/_index.md new file mode 100644 index 000000000..826b02510 --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/polyline/_index.md @@ -0,0 +1,45 @@ +--- +title: polyline package +description: > + The `polyline` package provides methods for polyline simplication, an efficient way of downsampling curves while retaining moments of variation throughout the path. +menu: + flux_0_x_ref: + name: polyline + parent: experimental + identifier: experimental/polyline +weight: 21 +cascade: + + introduced: 0.181.0 +--- + + + +The `polyline` package provides methods for polyline simplication, an efficient way of downsampling curves while retaining moments of variation throughout the path. +Import the `experimental/polyline` package: + +```js +import "experimental/polyline" +``` + +This class of algorithms enable efficient rendering of graphs and visualizations without having to load all data into memory. +This is done by reducing the number of vertices that do not contribute significantly to the convexity and concavity of the shape. + + +## Functions + +{{< children type="functions" show="pages" >}} diff --git a/content/flux/v0.x/stdlib/experimental/polyline/rdp.md b/content/flux/v0.x/stdlib/experimental/polyline/rdp.md new file mode 100644 index 000000000..9715bbd4c --- /dev/null +++ b/content/flux/v0.x/stdlib/experimental/polyline/rdp.md @@ -0,0 +1,264 @@ +--- +title: polyline.rdp() function +description: > + `polyline.rdp()` applies the Ramer Douglas Peucker (RDP) algorithm to input data to downsample curves composed + of line segments into visually indistinguishable curves with fewer points. +menu: + flux_0_x_ref: + name: polyline.rdp + parent: experimental/polyline + identifier: experimental/polyline/rdp +weight: 201 +flux/v0.x/tags: [transformations] +--- + + + +`polyline.rdp()` applies the Ramer Douglas Peucker (RDP) algorithm to input data to downsample curves composed +of line segments into visually indistinguishable curves with fewer points. + + + +##### Function type signature + +```js +( + <-tables: stream[A], + ?epsilon: float, + ?retention: float, + ?timeColumn: string, + ?valColumn: string, +) => stream[B] where A: Record, B: Record +``` + +{{% caption %}}For more information, see [Function type signatures](/flux/v0.x/function-type-signatures/).{{% /caption %}} + +## Parameters + +### valColumn + +Column with Y axis values of the given curve. Default is `_value`. + + + +### timeColumn + +Column with X axis values of the given curve. Default is `_time`. + + + +### epsilon + +Maximum tolerance value that determines the amount of compression. + +Epsilon should be greater than `0.0`. + +### retention + +Percentage of points to retain after downsampling. + +Retention rate should be between `0.0` and `100.0`. + +### tables + +Input data. Default is piped-forward data (`<-`). + + + + +## Examples + +- [Downsample data using the RDP algorithm](#downsample-data-using-the-rdp-algorithm) +- [Downsample the data using the epsilon value 1.5](#downsample-the-data-using-the-epsilon-value-15) +- [Downsample the data using a retention rate of 90%](#downsample-the-data-using-a-retention-rate-of-90) + +### Downsample data using the RDP algorithm + +When using `polyline.rdp()`, leave both `epsilon` and `retention` unspecified +to automatically calculate the maximum tolerance beyond which producing a +visually indistinguishable curve is not be possible. + +```js +import "experimental/polyline" + +data + |> polyline.rdp() +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | +| -------------------- | ------------------- | +| 2022-08-29T17:57:00Z | 10.56555566168836 | +| 2022-08-29T17:57:10Z | -29.76098586714259 | +| 2022-08-29T17:57:20Z | -67.50435038579738 | +| 2022-08-29T17:57:30Z | -16.758669047964453 | +| 2022-08-29T17:57:40Z | -47.25865245658065 | +| 2022-08-29T17:57:50Z | 66.16082461651365 | +| 2022-08-29T17:58:00Z | -0.9179216017921821 | +| 2022-08-29T17:58:10Z | -56.89169240573004 | +| 2022-08-29T17:58:20Z | 11.358605472976624 | +| 2022-08-29T17:58:30Z | 28.71147881415803 | +| 2022-08-29T17:58:40Z | -30.928830759588756 | +| 2022-08-29T17:58:50Z | -22.411848631056067 | +| 2022-08-29T17:59:00Z | 17.05503606764129 | +| 2022-08-29T17:59:10Z | 9.834382683760559 | +| 2022-08-29T17:59:20Z | -12.62058579127679 | +| 2022-08-29T17:59:30Z | -44.44668391211515 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------- | +| 2022-08-29T17:57:00Z | 10.56555566168836 | +| 2022-08-29T17:57:10Z | -29.76098586714259 | +| 2022-08-29T17:57:20Z | -67.50435038579738 | +| 2022-08-29T17:57:30Z | -16.758669047964453 | +| 2022-08-29T17:57:40Z | -47.25865245658065 | +| 2022-08-29T17:57:50Z | 66.16082461651365 | +| 2022-08-29T17:58:00Z | -0.9179216017921821 | +| 2022-08-29T17:58:10Z | -56.89169240573004 | +| 2022-08-29T17:58:20Z | 11.358605472976624 | +| 2022-08-29T17:58:30Z | 28.71147881415803 | +| 2022-08-29T17:58:40Z | -30.928830759588756 | +| 2022-08-29T17:58:50Z | -22.411848631056067 | +| 2022-08-29T17:59:00Z | 17.05503606764129 | +| 2022-08-29T17:59:10Z | 9.834382683760559 | +| 2022-08-29T17:59:20Z | -12.62058579127679 | +| 2022-08-29T17:59:30Z | -44.44668391211515 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Downsample the data using the epsilon value 1.5 + +```js +import "experimental/polyline" + +data + |> polyline.rdp(epsilon: 1.5) + +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | +| -------------------- | ------------------- | +| 2022-08-29T17:57:00Z | 10.56555566168836 | +| 2022-08-29T17:57:10Z | -29.76098586714259 | +| 2022-08-29T17:57:20Z | -67.50435038579738 | +| 2022-08-29T17:57:30Z | -16.758669047964453 | +| 2022-08-29T17:57:40Z | -47.25865245658065 | +| 2022-08-29T17:57:50Z | 66.16082461651365 | +| 2022-08-29T17:58:00Z | -0.9179216017921821 | +| 2022-08-29T17:58:10Z | -56.89169240573004 | +| 2022-08-29T17:58:20Z | 11.358605472976624 | +| 2022-08-29T17:58:30Z | 28.71147881415803 | +| 2022-08-29T17:58:40Z | -30.928830759588756 | +| 2022-08-29T17:58:50Z | -22.411848631056067 | +| 2022-08-29T17:59:00Z | 17.05503606764129 | +| 2022-08-29T17:59:10Z | 9.834382683760559 | +| 2022-08-29T17:59:20Z | -12.62058579127679 | +| 2022-08-29T17:59:30Z | -44.44668391211515 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------- | +| 2022-08-29T17:57:00Z | 10.56555566168836 | +| 2022-08-29T17:57:20Z | -67.50435038579738 | +| 2022-08-29T17:57:30Z | -16.758669047964453 | +| 2022-08-29T17:57:40Z | -47.25865245658065 | +| 2022-08-29T17:57:50Z | 66.16082461651365 | +| 2022-08-29T17:58:00Z | -0.9179216017921821 | +| 2022-08-29T17:58:10Z | -56.89169240573004 | +| 2022-08-29T17:58:20Z | 11.358605472976624 | +| 2022-08-29T17:58:30Z | 28.71147881415803 | +| 2022-08-29T17:58:40Z | -30.928830759588756 | +| 2022-08-29T17:58:50Z | -22.411848631056067 | +| 2022-08-29T17:59:00Z | 17.05503606764129 | +| 2022-08-29T17:59:10Z | 9.834382683760559 | +| 2022-08-29T17:59:20Z | -12.62058579127679 | +| 2022-08-29T17:59:30Z | -44.44668391211515 | + +{{% /expand %}} +{{< /expand-wrapper >}} + +### Downsample the data using a retention rate of 90% + +```js +import "experimental/polyline" + +data + |> polyline.rdp(retention: 90.0) + +``` + +{{< expand-wrapper >}} +{{% expand "View example input and ouput" %}} + +#### Input data + +| _time | _value | +| -------------------- | ------------------- | +| 2022-08-29T17:57:00Z | 10.56555566168836 | +| 2022-08-29T17:57:10Z | -29.76098586714259 | +| 2022-08-29T17:57:20Z | -67.50435038579738 | +| 2022-08-29T17:57:30Z | -16.758669047964453 | +| 2022-08-29T17:57:40Z | -47.25865245658065 | +| 2022-08-29T17:57:50Z | 66.16082461651365 | +| 2022-08-29T17:58:00Z | -0.9179216017921821 | +| 2022-08-29T17:58:10Z | -56.89169240573004 | +| 2022-08-29T17:58:20Z | 11.358605472976624 | +| 2022-08-29T17:58:30Z | 28.71147881415803 | +| 2022-08-29T17:58:40Z | -30.928830759588756 | +| 2022-08-29T17:58:50Z | -22.411848631056067 | +| 2022-08-29T17:59:00Z | 17.05503606764129 | +| 2022-08-29T17:59:10Z | 9.834382683760559 | +| 2022-08-29T17:59:20Z | -12.62058579127679 | +| 2022-08-29T17:59:30Z | -44.44668391211515 | + + +#### Output data + +| _time | _value | +| -------------------- | ------------------- | +| 2022-08-29T17:57:00Z | 10.56555566168836 | +| 2022-08-29T17:57:20Z | -67.50435038579738 | +| 2022-08-29T17:57:30Z | -16.758669047964453 | +| 2022-08-29T17:57:40Z | -47.25865245658065 | +| 2022-08-29T17:57:50Z | 66.16082461651365 | +| 2022-08-29T17:58:00Z | -0.9179216017921821 | +| 2022-08-29T17:58:10Z | -56.89169240573004 | +| 2022-08-29T17:58:20Z | 11.358605472976624 | +| 2022-08-29T17:58:30Z | 28.71147881415803 | +| 2022-08-29T17:58:40Z | -30.928830759588756 | +| 2022-08-29T17:58:50Z | -22.411848631056067 | +| 2022-08-29T17:59:00Z | 17.05503606764129 | +| 2022-08-29T17:59:10Z | 9.834382683760559 | +| 2022-08-29T17:59:30Z | -44.44668391211515 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/http/requests/get.md b/content/flux/v0.x/stdlib/http/requests/get.md index 0fbd5131b..7ae2e9c21 100644 --- a/content/flux/v0.x/stdlib/http/requests/get.md +++ b/content/flux/v0.x/stdlib/http/requests/get.md @@ -20,7 +20,7 @@ documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: -https://github.com/influxdata/flux/blob/master/stdlib/http/requests/requests.flux#L260-L274 +https://github.com/influxdata/flux/blob/master/stdlib/http/requests/requests.flux#L274-L288 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md diff --git a/content/flux/v0.x/stdlib/http/requests/peek.md b/content/flux/v0.x/stdlib/http/requests/peek.md index db2b97cbc..08618bde3 100644 --- a/content/flux/v0.x/stdlib/http/requests/peek.md +++ b/content/flux/v0.x/stdlib/http/requests/peek.md @@ -19,7 +19,7 @@ documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: -https://github.com/influxdata/flux/blob/master/stdlib/http/requests/requests.flux#L307-L317 +https://github.com/influxdata/flux/blob/master/stdlib/http/requests/requests.flux#L321-L331 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md @@ -82,12 +82,12 @@ requests.peek(response: requests.get(url: "https://api.agify.io", params: ["name Connection: keep-alive, Content-Length: 41, Content-Type: application/json; charset=utf-8, - Date: Mon, 22 Aug 2022 19:17:08 GMT, + Date: Mon, 29 Aug 2022 17:59:42 GMT, Etag: W/"29-klDahUESBLxHyQ7NiaetCn2CvCI", Server: nginx/1.16.1, X-Rate-Limit-Limit: 1000, X-Rate-Limit-Remaining: 996, - X-Rate-Reset: 16971 + X-Rate-Reset: 21617 ] | 200 | {{% /expand %}} diff --git a/content/flux/v0.x/stdlib/http/requests/post.md b/content/flux/v0.x/stdlib/http/requests/post.md index fc9cde32d..2caf00e27 100644 --- a/content/flux/v0.x/stdlib/http/requests/post.md +++ b/content/flux/v0.x/stdlib/http/requests/post.md @@ -20,7 +20,7 @@ documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: -https://github.com/influxdata/flux/blob/master/stdlib/http/requests/requests.flux#L188-L202 +https://github.com/influxdata/flux/blob/master/stdlib/http/requests/requests.flux#L202-L216 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md @@ -82,6 +82,9 @@ Set of options to control how the request should be performed. ## Examples +- [Make a POST request with a JSON body and decode JSON response](#make-a-post-request-with-a-json-body-and-decode-json-response) +- [Make a POST request with query parameters](#make-a-post-request-with-query-parameters) + ### Make a POST request with a JSON body and decode JSON response ```js @@ -114,3 +117,84 @@ array.from(rows: [data]) {{% /expand %}} {{< /expand-wrapper >}} + +### Make a POST request with query parameters + +```js +import "http/requests" + +response = + requests.post(url: "http://example.com", params: ["start": ["100"], "interval": ["1h", "1d"]]) + +// Full URL: http://example.com?start=100&interval=1h&interval=1d +requests.peek(response: response) + +``` + +{{< expand-wrapper >}} +{{% expand "View example output" %}} + +#### Output data + +| statusCode | body | headers | duration | +| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | +| 200 | + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + + | [ + Accept-Ranges: bytes, + Cache-Control: max-age=604800, + Content-Type: text/html; charset=UTF-8, + Date: Mon, 29 Aug 2022 17:59:43 GMT, + Etag: "3147526947+gzip", + Expires: Mon, 05 Sep 2022 17:59:43 GMT, + Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT, + Server: EOS (vny/0452), + Vary: Accept-Encoding +] | 151995957 | + +{{% /expand %}} +{{< /expand-wrapper >}} diff --git a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md index df0024dd0..f5c064f31 100644 --- a/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md +++ b/content/flux/v0.x/stdlib/influxdata/influxdb/monitor/deadman.md @@ -109,17 +109,16 @@ data ### Detect if a host hasn't reported since a relative time -Use `experimental.addDuration()` to return a time value relative to a specified time. +Use `date.add()` to return a time value relative to a specified time. ```js import "influxdata/influxdb/monitor" -import "experimental" +import "date" -// from(bucket: "example-bucket") |> range(start: -10m) |> filter(fn: (r) => r._measurement == "example-measurement") - |> monitor.deadman(t: experimental.addDuration(d: -5m, from: now())) + |> monitor.deadman(t: date.add(d: -5m, to: now())) ``` diff --git a/content/flux/v0.x/stdlib/universe/union.md b/content/flux/v0.x/stdlib/universe/union.md index f58c95992..0685dbab9 100644 --- a/content/flux/v0.x/stdlib/universe/union.md +++ b/content/flux/v0.x/stdlib/universe/union.md @@ -149,14 +149,14 @@ union(tables: [t1, t2]) | _time | _value | tag | | -------------------- | ------- | ---- | -| 2021-01-01T00:00:00Z | 1 | foo | -| 2021-01-02T00:00:00Z | 2 | foo | -| 2021-01-03T00:00:00Z | 3 | foo | -| 2021-01-04T00:00:00Z | 4 | foo | | 2021-01-01T00:00:00Z | 0 | bar | | 2021-01-02T00:00:00Z | -1 | bar | | 2021-01-03T00:00:00Z | -2 | bar | | 2021-01-04T00:00:00Z | -3 | bar | +| 2021-01-01T00:00:00Z | 1 | foo | +| 2021-01-02T00:00:00Z | 2 | foo | +| 2021-01-03T00:00:00Z | 3 | foo | +| 2021-01-04T00:00:00Z | 4 | foo | {{% /expand %}} {{< /expand-wrapper >}}