Aggregate functions added restrict into batch methods

This commit is contained in:
Maksim Kita 2022-06-15 14:11:10 +02:00
parent 864fd627e1
commit bf6d155170
17 changed files with 66 additions and 66 deletions

View File

@ -76,27 +76,27 @@ public:
data(place).~Data();
}
void add(AggregateDataPtr, const IColumn **, size_t, Arena *) const override
void add(AggregateDataPtr __restrict, const IColumn **, size_t, Arena *) const override
{
}
void merge(AggregateDataPtr, ConstAggregateDataPtr, Arena *) const override
void merge(AggregateDataPtr __restrict, ConstAggregateDataPtr, Arena *) const override
{
}
void serialize(ConstAggregateDataPtr, WriteBuffer & buf, std::optional<size_t> /* version */) const override
void serialize(ConstAggregateDataPtr __restrict, WriteBuffer & buf, std::optional<size_t> /* version */) const override
{
char c = 0;
buf.write(c);
}
void deserialize(AggregateDataPtr /* place */, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override
void deserialize(AggregateDataPtr __restrict /* place */, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override
{
char c = 0;
buf.read(c);
}
void insertResultInto(AggregateDataPtr, IColumn & to, Arena *) const override
void insertResultInto(AggregateDataPtr __restrict, IColumn & to, Arena *) const override
{
to.insertDefault();
}

View File

@ -236,7 +236,7 @@ public:
void addBatchSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena *,
ssize_t if_argument_pos) const final
@ -260,7 +260,7 @@ public:
void addBatchSinglePlaceNotNull(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena *,

View File

@ -41,7 +41,7 @@ public:
memset(place, 0, sizeOfData());
}
void destroy(AggregateDataPtr) const noexcept override
void destroy(AggregateDataPtr __restrict) const noexcept override
{
// nothing
}
@ -61,7 +61,7 @@ public:
return alignof(T);
}
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena *) const override
{
const auto * y_col = static_cast<const ColumnUInt8 *>(columns[category_count]);
bool y = y_col->getData()[row_num];
@ -78,7 +78,7 @@ public:
reinterpret_cast<T *>(place)[category_count * 2 + size_t(y)] += 1;
}
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena *) const override
{
for (size_t i : collections::range(0, category_count + 1))
{
@ -87,12 +87,12 @@ public:
}
}
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf, std::optional<size_t> /* version */) const override
void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> /* version */) const override
{
buf.write(place, sizeOfData());
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override
void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override
{
buf.read(place, sizeOfData());
}

View File

@ -65,7 +65,7 @@ public:
void addBatchSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena *,
ssize_t if_argument_pos) const override
@ -84,7 +84,7 @@ public:
void addBatchSinglePlaceNotNull(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena *,
@ -222,7 +222,7 @@ public:
void addBatchSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena *,
ssize_t if_argument_pos) const override

View File

@ -122,7 +122,7 @@ public:
void addBatchSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t) const override

View File

