You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/usage/streaming.rst
+14-28Lines changed: 14 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,13 @@
3
3
Streaming
4
4
=========
5
5
6
-
.. note::
7
-
Data streaming is a novel backend and under active development.
8
-
At the moment, the internal data format is still changing rapidly and is likely not compatible between releases of the openPMD-api.
9
-
10
6
The openPMD API includes a streaming-aware API as well as streaming-enabled backends (currently: ADIOS2).
11
7
12
8
Unlike in file-based backends, the order in which data is put out becomes relevant in streaming-based backends.
13
9
Each iteration will be published as one atomical step by the streaming API (compare the concept of `steps in ADIOS2 <https://adios2.readthedocs.io/en/latest/components/components.html#engine>`_).
14
10
11
+
In order to process Iterations synchronously, and one after another, the openPMD-api has *linear* access modes twinned with each regular, i.e. *random-access* mode (except ``READ_WRITE``, which only supports random-access).
12
+
15
13
Reading
16
14
-------
17
15
@@ -21,37 +19,29 @@ It can be used to read any kind of openPMD-compatible dataset, stream-based and
21
19
C++
22
20
^^^
23
21
24
-
The reading end of the streaming API is activated through use of ``Series::readIterations()`` instead of accessing the field ``Series::iterations`` directly.
25
-
Use of ``Access::READ_LINEAR`` mode is recommended.
26
-
The returned object of type ``ReadIterations`` can be used in a C++11 range-based for loop to iterate over objects of type ``IndexedIteration``.
27
-
This class extends the ``Iteration`` class with a field ``IndexedIteration::iterationIndex``, denoting this iteration's index.
22
+
The reading end of the streaming API is activated through use of ``Access::READ_LINEAR`` instead of ``Access::READ_RANDOM_ACCESS`` (or ``Access::READ_ONLY``). Iterations must be accessed with ``Series::snapshots()`` instead of directly using the field ``Series::iterations``.
28
23
29
-
Iterations are implicitly opened by the Streaming API and ``Iteration::open()`` needs not be called explicitly.
24
+
In ``READ_LINEAR`` mode, Iterations are implicitly opened and ``Iteration::open()`` needs not be called explicitly.
30
25
Users are encouraged to explicitly ``.close()`` the iteration after reading from it.
31
26
Closing the iteration will flush all pending operations on that iteration.
32
27
If an iteration is not closed until the beginning of the next iteration, it will be closed automatically.
33
28
34
-
Note that a closed iteration cannot be reopened.
35
-
This pays tribute to the fact that in streaming mode, an iteration may be dropped by the data source once the data sink has finished reading from it.
29
+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``READ_LINEAR`` is available under the condition that the Series is neither a stream nor that it uses ADIOS2 steps. In a stream, Iterations may be dropped by the writer once the reader has finished reading from it.
36
30
37
31
.. literalinclude:: 10_streaming_read.cpp
38
32
:language: cpp
39
33
40
34
Python
41
35
^^^^^^
42
36
43
-
The reading end of the streaming API is activated through use of ``Series.read_iterations()`` instead of accessing the field ``Series.iterations`` directly.
44
-
Use of ``Access.read_linear`` mode is recommended.
45
-
The returned object of type ``ReadIterations`` can be used in a Python range-based for loop to iterate over objects of type ``IndexedIteration``.
46
-
This class extends the ``Iteration`` class with a field ``IndexedIteration.iteration_index``, denoting this iteration's index.
37
+
The reading end of the streaming API is activated through use of ``Access.read_linear`` instead of ``Access.read_random_access`` (or ``Access.read_only``). Iterations must be accessed with ``Series.snapshots()`` instead of directly using the field ``Series.iterations``.
47
38
48
-
Iterations are implicitly opened by the Streaming API and ``Iteration.open()`` needs not be called explicitly.
39
+
In ``read_linear`` mode, Iterations are implicitly opened and ``Iteration.open()`` needs not be called explicitly.
49
40
Users are encouraged to explicitly ``.close()`` the iteration after reading from it.
50
41
Closing the iteration will flush all pending operations on that iteration.
51
42
If an iteration is not closed until the beginning of the next iteration, it will be closed automatically.
52
43
53
-
Note that a closed iteration cannot be reopened.
54
-
This pays tribute to the fact that in streaming mode, an iteration may be dropped by the data source once the data sink has finished reading from it.
44
+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``read_linear`` is available under the condition that the Series is neither a stream nor that it uses ADIOS2 steps. In a stream, Iterations may be dropped by the writer once the reader has finished reading from it.
55
45
56
46
.. literalinclude:: 10_streaming_read.py
57
47
:language: python3
@@ -65,33 +55,29 @@ It can be used to write any kind of openPMD-compatible dataset, stream-based and
65
55
C++
66
56
^^^
67
57
68
-
The writing end of the streaming API is activated through use of ``Series::writeIterations()`` instead of accessing the field ``Series::iterations`` directly.
69
-
The returned object of type ``WriteIterations`` wraps the field ``Series::iterations``, but exposes only a restricted subset of functionality.
70
-
Using ``WriteIterations::operator[]( uint64_t )`` will automatically open a streaming step for the corresponding iteration.
58
+
The writing end of the streaming API is activated through use of ``Access::CREATE_LINEAR`` instead of ``ACCESS::CREATE_RANDOM_ACCESS`` (or ``Access::CREATE``). Iterations must be accessed with ``Series::snapshots()`` instead of using the field ``Series::iterations`` directly.
59
+
With linear create mode, ``Snapshots::operator[](uint64_t)`` will automatically open a streaming step for each new corresponding iteration.
71
60
72
61
Users are encouraged to explicitly ``.close()`` the iteration after writing to it.
73
62
Closing the iteration will flush all pending operations on that iteration.
74
63
If an iteration is not closed until the next iteration is accessed via ``WriteIterations::operator[]( uint64_t )``, it will be closed automatically.
75
64
76
-
Note that a closed iteration cannot be reopened.
77
-
This pays tribute to the fact that in streaming mode, an iteration is sent to the sink upon closing it and the data source can no longer modify it.
65
+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``CREATE_LINEAR`` is available for non-streaming backends other than ADIOS2 (and in ADIOS2, if using file-based encoding with engine BP5 and engine option ``FlattenSteps=ON``). In a stream, Iterations may not be modified after they have been sent to readers.
78
66
79
67
.. literalinclude:: 10_streaming_write.cpp
80
68
:language: cpp
81
69
82
70
Python
83
71
^^^^^^
84
72
85
-
The writing end of the streaming API is activated through use of ``Series.write_iterations()`` instead of accessing the field ``Series.iterations`` directly.
86
-
The returned object of type ``WriteIterations`` wraps the field ``Series.iterations``, but exposes only a restricted subset of functionality.
87
-
Using ``WriteIterations.__getitem__(index)`` (i.e. the index operator ``series.writeIterations()[index]``) will automatically open a streaming step for the corresponding iteration.
73
+
The writing end of the streaming API is activated through use of ``Access.create_linear`` instead of ``ACCESS.create_random_access`` (or ``Access.create``). Iterations must be accessed with ``Series.snapshots()`` instead of using the field ``Series.iterations`` directly.
74
+
With linear create mode, ``Snapshots.__getitem__(index)`` will automatically open a streaming step for each new corresponding iteration.
88
75
89
76
Users are encouraged to explicitly ``.close()`` the iteration after writing to it.
90
77
Closing the iteration will flush all pending operations on that iteration.
91
78
If an iteration is not closed until the next iteration is accessed via ``WriteIterations.__getitem__(index)``, it will be closed automatically.
92
79
93
-
Note that a closed iteration cannot be reopened.
94
-
This pays tribute to the fact that in streaming mode, an iteration is sent to the sink upon closing it and the data source can no longer modify it.
80
+
Note that a closed iteration can in general not be reopened. Limited support for reopening closed Iterations in ``create_linear`` is available for non-streaming backends other than ADIOS2 (and in ADIOS2, if using file-based encoding with engine BP5 and engine option ``FlattenSteps=ON``). In a stream, Iterations may not be modified after they have been sent to readers.
0 commit comments