2017-02-11 20:20:57 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Columns/IColumn.h>
|
2017-02-11 20:20:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Create a 'selector' to be used in IColumn::scatter method
|
|
|
|
* according to sharding scheme and values of column with sharding key.
|
|
|
|
*
|
|
|
|
* Each of num_shards has its weight. Weight must be small.
|
|
|
|
* 'slots' contains weight elements for each shard, in total - sum of all weight elements.
|
|
|
|
*
|
|
|
|
* Values of column get divided to sum_weight, and modulo of division
|
|
|
|
* will map to corresponding shard through 'slots' array.
|
|
|
|
*
|
|
|
|
* Column must have integer type.
|
|
|
|
* T is type of column elements.
|
|
|
|
*/
|
|
|
|
template <typename T>
|
|
|
|
IColumn::Selector createBlockSelector(
|
2017-04-01 07:20:54 +00:00
|
|
|
const IColumn & column,
|
|
|
|
size_t num_shards,
|
|
|
|
const std::vector<size_t> & slots);
|
2017-02-11 20:20:57 +00:00
|
|
|
|
|
|
|
}
|