MCPcopy
hub / github.com/pingcap/tidb / TestMemAwareHandleMapWithPartialHandle

Function TestMemAwareHandleMapWithPartialHandle

pkg/kv/key_test.go:294–336  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

292}
293
294func TestMemAwareHandleMapWithPartialHandle(t *testing.T) {
295 m := NewMemAwareHandleMap[int]()
296 ph1 := NewPartitionHandle(1, IntHandle(1))
297 m.Set(ph1, 1)
298
299 ph2 := NewPartitionHandle(2, IntHandle(1))
300 m.Set(ph2, 2)
301
302 ph3 := NewPartitionHandle(1, IntHandle(3))
303 m.Set(ph3, 5)
304
305 ih := IntHandle(1)
306 m.Set(ih, 3)
307
308 dec := types.NewDecFromInt(1)
309 encoded, err := codec.EncodeKey(stmtctx.NewStmtCtx().TimeZone(), nil, types.NewDecimalDatum(dec))
310 assert.Nil(t, err)
311 assert.Less(t, len(encoded), 9)
312
313 ch, err := NewCommonHandle(encoded)
314 assert.NoError(t, err)
315 m.Set(ch, 4)
316
317 v, ok := m.Get(ph1)
318 assert.True(t, ok)
319 assert.Equal(t, 1, v)
320
321 v, ok = m.Get(ph2)
322 assert.True(t, ok)
323 assert.Equal(t, 2, v)
324
325 v, ok = m.Get(ph3)
326 assert.True(t, ok)
327 assert.Equal(t, 5, v)
328
329 v, ok = m.Get(ih)
330 assert.True(t, ok)
331 assert.Equal(t, 3, v)
332
333 v, ok = m.Get(ch)
334 assert.True(t, ok)
335 assert.Equal(t, 4, v)
336}
337
338func TestKeyRangeDefinition(t *testing.T) {
339 // The struct layout for kv.KeyRange and coprocessor.KeyRange should be exactly the same.

Callers

nothing calls this directly

Calls 12

NewDecFromIntFunction · 0.92
EncodeKeyFunction · 0.92
NewStmtCtxFunction · 0.92
NewDecimalDatumFunction · 0.92
NewPartitionHandleFunction · 0.85
IntHandleTypeAlias · 0.85
NewCommonHandleFunction · 0.85
TimeZoneMethod · 0.80
SetMethod · 0.65
GetMethod · 0.65
EqualMethod · 0.65
LessMethod · 0.45

Tested by

no test coverage detected