mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Applied clang-format #2272
This commit is contained in:
parent
598c7fddb7
commit
90427db854
@ -1,10 +1,10 @@
|
||||
#include <Functions/FunctionsProjection.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Functions/FunctionsProjection.h>
|
||||
|
||||
namespace DB {
|
||||
|
||||
namespace DB
|
||||
{
|
||||
FunctionPtr FunctionOneOrZero::create(const Context &)
|
||||
{
|
||||
return std::make_shared<FunctionOneOrZero>();
|
||||
@ -64,8 +64,8 @@ DataTypePtr FunctionProject::getReturnTypeImpl(const DataTypes & arguments) cons
|
||||
{
|
||||
if (!checkAndGetDataType<DataTypeUInt8>(arguments[1].get()))
|
||||
{
|
||||
throw Exception("Illegal type " + arguments[1]->getName() + " of 2nd argument of function " + getName(),
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
throw Exception(
|
||||
"Illegal type " + arguments[1]->getName() + " of 2nd argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
}
|
||||
return arguments[0];
|
||||
}
|
||||
@ -116,14 +116,16 @@ DataTypePtr FunctionBuildProjectionComposition::getReturnTypeImpl(const DataType
|
||||
{
|
||||
if (!checkAndGetDataType<DataTypeUInt8>(arguments[i].get()))
|
||||
{
|
||||
throw Exception("Illegal type " + arguments[i]->getName() + " of " + std::to_string(i + 1) + " argument of function " + getName(),
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
throw Exception(
|
||||
"Illegal type " + arguments[i]->getName() + " of " + std::to_string(i + 1) + " argument of function " + getName(),
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
}
|
||||
}
|
||||
return std::make_shared<DataTypeUInt8>();
|
||||
}
|
||||
|
||||
void FunctionBuildProjectionComposition::executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t /*input_rows_count*/)
|
||||
void FunctionBuildProjectionComposition::executeImpl(
|
||||
Block & block, const ColumnNumbers & arguments, size_t result, size_t /*input_rows_count*/)
|
||||
{
|
||||
const auto & first_projection_column = block.getByPosition(arguments[0]).column;
|
||||
const auto & second_projection_column = block.getByPosition(arguments[1]).column;
|
||||
@ -145,9 +147,9 @@ void FunctionBuildProjectionComposition::executeImpl(Block & block, const Column
|
||||
}
|
||||
if (current_reserve_index != second_projection_column->size())
|
||||
{
|
||||
throw Exception("Second argument size is not appropriate: " + std::to_string(second_projection_column->size())
|
||||
+ " instead of " + std::to_string(current_reserve_index),
|
||||
ErrorCodes::BAD_ARGUMENTS);
|
||||
throw Exception("Second argument size is not appropriate: " + std::to_string(second_projection_column->size()) + " instead of "
|
||||
+ std::to_string(current_reserve_index),
|
||||
ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
block.getByPosition(result).column = std::move(col_res);
|
||||
}
|
||||
@ -162,7 +164,8 @@ String FunctionRestoreProjection::getName() const
|
||||
return name;
|
||||
}
|
||||
|
||||
bool FunctionRestoreProjection::isVariadic() const {
|
||||
bool FunctionRestoreProjection::isVariadic() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@
|
||||
#include <Functions/IFunction.h>
|
||||
#include "FunctionsConversion.h"
|
||||
|
||||
namespace DB {
|
||||
|
||||
namespace DB
|
||||
{
|
||||
/*
|
||||
* This function accepts one column and converts it to UInt8, replacing values, which evaluate to true, with 1, and values,
|
||||
* which evaluate to false with 0
|
||||
*/
|
||||
class FunctionOneOrZero final : public IFunction {
|
||||
class FunctionOneOrZero final : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "one_or_zero";
|
||||
static FunctionPtr create(const Context &);
|
||||
@ -25,7 +26,8 @@ public:
|
||||
* This function builds a column of a smaller, which contains values of the data column at the positions where
|
||||
* the projection column contained 1. The size of result column equals the count of ones in the projection column.
|
||||
*/
|
||||
class FunctionProject final : public IFunction {
|
||||
class FunctionProject final : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "__inner_project__";
|
||||
static FunctionPtr create(const Context &);
|
||||
@ -39,7 +41,8 @@ public:
|
||||
* FunctionBuildProjectionComposition constructs the composition of two projection columns. The size of
|
||||
* second projection column should equal the count of ones in the first input projection column.
|
||||
*/
|
||||
class FunctionBuildProjectionComposition final : public IFunction {
|
||||
class FunctionBuildProjectionComposition final : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "__inner_build_projection_composition__";
|
||||
static FunctionPtr create(const Context &);
|
||||
@ -53,7 +56,8 @@ public:
|
||||
* Accepts mapping column with values from range [0, N) and N more columns as arguments.
|
||||
* Forms a column by taking value from column, which number is in the mapping column.
|
||||
*/
|
||||
class FunctionRestoreProjection final : public IFunction {
|
||||
class FunctionRestoreProjection final : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "__inner_restore_projection__";
|
||||
static FunctionPtr create(const Context &);
|
||||
|
@ -3,21 +3,23 @@
|
||||
#include <string>
|
||||
#include <Interpreters/ExpressionAnalyzer.h>
|
||||
|
||||
namespace DB {
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class ExpressionAnalyzer;
|
||||
|
||||
struct ScopeStack;
|
||||
|
||||
namespace ErrorCodes {
|
||||
extern const int CONDITIONAL_TREE_PARENT_NOT_FOUND;
|
||||
extern const int ILLEGAL_PROJECTION_MANIPULATOR;
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int CONDITIONAL_TREE_PARENT_NOT_FOUND;
|
||||
extern const int ILLEGAL_PROJECTION_MANIPULATOR;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a base class for the ConditionalTree. Look at the description of ConditionalTree.
|
||||
*/
|
||||
struct ProjectionManipulatorBase {
|
||||
struct ProjectionManipulatorBase
|
||||
{
|
||||
public:
|
||||
virtual bool tryToGetFromUpperProjection(const std::string & column_name) = 0;
|
||||
|
||||
@ -37,9 +39,11 @@ using ProjectionManipulatorPtr = std::shared_ptr<ProjectionManipulatorBase>;
|
||||
* For the better understanding of what ProjectionManipulator does,
|
||||
* look at the description of ConditionalTree.
|
||||
*/
|
||||
struct DefaultProjectionManipulator : public ProjectionManipulatorBase {
|
||||
struct DefaultProjectionManipulator : public ProjectionManipulatorBase
|
||||
{
|
||||
private:
|
||||
ScopeStack & scopes;
|
||||
|
||||
public:
|
||||
explicit DefaultProjectionManipulator(ScopeStack & scopes);
|
||||
|
||||
@ -86,9 +90,11 @@ public:
|
||||
* understand whether we need to scan the expression deeply, or can it be easily computed just with the projection
|
||||
* from one of the higher projection layers.
|
||||
*/
|
||||
struct ConditionalTree : public ProjectionManipulatorBase {
|
||||
struct ConditionalTree : public ProjectionManipulatorBase
|
||||
{
|
||||
private:
|
||||
struct Node {
|
||||
struct Node
|
||||
{
|
||||
Node();
|
||||
|
||||
size_t getParentNode() const;
|
||||
@ -103,21 +109,20 @@ private:
|
||||
ScopeStack & scopes;
|
||||
const Context & context;
|
||||
std::unordered_map<std::string, size_t> projection_expression_index;
|
||||
|
||||
private:
|
||||
std::string getColumnNameByIndex(const std::string & col_name, size_t node) const;
|
||||
|
||||
std::string getProjectionColumnName(const std::string & first_projection_expr,
|
||||
const std::string & second_projection_expr) const;
|
||||
std::string getProjectionColumnName(const std::string & first_projection_expr, const std::string & second_projection_expr) const;
|
||||
|
||||
std::string getProjectionColumnName(size_t first_index, size_t second_index) const;
|
||||
|
||||
void buildProjectionCompositionRecursive(const std::vector<size_t> & path,
|
||||
size_t child_index,
|
||||
size_t parent_index);
|
||||
void buildProjectionCompositionRecursive(const std::vector<size_t> & path, size_t child_index, size_t parent_index);
|
||||
|
||||
void buildProjectionComposition(size_t child_node, size_t parent_node);
|
||||
|
||||
std::string getProjectionSourceColumn(size_t node) const;
|
||||
|
||||
public:
|
||||
ConditionalTree(ScopeStack & scopes, const Context & context);
|
||||
|
||||
@ -128,11 +133,7 @@ public:
|
||||
std::string buildRestoreProjectionAndGetName(size_t levels_up);
|
||||
|
||||
void restoreColumn(
|
||||
const std::string & default_values_name,
|
||||
const std::string & new_values_name,
|
||||
size_t levels_up,
|
||||
const std::string & result_name
|
||||
);
|
||||
const std::string & default_values_name, const std::string & new_values_name, size_t levels_up, const std::string & result_name);
|
||||
|
||||
void goUp(size_t levels_up);
|
||||
|
||||
@ -150,7 +151,8 @@ using ConditionalTreePtr = std::shared_ptr<ConditionalTree>;
|
||||
* This class has two inherited classes: DefaultProjectionAction, which does nothing, and AndOperatorProjectionAction,
|
||||
* which represents how function "and" uses projection manipulator.
|
||||
*/
|
||||
class ProjectionActionBase {
|
||||
class ProjectionActionBase
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* What to do before scanning the function argument (each of it)
|
||||
@ -177,7 +179,8 @@ public:
|
||||
|
||||
using ProjectionActionPtr = std::shared_ptr<ProjectionActionBase>;
|
||||
|
||||
class DefaultProjectionAction : public ProjectionActionBase {
|
||||
class DefaultProjectionAction : public ProjectionActionBase
|
||||
{
|
||||
public:
|
||||
void preArgumentAction() final;
|
||||
|
||||
@ -191,7 +194,8 @@ public:
|
||||
/*
|
||||
* This is a specification of ProjectionAction specifically for the 'and' operation
|
||||
*/
|
||||
class AndOperatorProjectionAction : public ProjectionActionBase {
|
||||
class AndOperatorProjectionAction : public ProjectionActionBase
|
||||
{
|
||||
private:
|
||||
ScopeStack & scopes;
|
||||
ProjectionManipulatorPtr projection_manipulator;
|
||||
@ -205,11 +209,10 @@ private:
|
||||
std::string getFinalColumnName();
|
||||
|
||||
void createZerosColumn(const std::string & restore_projection_name);
|
||||
|
||||
public:
|
||||
AndOperatorProjectionAction(ScopeStack & scopes,
|
||||
ProjectionManipulatorPtr projection_manipulator,
|
||||
const std::string & expression_name,
|
||||
const Context& context);
|
||||
AndOperatorProjectionAction(
|
||||
ScopeStack & scopes, ProjectionManipulatorPtr projection_manipulator, const std::string & expression_name, const Context & context);
|
||||
|
||||
/*
|
||||
* Before scanning each argument, we should go to the next projection layer. For example, if the expression is
|
||||
@ -241,9 +244,9 @@ public:
|
||||
* it returns the pointer to AndOperatorProjectionAction.
|
||||
*/
|
||||
ProjectionActionPtr getProjectionAction(const std::string & node_name,
|
||||
ScopeStack & scopes,
|
||||
ProjectionManipulatorPtr projection_manipulator,
|
||||
const std::string & expression_name,
|
||||
const Context & context);
|
||||
ScopeStack & scopes,
|
||||
ProjectionManipulatorPtr projection_manipulator,
|
||||
const std::string & expression_name,
|
||||
const Context & context);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user