Ports #
| Port | Direction | Kind | Required | Description |
|---|---|---|---|---|
in | input | records | yes | One JSON array per item. |
out | output | records | yes |
Parameters #
This pipe has no parameters.
When to use it #
- A pipe answers with one array per call: flatten it so that later pipes see one record per line again.
- Undo
std:batchafter the step that needed arrays.
When to use something else
- It flattens one level only, and an item that is not an array fails the run. An empty array simply emits nothing.
How it works #
Three array items go in: an array of 1 and 2, an empty array, and an array holding the array [3] and the number 4. Four items come out: 1, 2, the array [3], and 4. The empty array emits nothing.
Drawn from a real run of the reference implementation.
One level, in order #
Every element of every array item becomes an item of its own, in order. Only one level is flattened: in the drawing the inner array [3] comes out as it is. An empty array emits nothing, and an item that is not a JSON array fails the run.
std:unbatch is the inverse of std:batch, and it is just as useful after any pipe that answers with one array per call. It works on plain arrays only: the frames of a windows stream are objects, not arrays, and a windows output does not connect to this pipe's records input.
A tested example #
Nothing here is invented: this is the test “flattens one level” from the pipe's own portable test file, which every conformant runner must pass.
This test sets no parameters.
[1,2]
[]
[[3],4]1
2
[3]
4The same step as a node of a pipeline.yaml:
nodes:
unbatch:
pipe: std:unbatch
inputs:
in: {from: inputs.in}Run it #
The pipe runs on its own from a shell. The input is the test input above. The quickstart shows how to get the openflange command.
printf '%s\n' '[1,2]' '[]' '[[3],4]' | openflange run std:unbatch1
2
[3]
4Executed with openflange 0.0.1 (go1.27.1 linux/amd64), built from commit 11cf8cc of the reference implementation; the output shown is what it printed, and it matches the test.
Notes from the manifest #
The pipe's manifest, OPENFLANGE.md, carries these notes.
Part of the OpenFlange standard library (std, version 0.1).
Emits every element of every input array as its own item, in order. Elements
are copied as raw bytes (nested values and number literals are preserved).
An empty array contributes nothing. An item that is not an array fails the
run with E_RUNTIME. Only one level is flattened. Inverse of std:batch.
Reference #
- Maturity
- Experimental
- Processing scope
record- Manifest version
0.1.0
- Normative definition: std:unbatch in the standard library specification
- Manifest and tests: std/0.1/unbatch in the specification repository