Flux 0.131.0 (#3160)
* added flux 0.131.0 release notes * Add Flux 'contrib/bonitoo-io/hex' package (#3156) * add hex package, closes #3148 * Apply suggestions from code review Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com> * updated verbiage on working with int and uint types Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com> * Add 'experimental/record' package (#3157) * added experimental/record package * Update content/flux/v0.x/stdlib/experimental/record/_index.md Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com>pull/3162/head
parent
2c646c496f
commit
e5b4c899d7
|
@ -12,6 +12,7 @@ weight: 201
|
|||
flux/v0.x/tags: ["basic types", "data types"]
|
||||
related:
|
||||
- /flux/v0.x/stdlib/universe/bytes/
|
||||
- /flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes/
|
||||
---
|
||||
|
||||
A **bytes** type represents a sequence of byte values.
|
||||
|
@ -23,7 +24,7 @@ A **bytes** type represents a sequence of byte values.
|
|||
|
||||
## Bytes syntax
|
||||
Flux does not provide a bytes literal syntax.
|
||||
Use the [`bytes()` function](/flux/v0.x/stdlib/universe/bytes) to convert a
|
||||
Use the [`bytes()` function](/flux/v0.x/stdlib/universe/bytes/) to convert a
|
||||
**string** into bytes.
|
||||
|
||||
```js
|
||||
|
@ -35,34 +36,16 @@ bytes(v: "hello")
|
|||
Only string types can be converted to bytes.
|
||||
{{% /note %}}
|
||||
|
||||
## Convert a column to bytes
|
||||
## Convert strings to bytes
|
||||
Use `bytes()` or `hex.bytes()` to convert strings to bytes.
|
||||
|
||||
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and rewrite rows.
|
||||
2. Use [`bytes()`](/flux/v0.x/stdlib/universe/bytes/) to convert column values to bytes.
|
||||
- [`bytes()`](/flux/v0.x/stdlib/universe/bytes/): Convert a string to bytes
|
||||
- [`hex.bytes()`](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/bytes/): Decode hexadecimal value and convert it to bytes.
|
||||
|
||||
#### Convert a hexadecimal string to bytes
|
||||
```js
|
||||
data
|
||||
|> map(fn: (r) => ({ r with _value: time(v: r._value) }))
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.bytes(v: "FF5733")
|
||||
// Returns [255 87 51] (bytes)
|
||||
```
|
||||
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
##### Given the following input data:
|
||||
| \_time | \_value _<span style="opacity:.5">(string)</span>_ |
|
||||
| :------------------- | -------------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | foo |
|
||||
| 2021-01-01T02:00:00Z | bar |
|
||||
| 2021-01-01T03:00:00Z | baz |
|
||||
| 2021-01-01T04:00:00Z | quz |
|
||||
{{% /flex-content %}}
|
||||
|
||||
{{% flex-content %}}
|
||||
##### The example above returns:
|
||||
| \_time | \_value _<span style="opacity:.5">(bytes)</span>_ |
|
||||
| :------------------- | -------------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | [102 111 111] |
|
||||
| 2021-01-01T02:00:00Z | [98 97 114] |
|
||||
| 2021-01-01T03:00:00Z | [98 97 122] |
|
||||
| 2021-01-01T04:00:00Z | [113 117 122] |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
|
|
|
@ -13,6 +13,7 @@ flux/v0.x/tags: ["basic types", "numeric types", "data types"]
|
|||
related:
|
||||
- /flux/v0.x/stdlib/universe/int/
|
||||
- /flux/v0.x/stdlib/universe/toint/
|
||||
- /flux/v0.x/stdlib/contrib/bonitoo-io/hex/int/
|
||||
list_code_example: |
|
||||
```js
|
||||
0
|
||||
|
@ -74,10 +75,13 @@ int(v: 12.54)
|
|||
|
||||
{{% note %}}
|
||||
#### Round float values before converting to integers
|
||||
Being Flux _truncates_ the [float](/flux/v0.x/data-types/basic/float/) value at the decimal when converting to an integer, for example `12.54` to `12`, you may want to round float values to the nearest whole number `12.54` to `13` before converting. To do this:
|
||||
When converting [floats](/flux/v0.x/data-types/basic/float/) to integers,
|
||||
`int()` _truncates_ the float value at the decimal (for example `12.54` to `12`).
|
||||
You may want to round float values to the nearest whole number (`12.54` to `13`) before converting.
|
||||
To do this:
|
||||
|
||||
1. Import the [`math` package](/flux/v0.x/stdlib/math/).
|
||||
2. Use [`math.round()`](/flux/v0.x/stdlib/math/round/) to round the the float value
|
||||
2. Use [`math.round()`](/flux/v0.x/stdlib/math/round/) to round the float value
|
||||
before converting it to an integer.
|
||||
|
||||
```js
|
||||
|
@ -88,6 +92,20 @@ int(v: math.round(x: 12.54))
|
|||
```
|
||||
{{% /note %}}
|
||||
|
||||
### Convert a hexadecimal string to an integer
|
||||
To convert a hexadecimal string representation of a number to an integer:
|
||||
|
||||
1. Import the [`contrib/bonitoo-io/hex` package](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/).
|
||||
2. Use [`hex.int()`](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/int/) to convert
|
||||
the hexadecimal string to an integer.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.int(v: "1e240")
|
||||
// Returns 123456
|
||||
```
|
||||
|
||||
### Convert columns to integers
|
||||
Flux lets you iterate over rows in a [stream of tables](/flux/v0.x/get-started/data-model/#stream-of-tables)
|
||||
and convert columns to integers.
|
||||
|
|
|
@ -69,6 +69,7 @@ string(v: 42)
|
|||
// Returns "42"
|
||||
```
|
||||
|
||||
### Convert regular expressions to strings
|
||||
To convert a [regular expression](/flux/v0.x/data-types/regexp/) to a string:
|
||||
|
||||
1. Import the [`regexp` package](/flux/v0.x/stdlib/regexp/).
|
||||
|
@ -82,6 +83,20 @@ regexp.getString(r: /[a-zA-Z]/)
|
|||
// Returns [a-zA-Z] (string)
|
||||
```
|
||||
|
||||
### Convert data types to hexadecimal strings
|
||||
To convert [basic types](/flux/v0.x/data-types/basic/) to hexadecimal strings:
|
||||
|
||||
1. Import the [`contrib/bonitoo-io/hex` package](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/).
|
||||
2. Use [`hex.string()`](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/string/) to convert
|
||||
other a value to a hexadecimal string.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: 123456)
|
||||
// Returns 1e240
|
||||
```
|
||||
|
||||
### Convert columns to strings
|
||||
Flux lets you iterate over rows in a [stream of tables](/flux/v0.x/get-started/data-model/#stream-of-tables)
|
||||
and convert columns to strings.
|
||||
|
|
|
@ -13,6 +13,7 @@ flux/v0.x/tags: ["basic types", "numeric types", "data types"]
|
|||
related:
|
||||
- /flux/v0.x/stdlib/universe/uint/
|
||||
- /flux/v0.x/stdlib/universe/touint/
|
||||
- /flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint/
|
||||
list_code_example: |
|
||||
```js
|
||||
uint(v: 123)
|
||||
|
@ -72,10 +73,13 @@ uint(v: -54321)
|
|||
|
||||
{{% note %}}
|
||||
#### Round float values before converting to uintegers
|
||||
Being Flux _truncates_ the [float](/flux/v0.x/data-types/basic/float/) value at the decimal when converting to a uinteger, for example `12.54` to `12`, you may want to round float values to the nearest whole number `12.54` to `13` before converting. To do this:
|
||||
When converting [floats](/flux/v0.x/data-types/basic/float/) to integers,
|
||||
`uint()` _truncates_ the float value at the decimal (for example `12.54` to `12`).
|
||||
You may want to round float values to the nearest whole number (`12.54` to `13`) before converting.
|
||||
To do this:
|
||||
|
||||
1. Import the [`math` package](/flux/v0.x/stdlib/math/).
|
||||
2. Use [`math.round()`](/flux/v0.x/stdlib/math/round/) to round the the float value
|
||||
2. Use [`math.round()`](/flux/v0.x/stdlib/math/round/) to round the float value
|
||||
before converting it to a uinteger.
|
||||
|
||||
```js
|
||||
|
@ -86,6 +90,20 @@ uint(v: math.round(x: 12.54))
|
|||
```
|
||||
{{% /note %}}
|
||||
|
||||
### Convert a hexadecimal string to a uinteger
|
||||
To convert a hexadecimal string representation of a number to a uinteger:
|
||||
|
||||
1. Import the [`contrib/bonitoo-io/hex` package](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/).
|
||||
2. Use [`hex.uint()`](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/uint/) to convert
|
||||
the hexadecimal string to a uinteger.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.uint(v: "-1e240")
|
||||
// Returns 123456
|
||||
```
|
||||
|
||||
### Convert columns to uintegers
|
||||
Flux lets you iterate over rows in a [stream of tables](/flux/v0.x/get-started/data-model/#stream-of-tables)
|
||||
and convert columns to uintegers.
|
||||
|
|
|
@ -10,6 +10,23 @@ aliases:
|
|||
- /influxdb/cloud/reference/release-notes/flux/
|
||||
---
|
||||
|
||||
## v0.131.0 [2021-09-20]
|
||||
|
||||
### Features
|
||||
- Update `group` to use new `GroupTransformation` interface.
|
||||
- Add [`experimental/record` package](/flux/v0.x/stdlib/experimental/record/).
|
||||
- Embed compiled Flux standard library instead of compiling at runtime.
|
||||
- Add [`contrib/bonitoo-io/hex` package](/flux/v0.x/stdlib/contrib/bonitoo-io/hex/)
|
||||
to work with hexadecimal string values.
|
||||
|
||||
### Bug fixes
|
||||
- Disallow setting [`allowAllFiles` parameter](https://github.com/go-sql-driver/mysql#allowallfiles)
|
||||
in [MySQL DSNs](/flux/v0.x/query-data/sql/mysql/#mysql-data-source-name).
|
||||
- Downgrade [Snowflake](/flux/v0.x/query-data/sql/snowflake/) version.
|
||||
- Add _null_ support to optimized `repeat` function.
|
||||
|
||||
---
|
||||
|
||||
## v0.130.0 [2021-09-15]
|
||||
|
||||
### Features
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
title: Flux hex package
|
||||
list_title: hex package
|
||||
description: >
|
||||
The Flux `hex` package provides functions that convert hexadecimal strings into Flux data types.
|
||||
Import the `contrib/bonitoo-io/hex` package.
|
||||
menu:
|
||||
flux_0_x_ref:
|
||||
name: hex
|
||||
parent: bonitoo-io
|
||||
weight: 202
|
||||
flux/v0.x/tags: [functions, hex, package]
|
||||
cascade:
|
||||
introduced: 0.131.0
|
||||
append:
|
||||
block: note
|
||||
content: |
|
||||
#### Package author and maintainer
|
||||
**Github:** [@bonitoo-io](https://github.com/bonitoo-io), [@sranka](https://github.com/sranka)
|
||||
**InfluxDB Slack:** [@sranka](https://influxdata.com/slack)
|
||||
---
|
||||
|
||||
The Flux `hex` package provides functions that convert hexadecimal strings into Flux data types.
|
||||
Import the `contrib/bonitoo-io/hex` package.
|
||||
|
||||
## Functions
|
||||
{{< children type="functions" show="pages" >}}
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
title: hex.bytes() function
|
||||
description: >
|
||||
`hex.bytes()` converts a hexadecimal string to bytes.
|
||||
menu:
|
||||
flux_0_x_ref:
|
||||
name: hex.bytes
|
||||
parent: hex
|
||||
weight: 302
|
||||
related:
|
||||
- /flux/v0.x/data-types/basic/bytes/
|
||||
flux/v0.x/tags: [type-conversions]
|
||||
---
|
||||
|
||||
`hex.bytes()` decodes a hexadecimal string and converts the decoded value to bytes.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.bytes(v: "6869")
|
||||
|
||||
// Returns [104 105] (the bytes representation of "hi")
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### v {data-type="string"}
|
||||
Value to convert.
|
||||
|
||||
## Examples
|
||||
|
||||
#### Convert a hexadecimal string to bytes
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.bytes(v: "FF5733")
|
||||
|
||||
// Returns [255 87 51] (bytes)
|
||||
```
|
|
@ -0,0 +1,108 @@
|
|||
---
|
||||
title: hex.int() function
|
||||
description: >
|
||||
`hex.int()` converts a hexadecimal string representation of a number to an integer.
|
||||
menu:
|
||||
flux_0_x_ref:
|
||||
name: hex.int
|
||||
parent: hex
|
||||
weight: 302
|
||||
related:
|
||||
- /flux/v0.x/data-types/basic/int/
|
||||
flux/v0.x/tags: [type-conversions]
|
||||
---
|
||||
|
||||
`hex.int()` converts a hexadecimal string representation of a number to an integer.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.int(v: "4d2")
|
||||
|
||||
// Returns 1234
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### v {data-type="string"}
|
||||
Value to convert.
|
||||
|
||||
## Examples
|
||||
|
||||
- [Convert a hexadecimal string to an integer](#convert-a-hexadecimal-string-to-an-integer)
|
||||
- [Convert all hexadecimal string values in a column to integers](#convert-all-hexadecimal-string-values-in-a-column-to-integers)
|
||||
|
||||
#### Convert a hexadecimal string to an integer
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.int(v: "-d431")
|
||||
|
||||
// Returns -54321
|
||||
```
|
||||
|
||||
#### Convert all hexadecimal string values in a column to integers
|
||||
|
||||
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows.
|
||||
2. Use `hex.int()` to update the value of a column.
|
||||
|
||||
_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._
|
||||
|
||||
```js
|
||||
import "sampledata"
|
||||
|
||||
data = sampledata.int()
|
||||
|> map(fn: (r) => ({ r with _value: hex.string(v: r._value) }))
|
||||
|
||||
data
|
||||
|> map(fn:(r) => ({ r with _value: hex.int(v: r._value) }))
|
||||
```
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "View input and output" %}}
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
##### Input data
|
||||
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
|
||||
| :------------------- | :-- | -------------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | t1 | -2 |
|
||||
| 2021-01-01T00:00:10Z | t1 | a |
|
||||
| 2021-01-01T00:00:20Z | t1 | 7 |
|
||||
| 2021-01-01T00:00:30Z | t1 | 11 |
|
||||
| 2021-01-01T00:00:40Z | t1 | f |
|
||||
| 2021-01-01T00:00:50Z | t1 | 4 |
|
||||
|
||||
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
|
||||
| :------------------- | :-- | -------------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | t2 | 13 |
|
||||
| 2021-01-01T00:00:10Z | t2 | 4 |
|
||||
| 2021-01-01T00:00:20Z | t2 | -3 |
|
||||
| 2021-01-01T00:00:30Z | t2 | 13 |
|
||||
| 2021-01-01T00:00:40Z | t2 | d |
|
||||
| 2021-01-01T00:00:50Z | t2 | 1 |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{% flex-content %}}
|
||||
##### Output data
|
||||
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
|
||||
| :-- | :------------------- | ----------------------------------------------: |
|
||||
| t1 | 2021-01-01T00:00:00Z | -2 |
|
||||
| t1 | 2021-01-01T00:00:10Z | 10 |
|
||||
| t1 | 2021-01-01T00:00:20Z | 7 |
|
||||
| t1 | 2021-01-01T00:00:30Z | 17 |
|
||||
| t1 | 2021-01-01T00:00:40Z | 15 |
|
||||
| t1 | 2021-01-01T00:00:50Z | 4 |
|
||||
|
||||
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
|
||||
| :-- | :------------------- | ----------------------------------------------: |
|
||||
| t2 | 2021-01-01T00:00:00Z | 19 |
|
||||
| t2 | 2021-01-01T00:00:10Z | 4 |
|
||||
| t2 | 2021-01-01T00:00:20Z | -3 |
|
||||
| t2 | 2021-01-01T00:00:30Z | 19 |
|
||||
| t2 | 2021-01-01T00:00:40Z | 13 |
|
||||
| t2 | 2021-01-01T00:00:50Z | 1 |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
|
@ -0,0 +1,170 @@
|
|||
---
|
||||
title: hex.string() function
|
||||
description: >
|
||||
`hex.string()` converts a [Flux basic type](/flux/v0.x/data-types/basic/) to a hexadecimal string.
|
||||
menu:
|
||||
flux_0_x_ref:
|
||||
name: hex.string
|
||||
parent: hex
|
||||
weight: 302
|
||||
related:
|
||||
- /flux/v0.x/stdlib/universe/string/
|
||||
flux/v0.x/tags: [type-conversions]
|
||||
---
|
||||
|
||||
`hex.string()` converts a [Flux basic type](/flux/v0.x/data-types/basic/) to a hexadecimal string.
|
||||
The function is similar to [string()](/flux/v0.x/stdlib/universe/string/),
|
||||
but encodes **int, uint, and bytes types** to hexadecimal lowercase characters.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: 1234)
|
||||
|
||||
// Returns 4d2
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### v {data-type="bool, int, uint, float, duration, time, bytes"}
|
||||
Value to convert.
|
||||
|
||||
## Examples
|
||||
|
||||
- [Convert a boolean to a hexadecimal string value](#convert-a-boolean-to-a-hexadecimal-string-value)
|
||||
- [Convert a duration to a hexadecimal string value](#convert-a-duration-to-a-hexadecimal-string-value)
|
||||
- [Convert a time to a hexadecimal string value](#convert-a-time-to-a-hexadecimal-string-value)
|
||||
- [Convert an integer to a hexadecimal string value](#convert-an-integer-to-a-hexadecimal-string-value)
|
||||
- [Convert a uinteger to a hexadecimal string value](#convert-a-uinteger-to-a-hexadecimal-string-value)
|
||||
- [Convert a float to a hexadecimal string value](#convert-a-float-to-a-hexadecimal-string-value)
|
||||
- [Convert bytes to a hexadecimal string value](#convert-bytes-to-a-hexadecimal-string-value)
|
||||
- [Convert all values in a column to hexadecimal string values](#convert-all-values-in-a-column-to-hexadecimal-string-values)
|
||||
|
||||
#### Convert a boolean to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: true)
|
||||
|
||||
// Returns "true"
|
||||
```
|
||||
|
||||
#### Convert a duration to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: 1m)
|
||||
|
||||
// Returns "1m"
|
||||
```
|
||||
|
||||
#### Convert a time to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: 2021-01-01T00:00:00Z)
|
||||
|
||||
// Returns "2021-01-01T00:00:00Z"
|
||||
```
|
||||
|
||||
#### Convert an integer to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: 1234)
|
||||
|
||||
// Returns "4d2"
|
||||
```
|
||||
|
||||
#### Convert a uinteger to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: uint(v: 5678))
|
||||
|
||||
// Returns "162e"
|
||||
```
|
||||
|
||||
#### Convert a float to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: 10.12)
|
||||
|
||||
// Returns "10.12"
|
||||
```
|
||||
|
||||
#### Convert bytes to a hexadecimal string value
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.string(v: bytes(v: "Hello world!"))
|
||||
|
||||
// Returns "48656c6c6f20776f726c6421"
|
||||
```
|
||||
|
||||
#### Convert all values in a column to hexadecimal string values
|
||||
|
||||
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows.
|
||||
2. Use `hex.string()` to update the value of a column.
|
||||
|
||||
_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._
|
||||
|
||||
```js
|
||||
import "sampledata"
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
data = sampledata.int()
|
||||
|> map(fn: (r) => ({ r with _value: r._value * 1000 }))
|
||||
|
||||
data
|
||||
|> map(fn:(r) => ({ r with _value: hex.string(v: r.foo) }))
|
||||
```
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "View input and output" %}}
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
##### Input data
|
||||
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
|
||||
| :-- | :------------------- | -------------------------------------------: |
|
||||
| t1 | 2021-01-01T00:00:00Z | -2000 |
|
||||
| t1 | 2021-01-01T00:00:10Z | 10000 |
|
||||
| t1 | 2021-01-01T00:00:20Z | 7000 |
|
||||
| t1 | 2021-01-01T00:00:30Z | 17000 |
|
||||
| t1 | 2021-01-01T00:00:40Z | 15000 |
|
||||
| t1 | 2021-01-01T00:00:50Z | 4000 |
|
||||
|
||||
| tag | _time | _value _<span style="opacity:.5;">(int)</span>_ |
|
||||
| :-- | :------------------- | -------------------------------------------: |
|
||||
| t2 | 2021-01-01T00:00:00Z | 19000 |
|
||||
| t2 | 2021-01-01T00:00:10Z | 4000 |
|
||||
| t2 | 2021-01-01T00:00:20Z | -3000 |
|
||||
| t2 | 2021-01-01T00:00:30Z | 19000 |
|
||||
| t2 | 2021-01-01T00:00:40Z | 13000 |
|
||||
| t2 | 2021-01-01T00:00:50Z | 1000 |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{% flex-content %}}
|
||||
##### Output data
|
||||
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
|
||||
| :------------------- | :-- | ----------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | t1 | -7d0 |
|
||||
| 2021-01-01T00:00:10Z | t1 | 2710 |
|
||||
| 2021-01-01T00:00:20Z | t1 | 1b58 |
|
||||
| 2021-01-01T00:00:30Z | t1 | 4268 |
|
||||
| 2021-01-01T00:00:40Z | t1 | 3a98 |
|
||||
| 2021-01-01T00:00:50Z | t1 | fa0 |
|
||||
|
||||
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
|
||||
| :------------------- | :-- | ----------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | t2 | 4a38 |
|
||||
| 2021-01-01T00:00:10Z | t2 | fa0 |
|
||||
| 2021-01-01T00:00:20Z | t2 | -bb8 |
|
||||
| 2021-01-01T00:00:30Z | t2 | 4a38 |
|
||||
| 2021-01-01T00:00:40Z | t2 | 32c8 |
|
||||
| 2021-01-01T00:00:50Z | t2 | 3e8 |
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
|
@ -0,0 +1,110 @@
|
|||
---
|
||||
title: hex.uint() function
|
||||
description: >
|
||||
`hex.uint()` converts a hexadecimal string representation of a number to an unsigned integer.
|
||||
menu:
|
||||
flux_0_x_ref:
|
||||
name: hex.uint
|
||||
parent: hex
|
||||
weight: 302
|
||||
related:
|
||||
- /flux/v0.x/data-types/basic/uint/
|
||||
flux/v0.x/tags: [type-conversions]
|
||||
---
|
||||
|
||||
`hex.uint()` converts a hexadecimal string representation of a number to an unsigned integer.
|
||||
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.uint(v: "4d2")
|
||||
|
||||
// Returns 1234
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
### v {data-type="string"}
|
||||
Value to convert.
|
||||
|
||||
## Examples
|
||||
|
||||
- [Convert a hexadecimal string to an unsigned integer](#convert-a-hexadecimal-string-to-an-unsigned-integer)
|
||||
- [Convert all hexadecimal string values in a column to unsigned integers](#convert-all-hexadecimal-string-values-in-a-column-to-unsigned-integers)
|
||||
|
||||
#### Convert a hexadecimal string to an unsigned integer
|
||||
```js
|
||||
import "contrib/bonitoo-io/hex"
|
||||
|
||||
hex.uint(v: "-d431")
|
||||
|
||||
// Returns -54321
|
||||
```
|
||||
|
||||
#### Convert all hexadecimal string values in a column to unsigned integers
|
||||
|
||||
1. Use [`map()`](/flux/v0.x/stdlib/universe/map/) to iterate over and update all input rows.
|
||||
2. Use `hex.uint()` to update the value of a column.
|
||||
|
||||
_The following example uses data provided by the [`sampledata` package](/flux/v0.x/stdlib/sampledata/)._
|
||||
|
||||
```js
|
||||
import "sampledata"
|
||||
|
||||
data = sampledata.uint()
|
||||
|> map(fn: (r) => ({ r with _value: hex.string(v: r._value) }))
|
||||
|
||||
data
|
||||
|> map(fn:(r) => ({ r with _value: hex.uint(v: r._value) }))
|
||||
```
|
||||
|
||||
{{< expand-wrapper >}}
|
||||
{{% expand "View input and output" %}}
|
||||
{{< flex >}}
|
||||
{{% flex-content %}}
|
||||
##### Input data
|
||||
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
|
||||
| :------------------- | :-- | -------------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | t1 | fffffffffffffffe |
|
||||
| 2021-01-01T00:00:10Z | t1 | a |
|
||||
| 2021-01-01T00:00:20Z | t1 | 7 |
|
||||
| 2021-01-01T00:00:30Z | t1 | 11 |
|
||||
| 2021-01-01T00:00:40Z | t1 | f |
|
||||
| 2021-01-01T00:00:50Z | t1 | 4 |
|
||||
|
||||
| _time | tag | _value _<span style="opacity:.5;">(string)</span>_ |
|
||||
| :------------------- | :-- | -------------------------------------------------: |
|
||||
| 2021-01-01T00:00:00Z | t2 | 13 |
|
||||
| 2021-01-01T00:00:10Z | t2 | 4 |
|
||||
| 2021-01-01T00:00:20Z | t2 | fffffffffffffffd |
|
||||
| 2021-01-01T00:00:30Z | t2 | 13 |
|
||||
| 2021-01-01T00:00:40Z | t2 | d |
|
||||
| 2021-01-01T00:00:50Z | t2 | 1 |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{% flex-content %}}
|
||||
##### Output data
|
||||
| tag | _time | _value _<span style="opacity:.5;">(uint)</span>_ |
|
||||
| :-- | :------------------- | -----------------------------------------------: |
|
||||
| t1 | 2021-01-01T00:00:00Z | 18446744073709551614 |
|
||||
| t1 | 2021-01-01T00:00:10Z | 10 |
|
||||
| t1 | 2021-01-01T00:00:20Z | 7 |
|
||||
| t1 | 2021-01-01T00:00:30Z | 17 |
|
||||
| t1 | 2021-01-01T00:00:40Z | 15 |
|
||||
| t1 | 2021-01-01T00:00:50Z | 4 |
|
||||
|
||||
| tag | _time | _value _<span style="opacity:.5;">(uint)</span>_ |
|
||||
| :-- | :------------------- | -----------------------------------------------: |
|
||||
| t2 | 2021-01-01T00:00:00Z | 19 |
|
||||
| t2 | 2021-01-01T00:00:10Z | 4 |
|
||||
| t2 | 2021-01-01T00:00:20Z | 18446744073709551613 |
|
||||
| t2 | 2021-01-01T00:00:30Z | 19 |
|
||||
| t2 | 2021-01-01T00:00:40Z | 13 |
|
||||
| t2 | 2021-01-01T00:00:50Z | 1 |
|
||||
|
||||
{{% /flex-content %}}
|
||||
{{< /flex >}}
|
||||
{{% /expand %}}
|
||||
{{< /expand-wrapper >}}
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
title: tickscript.alert() function
|
||||
description: >
|
||||
The `tickscript.alert()` function function identifies events of varying severity levels
|
||||
The `tickscript.alert()` function identifies events of varying severity levels
|
||||
and writes them to the `statuses` measurement in the InfluxDB
|
||||
`_monitoring` system bucket.
|
||||
menu:
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
title: Flux experimental record package
|
||||
list_title: record package
|
||||
description: >
|
||||
The Flux experimental `record` package provides tools for working with Flux
|
||||
[records](/flux/v0.x/data-types/composite/record/).
|
||||
Import the `experimental/record` package.
|
||||
menu:
|
||||
flux_0_x_ref:
|
||||
name: record
|
||||
parent: experimental
|
||||
weight: 301
|
||||
flux/v0.x/tags: [package]
|
||||
introduced: 0.131.0
|
||||
---
|
||||
|
||||
The Flux experimental `record` package provides tools for working with Flux
|
||||
[records](/flux/v0.x/data-types/composite/record/).
|
||||
Import the `experimental/record` package.
|
||||
|
||||
```
|
||||
import "experimental/record"
|
||||
```
|
||||
|
||||
{{% warn %}}
|
||||
#### This package is an interim solution
|
||||
The `experimental/record` package is an interim solution for
|
||||
[influxdata/flux#3461](https://github.com/influxdata/flux/issues/3461)
|
||||
and will either be removed after this issue is resolved or promoted out of
|
||||
the experimental package if other uses are found.
|
||||
{{% /warn %}}
|
||||
|
||||
## Constants
|
||||
The `experimental/record` package provides the following constants:
|
||||
|
||||
```js
|
||||
record.any = {} // polymorphic record with unconstrained property types
|
||||
```
|
||||
|
||||
### record.any
|
||||
Currently, default function parameter values constrain the parameter's type.
|
||||
`record.any` is a polymorphic record value that can be used as a default
|
||||
record value when input record property types are not known.
|
||||
|
||||
```js
|
||||
addFoo = (r=record.any) => ({ r with foo: "bar" })
|
||||
|
||||
addFoo(r: {})
|
||||
// Returns {foo: "bar"}
|
||||
|
||||
addFoo(r: {baz: "quz", int: 123})
|
||||
// {baz: "quz", int: 123, foo: "bar"}
|
||||
```
|
||||
|
|
@ -39,28 +39,28 @@ Value to convert.
|
|||
|
||||
#### Convert a boolean to a string value
|
||||
```js
|
||||
int(v: true)
|
||||
string(v: true)
|
||||
|
||||
// Returns "true"
|
||||
```
|
||||
|
||||
#### Convert a duration to a string value
|
||||
```js
|
||||
int(v: 1m)
|
||||
string(v: 1m)
|
||||
|
||||
// Returns "1m"
|
||||
```
|
||||
|
||||
#### Convert a time to a string value
|
||||
```js
|
||||
int(v: 2021-01-01T00:00:00Z)
|
||||
string(v: 2021-01-01T00:00:00Z)
|
||||
|
||||
// Returns "2021-01-01T00:00:00Z"
|
||||
```
|
||||
|
||||
#### Convert a float to a string value
|
||||
```js
|
||||
int(v: 10.12)
|
||||
string(v: 10.12)
|
||||
|
||||
// Returns "10.12"
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue