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

tarantool / crud / 21364862659

26 Jan 2026 04:13PM UTC coverage: 73.492% (-15.0%) from 88.463%
21364862659

push

github

web-flow
Merge f981517ee into a84e19f3e

4253 of 5787 relevant lines covered (73.49%)

55.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.22
/crud/common/map_call_cases/batch_insert_iter.lua
1
local errors = require('errors')
19✔
2

3
local dev_checks = require('crud.common.dev_checks')
19✔
4
local sharding = require('crud.common.sharding')
19✔
5

6
local BaseIterator = require('crud.common.map_call_cases.base_iter')
19✔
7

8
local SplitTuplesError = errors.new_class('SplitTuplesError')
19✔
9

10
local BatchInsertIterator = {}
19✔
11
-- inheritance from BaseIterator
12
setmetatable(BatchInsertIterator, {__index = BaseIterator})
19✔
13

14
--- Create new batch insert iterator for map call
15
--
16
-- @function new
17
--
18
-- @tparam[opt] table opts
19
-- Options of BatchInsertIterator:new
20
-- @tparam[opt] table opts.tuples
21
-- Tuples to be inserted
22
-- @tparam[opt] table opts.space
23
-- Space to be inserted into
24
-- @tparam[opt] table opts.execute_on_storage_opts
25
-- Additional opts for call on storage
26
--
27
-- @return[1] table iterator
28
-- @treturn[2] nil
29
-- @treturn[2] table of tables Error description
30
function BatchInsertIterator:new(opts)
19✔
31
    dev_checks('table', {
16✔
32
        tuples = 'table',
33
        space = 'table',
34
        execute_on_storage_opts = 'table',
35
        vshard_router = 'table',
36
    })
37

38
    local sharding_data, err = sharding.split_tuples_by_replicaset(opts.vshard_router, opts.tuples, opts.space)
16✔
39
    if err ~= nil then
16✔
40
        return nil, SplitTuplesError:new("Failed to split tuples by replicaset: %s", err.err)
×
41
    end
42

43
    local next_index, next_batch = next(sharding_data.batches)
16✔
44

45
    local execute_on_storage_opts = opts.execute_on_storage_opts
16✔
46
    execute_on_storage_opts.sharding_func_hash = sharding_data.sharding_func_hash
16✔
47
    execute_on_storage_opts.sharding_key_hash = sharding_data.sharding_key_hash
16✔
48
    execute_on_storage_opts.skip_sharding_hash_check = sharding_data.skip_sharding_hash_check
16✔
49

50
    local iter = {
16✔
51
        space_name = opts.space.name,
16✔
52
        opts = execute_on_storage_opts,
16✔
53
        batches_by_replicasets = sharding_data.batches,
16✔
54
        next_index = next_index,
16✔
55
        next_batch = next_batch,
16✔
56
    }
57

58
    setmetatable(iter, self)
16✔
59
    self.__index = self
16✔
60

61
    return iter
16✔
62
end
63

64
--- Get function arguments and next replicaset
65
--
66
-- @function get
67
--
68
-- @return[1] table func_args
69
-- @return[2] table replicaset
70
-- @return[3] string replicaset_id
71
function BatchInsertIterator:get()
19✔
72
    local replicaset_id = self.next_index
28✔
73
    local replicaset = self.next_batch.replicaset
28✔
74
    local func_args = {
28✔
75
        self.space_name,
28✔
76
        self.next_batch.tuples,
28✔
77
        self.opts,
28✔
78
    }
79

80
    self.next_index, self.next_batch = next(self.batches_by_replicasets, self.next_index)
28✔
81

82
    return func_args, replicaset, replicaset_id
28✔
83
end
84

85
return BatchInsertIterator
19✔
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