(t *testing.T)
| 287 | } |
| 288 | |
| 289 | func TestSplitTable(t *testing.T) { |
| 290 | tbInfo := &model.TableInfo{ |
| 291 | Name: pmodel.NewCIStr("t1"), |
| 292 | ID: rand.Int63(), |
| 293 | Columns: []*model.ColumnInfo{ |
| 294 | { |
| 295 | Name: pmodel.NewCIStr("c0"), |
| 296 | ID: 1, |
| 297 | Offset: 1, |
| 298 | DefaultValue: 0, |
| 299 | State: model.StatePublic, |
| 300 | FieldType: *types.NewFieldType(mysql.TypeLong), |
| 301 | }, |
| 302 | }, |
| 303 | } |
| 304 | defer func(originValue int64) { |
| 305 | minRegionStepValue = originValue |
| 306 | }(minRegionStepValue) |
| 307 | minRegionStepValue = 10 |
| 308 | // range is 0 ~ 100, and split into 10 region. |
| 309 | // So 10 regions range is like below: |
| 310 | // region1: [-inf ~ 10) |
| 311 | // region2: [10 ~ 20) |
| 312 | // region3: [20 ~ 30) |
| 313 | // region4: [30 ~ 40) |
| 314 | // region5: [40 ~ 50) |
| 315 | // region6: [50 ~ 60) |
| 316 | // region7: [60 ~ 70) |
| 317 | // region8: [70 ~ 80) |
| 318 | // region9: [80 ~ 90 ) |
| 319 | // region10: [90 ~ +inf) |
| 320 | ctx := mock.NewContext() |
| 321 | e := &SplitTableRegionExec{ |
| 322 | BaseExecutor: exec.NewBaseExecutor(ctx, nil, 0), |
| 323 | tableInfo: tbInfo, |
| 324 | handleCols: util.NewIntHandleCols(&expression.Column{RetType: types.NewFieldType(mysql.TypeLonglong)}), |
| 325 | lower: []types.Datum{types.NewDatum(0)}, |
| 326 | upper: []types.Datum{types.NewDatum(100)}, |
| 327 | num: 10, |
| 328 | } |
| 329 | valueList, err := e.getSplitTableKeys() |
| 330 | require.NoError(t, err) |
| 331 | require.Len(t, valueList, e.num-1) |
| 332 | |
| 333 | cases := []struct { |
| 334 | value int |
| 335 | lessEqualIdx int |
| 336 | }{ |
| 337 | {-1, -1}, |
| 338 | {0, -1}, |
| 339 | {1, -1}, |
| 340 | {10, 0}, |
| 341 | {11, 0}, |
| 342 | {20, 1}, |
| 343 | {21, 1}, |
| 344 | {31, 2}, |
| 345 | {41, 3}, |
| 346 | {51, 4}, |
nothing calls this directly
no test coverage detected