Skip to content

Commit 2ce915e

Browse files
adds content on stream nearest, latest, earliest [ch1568] (#64)
1 parent 5bc9de5 commit 2ce915e

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

docs/source/working/stream-view-data.rst

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ related performance benefits.
99

1010
View Individual Data Points
1111
----------------------------
12-
To view the values directly, call the :code:`values` method which will
12+
To view the values directly, call the :code:`Stream.values` method which will
1313
fully materialize the stream values at the stream version you specify (use the
1414
default value of zero as the latest version). A :code:`start` and :code:`end`
1515
argument is required when making this request.
1616

17-
Calling :code:`values` will return a series of :code:`tuple`, with each item containing a
17+
Calling :code:`Stream.values` will return a series of :code:`tuple`, with each item containing a
1818
:code:`RawPoint`, and version of the stream (:code:`int`). As described in the
1919
API reference, a :code:`RawPoint` has both a :code:`time` and :code:`value`
2020
property.
@@ -33,6 +33,29 @@ property.
3333
...
3434
3535
36+
Helpers for Dates/Times
37+
~~~~~~~~~~~~~~~~~~~~~~~~~
38+
39+
If you are interested in finding the closest point to a particular datetime, there
40+
is the :code:`Stream.nearest` method. Alternatively, if you want to know the first or
41+
last points in a stream, you can call the :code:`Stream.earliest` and :code:`Stream.latest`
42+
methods. These two are often useful if you would like to view all of the data
43+
within the stream using the :code:`Stream.windows` method below (it is not recommended that
44+
you query for all the data using the :code:`Stream.values` method due to the memory
45+
consumption implied). Each of these three methods returns a tuple containing a
46+
RawPoint and the data version number. The exact timestamp can be obtained from the
47+
RawPoint. Keep in mind that all of these methods accept a :code:`version` argument so that
48+
you can ask for the earliest, latest, or nearest point from a previous version of the stream.
49+
50+
.. code-block:: python
51+
52+
stream = db.stream_from_uuid("6f8ebaf0-78ea-416e-a0ff-5c3c5d83c279")
53+
stream.earliest()
54+
>> (RawPoint(1364860800000000000, 42516.03), 3934)
55+
stream.earliest()[0].time
56+
>> 1364860800000000000
57+
58+
3659
View Windows of Data
3760
--------------------
3861
If you don't need to view every single point of data, then it is faster to view
@@ -57,7 +80,7 @@ cover.
5780

5881
aligned_windows
5982
^^^^^^^^^^^^^^^^
60-
For statistical aggregates of your data, the :code:`aligned_windows` method is
83+
For statistical aggregates of your data, the :code:`Stream.aligned_windows` method is
6184
the fastest way to query your data. Each point returned is a statistical
6285
aggregate of all the raw data within a window of width 2^pointwidth
6386
nanoseconds.
@@ -103,7 +126,7 @@ with count == 0 will be omitted.
103126
104127
windows
105128
^^^^^^^^
106-
The :code:`windows` method of a Stream allows you to request windows of data
129+
The :code:`Stream.windows` method of a Stream allows you to request windows of data
107130
while specifying the precision of the data you require. Each window will cover
108131
:code:`width` nanoseconds in length. Precision of the result is determined by
109132
the :code:`depth` parameter such that each window will be accurate to

0 commit comments

Comments
 (0)