(t *testing.T)
| 292 | } |
| 293 | |
| 294 | func 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 | |
| 338 | func TestKeyRangeDefinition(t *testing.T) { |
| 339 | // The struct layout for kv.KeyRange and coprocessor.KeyRange should be exactly the same. |
nothing calls this directly
no test coverage detected