flux 0.181.0 release notes and stdlib (#4397)

pull/4402/head
Scott Anderson 2022-08-29 15:19:29 -06:00 committed by GitHub
parent 272b19b259
commit ff91ce8da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 427 additions and 19 deletions

View File

@ -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._

View File

@ -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 %}}

View File

@ -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 >}}

View File

@ -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
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
documentation is generated.
To make updates to this documentation, update the comments above the package
declaration in the Flux source code:
https://github.com/influxdata/flux/blob/master/stdlib/experimental/polyline/polyline.flux
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
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" >}}

View File

@ -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]
---
<!------------------------------------------------------------------------------
IMPORTANT: This page was generated from comments in the Flux source code. Any
edits made directly to this page will be overwritten the next time the
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/experimental/polyline/polyline.flux#L66-L75
Contributing to Flux: https://github.com/influxdata/flux#contributing
Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md
------------------------------------------------------------------------------->
`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 >}}

View File

@ -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

View File

@ -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 %}}

View File

@ -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 | <!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
background-color: #f0f0f2;
margin: 0;
padding: 0;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
div {
width: 600px;
margin: 5em auto;
padding: 2em;
background-color: #fdfdff;
border-radius: 0.5em;
box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
}
a:link, a:visited {
color: #38488f;
text-decoration: none;
}
@media (max-width: 700px) {
div {
margin: 0 auto;
width: auto;
}
}
</style>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>This domain is for use in illustrative examples in documents. You may use this
domain in literature without prior coordination or asking for permission.</p>
<p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>
| [
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 >}}

View File

@ -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()))
```

View File

@ -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 >}}