@ -100,7 +100,7 @@ public:
void addBatch(
size_t row_begin,
size_t row_end,
AggregateDataPtr * places,
AggregateDataPtr * __restrict places,
size_t place_offset,
const IColumn ** columns,
Arena * arena,
@ -112,7 +112,7 @@ public:
void addBatchSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t) const override
@ -123,7 +123,7 @@ public:
void addBatchSinglePlaceNotNull(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena * arena,

View File

@ -362,7 +362,7 @@ public:
void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override { this->data(place).read(buf); }
void predictValues(
ConstAggregateDataPtr place,
ConstAggregateDataPtr __restrict place,
IColumn & to,
const ColumnsWithTypeAndName & arguments,
size_t offset,

View File

@ -105,7 +105,7 @@ public:
DataTypePtr getReturnType() const override { return std::make_shared<DataTypeMap>(DataTypes{key_type, nested_func->getReturnType()}); }
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena) const override
void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena) const override
{
const auto & map_column = assert_cast<const ColumnMap &>(*columns[0]);
const auto & map_nested_tuple = map_column.getNestedData();
@ -160,7 +160,7 @@ public:
}
}
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena * arena) const override
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena * arena) const override
{
auto & merged_maps = this->data(place).merged_maps;
const auto & rhs_maps = this->data(rhs).merged_maps;
@ -178,7 +178,7 @@ public:
}
}
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf, std::optional<size_t> /* version */) const override
void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> /* version */) const override
{
auto & merged_maps = this->data(place).merged_maps;
writeVarUInt(merged_maps.size(), buf);
@ -190,7 +190,7 @@ public:
}
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena * arena) const override
void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena * arena) const override
{
auto & merged_maps = this->data(place).merged_maps;
UInt64 size;
@ -209,7 +209,7 @@ public:
}
}
void insertResultInto(AggregateDataPtr place, IColumn & to, Arena * arena) const override
void insertResultInto(AggregateDataPtr __restrict place, IColumn & to, Arena * arena) const override
{
auto & map_column = assert_cast<ColumnMap &>(to);
auto & nested_column = map_column.getNestedColumn();

View File

@ -33,11 +33,11 @@ public:
bool allocatesMemoryInArena() const override { return false; }
void create(AggregateDataPtr) const override
void create(AggregateDataPtr __restrict) const override
{
}
void destroy(AggregateDataPtr) const noexcept override
void destroy(AggregateDataPtr __restrict) const noexcept override
{
}
@ -56,11 +56,11 @@ public:
return 1;
}
void add(AggregateDataPtr, const IColumn **, size_t, Arena *) const override
void add(AggregateDataPtr __restrict, const IColumn **, size_t, Arena *) const override
{
}
void merge(AggregateDataPtr, ConstAggregateDataPtr, Arena *) const override
void merge(AggregateDataPtr __restrict, ConstAggregateDataPtr, Arena *) const override
{
}
@ -69,14 +69,14 @@ public:
writeChar('\0', buf);
}
void deserialize(AggregateDataPtr, ReadBuffer & buf, std::optional<size_t>, Arena *) const override
void deserialize(AggregateDataPtr __restrict, ReadBuffer & buf, std::optional<size_t>, Arena *) const override
{
[[maybe_unused]] char symbol;
readChar(symbol, buf);
assert(symbol == '\0');
}
void insertResultInto(AggregateDataPtr, IColumn & to, Arena *) const override
void insertResultInto(AggregateDataPtr __restrict, IColumn & to, Arena *) const override
{
to.insertDefault();
}

View File

@ -309,7 +309,7 @@ public:
void addBatchSinglePlace( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t if_argument_pos = -1) const override

View File

@ -99,7 +99,7 @@ public:
}
void add(
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
size_t row_num,
Arena * arena) const override
@ -138,7 +138,7 @@ public:
void addBatchSinglePlace( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t if_argument_pos = -1) const override
@ -169,7 +169,7 @@ public:
void addBatchSinglePlaceNotNull( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena * arena,
@ -206,7 +206,7 @@ public:
}
void merge(
AggregateDataPtr place,
AggregateDataPtr __restrict place,
ConstAggregateDataPtr rhs,
Arena * arena) const override
{
@ -227,14 +227,14 @@ public:
(places[i] + place_offset)[size_of_data] |= rhs[i][size_of_data];
}
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf, std::optional<size_t> version) const override
void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> version) const override
{
nested_function->serialize(place, buf, version);
writeChar(place[size_of_data], buf);
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, std::optional<size_t> version, Arena * arena) const override
void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> version, Arena * arena) const override
{
nested_function->deserialize(place, buf, version, arena);
@ -261,7 +261,7 @@ public:
}
void insertResultInto(
AggregateDataPtr place,
AggregateDataPtr __restrict place,
IColumn & to,
Arena * arena) const override
{

View File

@ -134,7 +134,7 @@ public:
nested_function->destroy(place + i * size_of_data);
}
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena) const override
void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena) const override
{
Key key;
@ -151,19 +151,19 @@ public:
nested_function->add(place + pos * size_of_data, columns, row_num, arena);
}
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena * arena) const override
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena * arena) const override
{
for (size_t i = 0; i < total; ++i)
nested_function->merge(place + i * size_of_data, rhs + i * size_of_data, arena);
}
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf, std::optional<size_t> version) const override
void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> version) const override
{
for (size_t i = 0; i < total; ++i)
nested_function->serialize(place + i * size_of_data, buf, version);
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, std::optional<size_t> version, Arena * arena) const override
void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> version, Arena * arena) const override
{
for (size_t i = 0; i < total; ++i)
nested_function->deserialize(place + i * size_of_data, buf, version, arena);
@ -174,7 +174,7 @@ public:
return std::make_shared<DataTypeArray>(nested_function->getReturnType());
}
void insertResultInto(AggregateDataPtr place, IColumn & to, Arena * arena) const override
void insertResultInto(AggregateDataPtr __restrict place, IColumn & to, Arena * arena) const override
{
auto & col = assert_cast<ColumnArray &>(to);
auto & col_offsets = assert_cast<ColumnArray::ColumnOffsets &>(col.getOffsetsColumn());

View File

@ -158,8 +158,8 @@ class SequenceNextNodeImpl final
using Self = SequenceNextNodeImpl<T, Node>;
using Data = SequenceNextNodeGeneralData<Node>;
static Data & data(AggregateDataPtr place) { return *reinterpret_cast<Data *>(place); }
static const Data & data(ConstAggregateDataPtr place) { return *reinterpret_cast<const Data *>(place); }
static Data & data(AggregateDataPtr __restrict place) { return *reinterpret_cast<Data *>(place); }
static const Data & data(ConstAggregateDataPtr __restrict place) { return *reinterpret_cast<const Data *>(place); }
static constexpr size_t base_cond_column_idx = 2;
static constexpr size_t event_column_idx = 1;
@ -216,7 +216,7 @@ public:
a.value.push_back(v->clone(arena), arena);
}
void create(AggregateDataPtr place) const override /// NOLINT
void create(AggregateDataPtr __restrict place) const override /// NOLINT
{
new (place) Data;
}

