• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / tarantool / 13768461042
88%

Build:
DEFAULT BRANCH: master
Ran 10 Mar 2025 03:40PM UTC
Jobs 1
Files 518
Run time 60min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

10 Mar 2025 03:27PM UTC coverage: 87.461% (+0.01%) from 87.447%
13768461042

push

github

locker
vinyl: implement index quantile method

We find the quantile key assuming that all keys are stored at the
deepest disk layer while newer layers contain incremental updates.
First, we walk over all index ranges overlapping with the target range
and estimate the number of tuples in them. Then we compute the offset of
the quantile key and walk over the index ranges again to find the key.

To achieve that, we need two helper functions:

 1. vy_run_estimate_stmt_count() estimates the number of tuples in
    the given run within the specified range. Basically, it finds
    the number of pages falling in the range, then scales down
    the total number of rows stored in the run proportionally,
    assuming that each page stores approximately the same number
    of rows.

 2. vy_run_estimate_key_at() finds a key at the given offset.
    Like vy_run_estimate_stmt_count(), this function assumes that
    each page stores approximately the same number of rows to
    find the page where the target key is located, then it returns
    the page min key, which should be a good enough approximation.

None of the functions accesses disk (yields).

Note that the target key may happen to be outside the target range, for
example, if the range is so small that there's no page fitting in it.
To follow the index:quantile() function protocol, we ignore such keys
(return NULL).

Also note that runs store extended keys so we need to strip extra parts
before returning the found key to the user.

Closes #11111

@TarantoolBot document
Title: Document `index:quantile()`

The new index method finds a quantile point in an indexed data range.
It takes the quantile level (0 < L < 1) and optionally the target range
boundaries and returns such a key that the ratio of tuples less than
the key equals L.

Example:

```lua
local s = box.schema.space.create('test')
s:create_index('pk')

for i = 1, 100 do
    s:insert({i * i, i})
end

-- Find the median in the whole index.
s.index.pk:quantile(0... (continued)

70034 of 123619 branches covered (56.65%)

89 of 92 new or added lines in 3 files covered. (96.74%)

193 existing lines in 21 files now uncovered.

103159 of 117948 relevant lines covered (87.46%)

1908792.38 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
3
92.53
-0.11% src/box/vinyl.c

Uncovered Existing Lines

Lines Coverage ∆ File
1
85.05
0.0% src/box/memtx_bitset.cc
1
96.12
-0.18% src/box/relay.cc
1
95.78
-0.12% src/box/replication.cc
1
89.64
-0.18% src/box/wal.c
1
97.15
0.2% src/lib/msgpuck/msgpuck.h
1
96.15
-0.05% src/lib/salad/bps_tree.h
2
96.0
0.12% src/box/index.h
2
95.84
-0.11% src/box/iproto.cc
2
93.9
-0.31% src/box/memtx_space.c
2
95.05
-0.62% src/box/raft.c
2
92.53
-0.11% src/box/vinyl.c
2
84.42
0.07% src/box/xlog.c
2
94.25
-0.39% src/box/xrow_update_field.c
2
93.12
0.21% src/lib/core/fiber.c
3
91.59
-0.59% src/box/gc.c
4
93.48
0.0% src/box/session_settings.c
5
90.22
-0.39% src/box/vy_log.c
9
88.14
-7.63% src/box/vy_regulator.c
19
86.97
0.0% src/box/sysview.c
48
94.64
0.19% src/box/memtx_tree.cc
83
83.46
0.46% src/box/index.cc
Jobs
ID Job ID Ran Files Coverage
1 13768461042.1 10 Mar 2025 03:40PM UTC 518
87.46
GitHub Action Run
Source Files on build 13768461042
  • Tree
  • List 518
  • Changed 37
  • Source Changed 0
  • Coverage Changed 37
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • a8df9b57 on github
  • Prev Build on master (#13700612185)
  • Next Build on master (#13786132790)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc