Skip to content

Commit 5b46209

Browse files
committed
TNTP-2109: Add bucket_ref to map calls
1 parent 16be0b4 commit 5b46209

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

crud/common/call.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ function call.map(vshard_router, func_name, func_args, opts)
186186
request_timeout = opts.mode == 'read' and opts.request_timeout or nil,
187187
}
188188
while iter:has_next() do
189-
local args, replicaset, replicaset_id = iter:get()
189+
local args, replicaset, replicaset_id, bucket_ids = iter:get()
190190

191191
local future, err = retry_call_with_master_discovery(replicaset, vshard_call_name,
192-
func_name, args, call_opts, opts.mode, {}) -- TODO: provide bucket_ids
192+
func_name, args, call_opts, opts.mode, bucket_ids)
193193

194194
if err ~= nil then
195195
local result_info = {

crud/common/map_call_cases/base_iter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function BaseIterator:get()
7272
local replicaset = self.next_replicaset
7373
self.next_index, self.next_replicaset = next(self.replicasets, self.next_index)
7474

75-
return self.func_args, replicaset, replicaset_id
75+
return self.func_args, replicaset, replicaset_id, {}
7676
end
7777

7878
return BaseIterator

crud/common/map_call_cases/batch_insert_iter.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ function BatchInsertIterator:get()
7676
self.next_batch.tuples,
7777
self.opts,
7878
}
79+
local bucket_ids = self.next_batch.bucket_ids
7980

8081
self.next_index, self.next_batch = next(self.batches_by_replicasets, self.next_index)
8182

82-
return func_args, replicaset, replicaset_id
83+
return func_args, replicaset, replicaset_id, bucket_ids
8384
end
8485

8586
return BatchInsertIterator

crud/common/map_call_cases/batch_upsert_iter.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ function BatchUpsertIterator:get()
8585
self.next_batch.operations,
8686
self.opts,
8787
}
88+
local bucket_ids = self.next_batch.bucket_ids
8889

8990
self.next_index, self.next_batch = next(self.batches_by_replicasets, self.next_index)
9091

91-
return func_args, replicaset, replicaset_id
92+
return func_args, replicaset, replicaset_id, bucket_ids
9293
end
9394

9495
return BatchUpsertIterator

crud/common/sharding/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,10 @@ function sharding.split_tuples_by_replicaset(vshard_router, tuples, space, opts)
324324
local record_by_replicaset = batches[replicaset_id] or {
325325
replicaset = replicaset,
326326
tuples = {},
327+
bucket_ids = {},
327328
}
328329
table.insert(record_by_replicaset.tuples, tuple)
330+
record_by_replicaset.bucket_ids[sharding_data.bucket_id] = true
329331

330332
if opts.operations ~= nil then
331333
record_by_replicaset.operations = record_by_replicaset.operations or {}
@@ -335,6 +337,14 @@ function sharding.split_tuples_by_replicaset(vshard_router, tuples, space, opts)
335337
batches[replicaset_id] = record_by_replicaset
336338
end
337339

340+
for _, rbr in pairs(batches) do
341+
local bucket_ids = {}
342+
for bid, _ in pairs(rbr.bucket_ids) do
343+
table.insert(bucket_ids, bid)
344+
end
345+
rbr.bucket_ids = bucket_ids
346+
end
347+
338348
return {
339349
batches = batches,
340350
sharding_func_hash = sharding_func_hash,

0 commit comments

Comments
 (0)