'np' and 'pp' (next/previous prefix) iterators
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- lua
- Domain
- documentation
Research direction
Start with the root document at reference/reference_lua/box_index/pairs/ and compare its iterator coverage with the issue description. Document the np and pp behavior, including memtx-only support, non-string fallback, select and pairs availability, and the examples shown here. Check the related development issue for implementation details and consider the work done when the page accurately describes and demonstrates both iterators.
Written by the indexing model from the issue text.
Description
Related dev. issue(s): https://github.com/tarantool/tarantool/issues/9994
Product: Tarantool
Since: 3.2
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/pairs/
SME: @ alyapunov
Details
Now there are two more iterators available: 'np' (next prefix)
and 'pp' (previous prefix). They work only in memtx tree. Also,
if the last part of key is not a string, they degrade to 'gt'
and 'lt' iterators.
These iterators introduce special comparison of the last part of
key (if it is a string). In terms of lua, if s is the search part,
and t is the corresponding tuple part, 'np' iterator searches for
the first tuple with string.sub(t, 1, #s) > s, while 'pp' searches
for the last tuple with string.sub(t, 1, #s) < s.
Comparison of all other parts of the key remains normal.
As usual, these iterators are available both in select and pairs,
in index and space methods.
Similar to all other tree iterators, they change only initial
search of selection. Once the first tuple found, the rest are
selected sequentially in direct (for 'np') or reverse (for 'pp')
order of the index.
For example:
tarantool> s:select{}
---
- - ['a']
- ['aa']
- ['ab']
- ['b']
- ['ba']
- ['bb']
- ['c']
- ['ca']
- ['cb']
...
tarantool> s:select({'b'}, {iterator = 'np'})
---
- - ['c']
- ['ca']
- ['cb']
...
tarantool> s:select({'b'}, {iterator = 'pp'})
---
- - ['ab']
- ['aa']
- ['a']
...
Requested by @ alyapunov in https://github.com/tarantool/tarantool/commit/96df090fe71a7152ddee105eca454efc0c096c28.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tarantool/doc
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Ecosystem: ClawMetry — the Qwen Code reader is now free and open source (follow-up to #9294 / #9338) Opencategory/integration priority/P3 scope/documentation status/ready-for-human type/feature-request
Difficulty 1/5 Under an hour Newbie friendliness 84/100