Skip to content

Commit 1cb951a

Browse files
committed
map: rename BatchCursor to MapBatchCursor
All of the other map related types have this prefix, so make BatchCursor the same. Signed-off-by: Lorenz Bauer <[email protected]>
1 parent b0728bc commit 1cb951a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

map.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ func (m *Map) guessNonExistentKey() ([]byte, error) {
975975
// ErrKeyNotExist is returned when the batch lookup has reached
976976
// the end of all possible results, even when partial results
977977
// are returned. It should be used to evaluate when lookup is "done".
978-
func (m *Map) BatchLookup(cursor *BatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
978+
func (m *Map) BatchLookup(cursor *MapBatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
979979
return m.batchLookup(sys.BPF_MAP_LOOKUP_BATCH, cursor, keysOut, valuesOut, opts)
980980
}
981981

@@ -995,17 +995,17 @@ func (m *Map) BatchLookup(cursor *BatchCursor, keysOut, valuesOut interface{}, o
995995
// ErrKeyNotExist is returned when the batch lookup has reached
996996
// the end of all possible results, even when partial results
997997
// are returned. It should be used to evaluate when lookup is "done".
998-
func (m *Map) BatchLookupAndDelete(cursor *BatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
998+
func (m *Map) BatchLookupAndDelete(cursor *MapBatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
999999
return m.batchLookup(sys.BPF_MAP_LOOKUP_AND_DELETE_BATCH, cursor, keysOut, valuesOut, opts)
10001000
}
10011001

1002-
// BatchCursor represents a starting point for a batch operation.
1003-
type BatchCursor struct {
1002+
// MapBatchCursor represents a starting point for a batch operation.
1003+
type MapBatchCursor struct {
10041004
m *Map
10051005
opaque []byte
10061006
}
10071007

1008-
func (m *Map) batchLookup(cmd sys.Cmd, cursor *BatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
1008+
func (m *Map) batchLookup(cmd sys.Cmd, cursor *MapBatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
10091009
if m.typ.hasPerCPUValue() {
10101010
return m.batchLookupPerCPU(cmd, cursor, keysOut, valuesOut, opts)
10111011
}
@@ -1030,7 +1030,7 @@ func (m *Map) batchLookup(cmd sys.Cmd, cursor *BatchCursor, keysOut, valuesOut i
10301030
return n, nil
10311031
}
10321032

1033-
func (m *Map) batchLookupPerCPU(cmd sys.Cmd, cursor *BatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
1033+
func (m *Map) batchLookupPerCPU(cmd sys.Cmd, cursor *MapBatchCursor, keysOut, valuesOut interface{}, opts *BatchOptions) (int, error) {
10341034
count, err := sliceLen(keysOut)
10351035
if err != nil {
10361036
return 0, fmt.Errorf("keys: %w", err)
@@ -1052,7 +1052,7 @@ func (m *Map) batchLookupPerCPU(cmd sys.Cmd, cursor *BatchCursor, keysOut, value
10521052
return n, sysErr
10531053
}
10541054

1055-
func (m *Map) batchLookupCmd(cmd sys.Cmd, cursor *BatchCursor, count int, keysOut any, valuePtr sys.Pointer, opts *BatchOptions) (int, error) {
1055+
func (m *Map) batchLookupCmd(cmd sys.Cmd, cursor *MapBatchCursor, count int, keysOut any, valuePtr sys.Pointer, opts *BatchOptions) (int, error) {
10561056
cursorLen := int(m.keySize)
10571057
if cursorLen < 4 {
10581058
// * generic_map_lookup_batch requires that batch_out is key_size bytes.

map_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func TestMapBatch(t *testing.T) {
156156
lookupKeys := make([]uint32, n)
157157
lookupValues := make([]uint32, n*possibleCPU)
158158

159-
var cursor BatchCursor
159+
var cursor MapBatchCursor
160160
var total int
161161
for {
162162
count, err = m.BatchLookup(&cursor, lookupKeys, lookupValues, nil)
@@ -182,7 +182,7 @@ func TestMapBatch(t *testing.T) {
182182
return
183183
}
184184

185-
cursor = BatchCursor{}
185+
cursor = MapBatchCursor{}
186186
total = 0
187187
for {
188188
count, err = m.BatchLookupAndDelete(&cursor, lookupKeys, lookupValues, nil)
@@ -236,7 +236,7 @@ func TestMapBatchCursorReuse(t *testing.T) {
236236

237237
tmp := make([]uint32, 2)
238238

239-
var cursor BatchCursor
239+
var cursor MapBatchCursor
240240
_, err = arr1.BatchLookup(&cursor, tmp, tmp, nil)
241241
testutils.SkipIfNotSupported(t, err)
242242
qt.Assert(t, qt.IsNil(err))
@@ -356,7 +356,7 @@ func TestBatchMapWithLock(t *testing.T) {
356356
t.Fatalf("BatchUpdate: expected count, %d, to be %d", count, len(keys))
357357
}
358358

359-
var cursor BatchCursor
359+
var cursor MapBatchCursor
360360
lookupKeys := make([]uint32, 2)
361361
lookupValues := make([]spinLockValue, 2)
362362
count, err = m.BatchLookup(&cursor, lookupKeys, lookupValues, &BatchOptions{ElemFlags: uint64(LookupLock)})
@@ -367,7 +367,7 @@ func TestBatchMapWithLock(t *testing.T) {
367367
t.Fatalf("BatchLookup: expected two keys, got %d", count)
368368
}
369369

370-
cursor = BatchCursor{}
370+
cursor = MapBatchCursor{}
371371
deleteKeys := []uint32{0, 1}
372372
deleteValues := make([]spinLockValue, 2)
373373
count, err = m.BatchLookupAndDelete(&cursor, deleteKeys, deleteValues, nil)
@@ -1146,7 +1146,7 @@ func TestMapBatchLookupAllocations(t *testing.T) {
11461146
}
11471147
defer arr.Close()
11481148

1149-
var cursor BatchCursor
1149+
var cursor MapBatchCursor
11501150
tmp := make([]uint32, 2)
11511151
input := any(tmp)
11521152

@@ -2151,7 +2151,7 @@ func BenchmarkIterate(b *testing.B) {
21512151
b.ResetTimer()
21522152

21532153
for i := 0; i < b.N; i++ {
2154-
var cursor BatchCursor
2154+
var cursor MapBatchCursor
21552155
for {
21562156
_, err := m.BatchLookup(&cursor, k, v, nil)
21572157
if errors.Is(err, ErrKeyNotExist) {
@@ -2178,7 +2178,7 @@ func BenchmarkIterate(b *testing.B) {
21782178
}
21792179
b.StartTimer()
21802180

2181-
var cursor BatchCursor
2181+
var cursor MapBatchCursor
21822182
for {
21832183
_, err := m.BatchLookupAndDelete(&cursor, k, v, nil)
21842184
if errors.Is(err, ErrKeyNotExist) {

0 commit comments

Comments
 (0)