Skip to content

Commit d44d2bf

Browse files
authored
Add read view pagination (#4384)
Resolves tarantool/enterprise_doc#218, #4281
1 parent 70493eb commit d44d2bf

File tree

1 file changed

+36
-8
lines changed

1 file changed

+36
-8
lines changed

doc/enterprise/read_views.rst

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Limitations
2828

2929
Read views have the following limitations:
3030

31-
- Only the :ref:`memtx <engines-memtx>` engine is supported.
32-
- Only TREE and HASH :ref:`indexes <index-types>` are supported.
33-
- Pagination (the :ref:`after <box_index-select>` option) is supported only for TREE indexes.
3431

32+
- Only the :ref:`memtx <engines-memtx>` engine is supported.
33+
- Only :ref:`TREE <indexes-tree>`, :ref:`HASH <indexes-hash>` and :ref:`functional <box_space-index_func>`
34+
indexes are supported.
3535

3636
.. _working_with_read_views:
3737

@@ -104,8 +104,39 @@ Similarly, you can retrieve data by the specific index.
104104
- [3, 'Ace of Base', 1987]
105105
...
106106
107+
Pagination is supported in read views in the same ways as in ``select`` requests
108+
to spaces: using the ``fetch_pos`` and ``after`` arguments. To get the cursor position
109+
after executing a request on a read view, set ``fetch_pos`` to ``true``:
107110

108-
ADD example with fech_pos and after
111+
.. code-block:: tarantoolsession
112+
113+
tarantool> result, position = read_view1.space.bands:select({}, { limit = 3, fetch_pos = true })
114+
---
115+
...
116+
117+
tarantool> result
118+
---
119+
- - [1, 'Roxette', 1986]
120+
- [2, 'Scorpions', 1965]
121+
- [3, 'Ace of Base', 1987]
122+
...
123+
124+
tarantool> position
125+
---
126+
- kQM
127+
...
128+
129+
Then, pass this position in the ``after`` parameter of a request to get the
130+
next data chunk:
131+
132+
.. code-block:: tarantoolsession
133+
134+
tarantool> read_view1.space.bands:select({}, { limit = 3, after = position })
135+
---
136+
- - [4, 'The Beatles', 1960]
137+
- [5, 'Pink Floyd', 1965]
138+
- [6, 'The Rolling Stones', 1962]
139+
...
109140
110141
.. _closing_read_view:
111142

@@ -133,7 +164,6 @@ On an attempt to use it, an error is raised.
133164
Example
134165
-------
135166

136-
137167
A Tarantool session below demonstrates how to open a read view,
138168
get data from this view, and close it.
139169
To repeat these steps, you need to bootstrap a Tarantool instance
@@ -194,11 +224,9 @@ as described in :ref:`Using data operations <box_space-operations-detailed-examp
194224
---
195225
...
196226
197-
198-
??? ADD example with fetch_pos and after
199227
.. toctree::
200228
:maxdepth: 2
201229
:hidden:
202230

203231
read_views/lua_api
204-
read_views/c_api
232+
read_views/c_api

0 commit comments

Comments
 (0)