Peek Window
The PEEK command is used to take a look at a window’s current aggregation values.
This is different than a query. The mechanics behind queries is that queries are executed when messages are received from the stream. If there are no messages received from the stream, then queries might not be executed at all. So, if you just need to take an immediate look at the current state (aggregation values) of a window, then you do it with the PEEK command. The PEEK command immediately returns the current value of all aggregations in a window.
Access Rule
Requires WINDOW, STREAM, or ADMIN role.
Syntax
PEEK <window name>;
Example
PEEK last_10_bids;
Output: A JSON formatted confirmation that the window has been removed.
Sample:
{
"status": 200,
"statements": 1,
"milliseconds": 1,
"details": [
{
"statement": 1,
"response": {
"window_name": "last_10_bids",
"stream_name": "my_bench_stream",
"values": {
"empty": false,
"full": true,
"count": 10,
"count_distinct": 10,
"first": 23.0,
"last": 32.0,
"max": 32.0,
"median": 27.5,
"min": 23.0,
"mode": 23.0,
"previous": 31.0,
"slope": 1.0,
"sum": 275.0,
"pop_variance": 8.25,
"sample_variance": 9.166666666666666,
"pop_stddev": 2.8722813232690143,
"sample_stddev": 3.0276503540974917
}
}
}
]
}
NOTE: To make the most of RioDB, do not write external applications that run PEEK in a loop. RioDB is designed from the ground up to avoid that poor practice. The best practice is to let RioDB be the “loop” and trigger whatever action as needed, even if the action is to just update content in some dashboard.