| 1 | #pragma once |
| 2 | |
| 3 | #include <Columns/IColumn.h> |
| 4 | |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | |
| 9 | /** Create a 'selector' to be used in IColumn::scatter method |
| 10 | * according to sharding scheme and values of column with sharding key. |
| 11 | * |
| 12 | * Each of num_shards has its weight. Weight must be small. |
| 13 | * 'slots' contains weight elements for each shard, in total - sum of all weight elements. |
| 14 | * |
| 15 | * Values of column get divided to sum_weight, and modulo of division |
| 16 | * will map to corresponding shard through 'slots' array. |
| 17 | * |
| 18 | * Column must have integer type. |
| 19 | * T is type of column elements. |
| 20 | */ |
| 21 | template <typename T> |
| 22 | IColumn::Selector createBlockSelector( |
| 23 | const IColumn & column, |
| 24 | const std::vector<UInt64> & slots); |
| 25 | |
| 26 | } |
| 27 | |