MCPcopy
hub / github.com/cilium/ebpf / BatchUpdate

Method BatchUpdate

map.go:1394–1410  ·  view source on GitHub ↗

BatchUpdate updates the map with multiple keys and values simultaneously. "keys" and "values" must be of type slice, a pointer to a slice or buffer will not work.

(keys, values any, opts *BatchOptions)

Source from the content-addressed store, hash-verified

1392// "keys" and "values" must be of type slice, a pointer
1393// to a slice or buffer will not work.
1394func (m *Map) BatchUpdate(keys, values any, opts *BatchOptions) (int, error) {
1395 if m.typ.hasPerCPUValue() {
1396 return m.batchUpdatePerCPU(keys, values, opts)
1397 }
1398
1399 count, err := batchCount(keys, values)
1400 if err != nil {
1401 return 0, err
1402 }
1403
1404 valuePtr, err := marshalMapSyscallInput(values, count*int(m.valueSize))
1405 if err != nil {
1406 return 0, err
1407 }
1408
1409 return m.batchUpdate(count, keys, valuePtr, opts)
1410}
1411
1412func (m *Map) batchUpdate(count int, keys any, valuePtr sys.Pointer, opts *BatchOptions) (int, error) {
1413 keyPtr, err := marshalMapSyscallInput(keys, count*int(m.keySize))

Callers 5

TestMapBatchFunction · 0.80
TestMapBatchUnprivilegedFunction · 0.80
TestBatchAPIMapDeleteFunction · 0.80
TestBatchMapWithLockFunction · 0.80
BenchmarkIterateFunction · 0.80

Calls 5

batchUpdatePerCPUMethod · 0.95
batchUpdateMethod · 0.95
batchCountFunction · 0.85
marshalMapSyscallInputFunction · 0.85
hasPerCPUValueMethod · 0.80

Tested by 5

TestMapBatchFunction · 0.64
TestMapBatchUnprivilegedFunction · 0.64
TestBatchAPIMapDeleteFunction · 0.64
TestBatchMapWithLockFunction · 0.64
BenchmarkIterateFunction · 0.64