fix for style

This commit is contained in:
bgranvea 2019-03-11 09:24:52 +01:00
parent 9d9d16e1ea
commit faa7d38cb5
4 changed files with 31 additions and 15 deletions

View File

@ -42,11 +42,14 @@ AggregatingSortedBlockInputStream::AggregatingSortedBlockInputStream(
continue;
}
if (auto simple_aggr = findSimpleAggregateFunction(column.type)) {
if (auto simple_aggr = findSimpleAggregateFunction(column.type))
{
// simple aggregate function
SimpleAggregateDescription desc{simple_aggr->getFunction(), i};
columns_to_simple_aggregate.emplace_back(std::move(desc));
} else {
}
else
{
// standard aggregate function
column_numbers_to_aggregate.push_back(i);
}
@ -99,7 +102,8 @@ void AggregatingSortedBlockInputStream::merge(MutableColumns & merged_columns, s
key_differs = next_key != current_key;
/// if there are enough rows accumulated and the last one is calculated completely
if (key_differs && merged_rows >= max_block_size) {
if (key_differs && merged_rows >= max_block_size)
{
/// Write the simple aggregation result for the previous group.
insertSimpleAggregationResult(merged_columns);
return;

View File

@ -18,7 +18,8 @@
#include <boost/algorithm/string/join.hpp>
namespace DB {
namespace DB
{
namespace ErrorCodes
{
@ -33,13 +34,16 @@ const std::vector<String> supported_functions = std::vector<String>(
{"any", "anyLast", "min", "max", "sum"});
String DataTypeDomainSimpleAggregateFunction::doGetName() const {
String DataTypeDomainSimpleAggregateFunction::doGetName() const
{
std::stringstream stream;
stream << "SimpleAggregateFunction(" << function->getName();
if (!parameters.empty()) {
if (!parameters.empty())
{
stream << "(";
for (size_t i = 0; i < parameters.size(); ++i) {
for (size_t i = 0; i < parameters.size(); ++i)
{
if (i)
stream << ", ";
stream << applyVisitor(DB::FieldVisitorToString(), parameters[i]);
@ -107,7 +111,8 @@ static std::pair<DataTypePtr, DataTypeDomainPtr> create(const ASTPtr & arguments
function = AggregateFunctionFactory::instance().get(function_name, argument_types, params_row);
// check function
if (std::find(std::begin(supported_functions), std::end(supported_functions), function->getName()) == std::end(supported_functions)) {
if (std::find(std::begin(supported_functions), std::end(supported_functions), function->getName()) == std::end(supported_functions))
{
throw Exception("Unsupported aggregate function " + function->getName() + ", supported functions are " + boost::algorithm::join(supported_functions, ","),
ErrorCodes::BAD_ARGUMENTS);
}
@ -115,7 +120,8 @@ static std::pair<DataTypePtr, DataTypeDomainPtr> create(const ASTPtr & arguments
DataTypePtr storage_type = DataTypeFactory::instance().get(argument_types[0]->getName());
DataTypeDomainPtr domain = std::make_unique<DataTypeDomainSimpleAggregateFunction>(storage_type, function, argument_types, params_row);
if (!function->getReturnType()->equals(*removeLowCardinality(storage_type))) {
if (!function->getReturnType()->equals(*removeLowCardinality(storage_type)))
{
throw Exception("Incompatible data types between aggregate function '" + function->getName() + "' which returns " + function->getReturnType()->getName() + " and column storage type " + storage_type->getName(),
ErrorCodes::BAD_ARGUMENTS);
}
@ -123,7 +129,8 @@ static std::pair<DataTypePtr, DataTypeDomainPtr> create(const ASTPtr & arguments
return std::make_pair(storage_type, std::move(domain));
}
static const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(const IDataTypeDomain * domain) {
static const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(const IDataTypeDomain * domain)
{
if (domain == nullptr)
return nullptr;
@ -136,7 +143,8 @@ static const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction
return nullptr;
}
const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(DataTypePtr dataType) {
const DataTypeDomainSimpleAggregateFunction * findSimpleAggregateFunction(DataTypePtr dataType)
{
return findSimpleAggregateFunction(dataType->getDomain());
}

View File

@ -24,7 +24,8 @@ namespace DB
* Technically, a standard IDataType is instanciated and a DataTypeDomainSimpleAggregateFunction is added as domain.
*/
class DataTypeDomainSimpleAggregateFunction : public IDataTypeDomain {
class DataTypeDomainSimpleAggregateFunction : public IDataTypeDomain
{
private:
const DataTypePtr storage_type;
const AggregateFunctionPtr function;

View File

@ -25,14 +25,16 @@ private:
public:
virtual ~IDataTypeDomain() {}
String getName() const {
String getName() const
{
if (delegate)
return delegate->getName();
else
return doGetName();
}
void appendDomain(DataTypeDomainPtr delegate_) const {
void appendDomain(DataTypeDomainPtr delegate_) const
{
if (delegate == nullptr)
delegate = std::move(delegate_);
else
@ -45,7 +47,8 @@ protected:
virtual String doGetName() const = 0;
};
class IDataTypeDomainCustomSerialization : public IDataTypeDomain {
class IDataTypeDomainCustomSerialization : public IDataTypeDomain
{
public:
virtual ~IDataTypeDomainCustomSerialization() {}