fixed constructor

This commit is contained in:
Nikita Vasilev 2019-01-10 15:57:12 +03:00
parent 6490c23aa6
commit 3f8c2ad814
3 changed files with 26 additions and 11 deletions

View File

@ -58,8 +58,17 @@ using IndexConditionPtr = std::shared_ptr<IndexCondition>;
class MergeTreeIndex
{
public:
MergeTreeIndex(String name, ExpressionActionsPtr expr, size_t granularity)
: name(name), expr(expr), granularity(granularity) {}
MergeTreeIndex(
String name,
ExpressionActionsPtr expr,
const Names & columns,
const DataTypes & data_types,
size_t granularity)
: name(name)
, expr(expr)
, columns(columns)
, data_types(data_types)
, granularity(granularity) {}
virtual ~MergeTreeIndex() = default;
@ -73,9 +82,9 @@ public:
String name;
ExpressionActionsPtr expr;
size_t granularity;
Names columns;
DataTypes data_types;
size_t granularity;
};

View File

@ -162,24 +162,25 @@ std::unique_ptr<MergeTreeIndex> MergeTreeMinMaxIndexCreator(
expr_list, data.getColumns().getAllPhysical());
auto minmax_expr = ExpressionAnalyzer(expr_list, syntax, context).getActions(false);
auto minmax = std::make_unique<MergeTreeMinMaxIndex>(
node->name, std::move(minmax_expr), node->granularity.get<size_t>());
auto sample = ExpressionAnalyzer(expr_list, syntax, context)
.getActions(true)->getSampleBlock();
Names columns;
DataTypes data_types;
Poco::Logger * log = &Poco::Logger::get("minmax_idx");
LOG_DEBUG(log, "new minmax index");
for (size_t i = 0; i < expr_list->children.size(); ++i)
{
const auto & column = sample.getByPosition(i);
minmax->columns.emplace_back(column.name);
minmax->data_types.emplace_back(column.type);
columns.emplace_back(column.name);
data_types.emplace_back(column.type);
LOG_DEBUG(log, ">" << column.name << " " << column.type->getName());
}
return minmax;
return std::make_unique<MergeTreeMinMaxIndex>(
node->name, std::move(minmax_expr), columns, data_types, node->granularity.get<size_t>());;
}
}

View File

@ -63,8 +63,13 @@ private:
class MergeTreeMinMaxIndex : public MergeTreeIndex
{
public:
MergeTreeMinMaxIndex(String name, ExpressionActionsPtr expr, size_t granularity)
: MergeTreeIndex(name, expr, granularity) {}
MergeTreeMinMaxIndex(
String name,
ExpressionActionsPtr expr,
const Names & columns,
const DataTypes & data_types,
size_t granularity)
: MergeTreeIndex(name, expr, columns, data_types, granularity) {}
~MergeTreeMinMaxIndex() override = default;