View File

@ -110,7 +110,7 @@ public:
}
void add(
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
size_t row_num,
Arena *
@ -125,17 +125,17 @@ public:
this->data(place).add(x, y);
}
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena *) const override
{
this->data(place).merge(this->data(rhs));
}
void serialize(ConstAggregateDataPtr place, WriteBuffer & buf, std::optional<size_t> /* version */) const override
void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> /* version */) const override
{
this->data(place).serialize(buf);
}
void deserialize(AggregateDataPtr place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override
void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional<size_t> /* version */, Arena *) const override
{
this->data(place).deserialize(buf);
}
@ -163,7 +163,7 @@ public:
bool allocatesMemoryInArena() const override { return false; }
void insertResultInto(
AggregateDataPtr place,
AggregateDataPtr __restrict place,
IColumn & to,
Arena *) const override
{

View File

@ -298,7 +298,7 @@ public:
}
}
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena * /*arena*/) const override
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr __restrict rhs, Arena * /*arena*/) const override
{
this->data(place).merge(this->data(rhs));
}

View File

@ -445,7 +445,7 @@ public:
void addBatchSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena *,
ssize_t if_argument_pos) const override
@ -465,7 +465,7 @@ public:
void addBatchSinglePlaceNotNull(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena *,

View File

@ -150,7 +150,7 @@ public:
/// Used for machine learning methods. Predict result from trained model.
/// Will insert result into `to` column for rows in range [offset, offset + limit).
virtual void predictValues(
ConstAggregateDataPtr /* place */,
ConstAggregateDataPtr __restrict /* place */,
IColumn & /*to*/,
const ColumnsWithTypeAndName & /*arguments*/,
size_t /*offset*/,
@ -209,7 +209,7 @@ public:
virtual void addBatchSinglePlace( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t if_argument_pos = -1) const = 0;
@ -218,7 +218,7 @@ public:
virtual void addBatchSparseSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena) const = 0;
@ -228,7 +228,7 @@ public:
virtual void addBatchSinglePlaceNotNull( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena * arena,
@ -237,7 +237,7 @@ public:
virtual void addBatchSinglePlaceFromInterval( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t if_argument_pos = -1)
@ -370,7 +370,7 @@ template <typename Derived>
class IAggregateFunctionHelper : public IAggregateFunction
{
private:
static void addFree(const IAggregateFunction * that, AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena * arena)
static void addFree(const IAggregateFunction * that, AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena)
{
static_cast<const Derived &>(*that).add(place, columns, row_num, arena);
}
@ -450,7 +450,7 @@ public:
void addBatchSinglePlace( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t if_argument_pos = -1) const override
@ -474,7 +474,7 @@ public:
void addBatchSparseSinglePlace(
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena) const override
{
@ -493,7 +493,7 @@ public:
void addBatchSinglePlaceNotNull( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
const UInt8 * null_map,
Arena * arena,
@ -517,7 +517,7 @@ public:
void addBatchSinglePlaceFromInterval( /// NOLINT
size_t row_begin,
size_t row_end,
AggregateDataPtr place,
AggregateDataPtr __restrict place,
const IColumn ** columns,
Arena * arena,
ssize_t if_argument_pos = -1)
@ -661,7 +661,7 @@ public:
IAggregateFunctionDataHelper(const DataTypes & argument_types_, const Array & parameters_)
: IAggregateFunctionHelper<Derived>(argument_types_, parameters_) {}
void create(AggregateDataPtr place) const override /// NOLINT
void create(AggregateDataPtr __restrict place) const override /// NOLINT
{
new (place) Data;
}