Apply one of the variants

This commit is contained in:
Alexey Milovidov 2020-07-30 02:10:11 +03:00
parent f428c2da70
commit ba6d5d00d9

View File

@ -222,24 +222,6 @@ public:
static_cast<const Derived *>(this)->add(places[i] + place_offset, columns, i, arena);
}
void addBatchLookupTable8(
size_t batch_size,
AggregateDataPtr * places,
size_t place_offset,
std::function<void(AggregateDataPtr &)> init,
const UInt8 * key,
const IColumn ** columns,
Arena * arena) const override
{
for (size_t i = 0; i < batch_size; ++i)
{
AggregateDataPtr & place = places[key[i]];
if (unlikely(!place))
init(place);
static_cast<const Derived *>(this)->add(place + place_offset, columns, i, arena);
}
}
void addBatchSinglePlace(size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena) const override
{
for (size_t i = 0; i < batch_size; ++i)
@ -274,6 +256,45 @@ public:
current_offset = next_offset;
}
}
void addBatchLookupTable8(
size_t batch_size,
AggregateDataPtr * map,
size_t place_offset,
std::function<void(AggregateDataPtr &)> init,
const UInt8 * key,
const IColumn ** columns,
Arena * arena) const override
{
static constexpr size_t UNROLL_COUNT = 8;
size_t i = 0;
size_t batch_size_unrolled = batch_size / UNROLL_COUNT * UNROLL_COUNT;
for (; i < batch_size_unrolled; i += UNROLL_COUNT)
{
AggregateDataPtr places[UNROLL_COUNT];
for (size_t j = 0; j < UNROLL_COUNT; ++j)
{
AggregateDataPtr & place = map[key[i + j]];
if (unlikely(!place))
init(place);
places[j] = place;
}
for (size_t j = 0; j < UNROLL_COUNT; ++j)
static_cast<const Derived *>(this)->add(places[j] + place_offset, columns, i + j, arena);
}
for (; i < batch_size; ++i)
{
AggregateDataPtr & place = map[key[i]];
if (unlikely(!place))
init(place);
static_cast<const Derived *>(this)->add(place + place_offset, columns, i, arena);
}
}
};