A new `index:offset_of` method introduced
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
Product: Tarantool
Since: 3.3.0
Root document:
- new page in https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/
- (possibly) https://www.tarantool.io/en/doc/latest/platform/ddl_dml/using_indexes/
SME: @ mkostoevr
Details
The method returns 0-based offset in the index of a first tuple
matching the provided key and iterator. The position is counted from
the beginning or end of the space depending on the iterator direction,
for example:
-- index: {{1}, {3}}
index:offset_of({3}, {iterator = 'eq'}) -- returns 1: [1, <3>]
index:offset_of({3}, {iterator = 'req'}) -- returns 0: [<3>, 1]
In case there's no tuple matching the key and iterator in the index the
function returns the position a matching tuple would be placed at if
existed, for example:
-- index: {{1}, {3}}
index:offset_of({2}, {iterator = 'eq'}) -- 1: [1, <2>, 3]
index:offset_of({4}, {iterator = 'req'}) -- 0: [<4>, 3, 1]
This works with any iterator:
-- index: {{1}, {3}}
index:offset_of({0}, {iterator = 'ge'}) -- 0: [<1>, 3]
index:offset_of({1}, {iterator = 'lt'}) -- 2: [3, 1, <...>]
-- index: {{'b'}, {'bb'}, {'bc'}, {'c'}, {'cc'}}
index:offset_of({'b'}, {iterator = 'np'}) -- 3: [b, bb, bc, <c>, cc]
index:offset_of({'cc'}, {iterator = 'pp'}) -- 1: [cc, <c>, bc, bb, b]
Requested by @mkostoevr in https://github.com/tarantool/tarantool/commit/21e428eaf8335b747e2f6072e3798a3edaef6aac.
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.
Research direction
Start with the new reference page under reference/reference_lua/box_index/ and review whether platform/ddl_dml/using_indexes/ also needs coverage. Document index:offset_of for every iterator behavior and the matching and non-matching examples shown in the issue; it is done when the method's return position and direction rules are clear in the relevant Tarantool documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100