mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Better semantic of sharing columns: development [#CLICKHOUSE-2].
This commit is contained in:
parent
4148c6ce81
commit
6756b37925
@ -173,7 +173,7 @@ MutableColumnPtr ColumnTuple::replicate(const Offsets_t & offsets) const
|
||||
return ColumnTuple::create(new_columns);
|
||||
}
|
||||
|
||||
MutableColumnPtr ColumnTuple::scatter(ColumnIndex num_columns, const Selector & selector) const
|
||||
MutableColumns ColumnTuple::scatter(ColumnIndex num_columns, const Selector & selector) const
|
||||
{
|
||||
const size_t tuple_size = columns.size();
|
||||
std::vector<Columns> scattered_tuple_elements(tuple_size);
|
||||
@ -181,7 +181,7 @@ MutableColumnPtr ColumnTuple::scatter(ColumnIndex num_columns, const Selector &
|
||||
for (size_t tuple_element_idx = 0; tuple_element_idx < tuple_size; ++tuple_element_idx)
|
||||
scattered_tuple_elements[tuple_element_idx] = columns[tuple_element_idx]->scatter(num_columns, selector);
|
||||
|
||||
Columns res(num_columns);
|
||||
MutableColumns res(num_columns);
|
||||
|
||||
for (size_t scattered_idx = 0; scattered_idx < num_columns; ++scattered_idx)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
MutableColumnPtr filter(const Filter & filt, ssize_t result_size_hint) const override;
|
||||
MutableColumnPtr permute(const Permutation & perm, size_t limit) const override;
|
||||
MutableColumnPtr replicate(const Offsets_t & offsets) const override;
|
||||
Columns scatter(ColumnIndex num_columns, const Selector & selector) const override;
|
||||
MutableColumns scatter(ColumnIndex num_columns, const Selector & selector) const override;
|
||||
void gather(ColumnGathererStream & gatherer_stream) override;
|
||||
int compareAt(size_t n, size_t m, const IColumn & rhs, int nan_direction_hint) const override;
|
||||
void getExtremes(Field & min, Field & max) const override;
|
||||
|
@ -66,13 +66,12 @@ Block NullableAdapterBlockInputStream::readImpl()
|
||||
}
|
||||
case TO_NULLABLE:
|
||||
{
|
||||
auto null_map = ColumnUInt8::create(elem.column->size(), 0);
|
||||
ColumnPtr null_map = ColumnUInt8::create(elem.column->size(), 0);
|
||||
|
||||
res.insert({
|
||||
ColumnNullable::create(elem.column, null_map),
|
||||
std::make_shared<DataTypeNullable>(elem.type),
|
||||
rename[i].value_or(elem.name)
|
||||
});
|
||||
rename[i].value_or(elem.name)});
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
|
@ -61,8 +61,11 @@ void SquashingTransform::append(Block && block)
|
||||
size_t rows = block.rows();
|
||||
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
accumulated_block.getByPosition(i).column->insertRangeFrom(
|
||||
*block.getByPosition(i).column, 0, rows);
|
||||
{
|
||||
MutableColumnPtr mutable_column = accumulated_block.getByPosition(i).column->mutate();
|
||||
mutable_column->insertRangeFrom(*block.getByPosition(i).column, 0, rows);
|
||||
accumulated_block.getByPosition(i).column = std::move(mutable_column);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -148,8 +148,7 @@ private:
|
||||
bool mergeMap(const MapDescription & map, Row & row, SortCursor & cursor);
|
||||
|
||||
// Add the row under the cursor to the `row`.
|
||||
template <typename TSortCursor>
|
||||
void addRow(TSortCursor & cursor);
|
||||
void addRow(SortCursor & cursor);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ bool TSKVRowInputStream::read(MutableColumns & columns)
|
||||
|
||||
read_columns[index] = true;
|
||||
|
||||
sample.getByPosition(index).type->deserializeTextEscaped(*columns[index], istr);
|
||||
header.getByPosition(index).type->deserializeTextEscaped(*columns[index], istr);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -159,7 +159,7 @@ String TabSeparatedRowInputStream::getDiagnosticInfo()
|
||||
}
|
||||
|
||||
|
||||
bool TabSeparatedRowInputStream::parseRowAndPrintDiagnosticInfo(MutableColumnPtr & columns,
|
||||
bool TabSeparatedRowInputStream::parseRowAndPrintDiagnosticInfo(MutableColumns & columns,
|
||||
WriteBuffer & out, size_t max_length_of_column_name, size_t max_length_of_data_type_name)
|
||||
{
|
||||
size_t size = data_types.size();
|
||||
|
@ -3,9 +3,10 @@
|
||||
#include <Interpreters/AggregateDescription.h>
|
||||
#include <Columns/ColumnAggregateFunction.h>
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <Columns/ColumnNullable.h>
|
||||
#include <Columns/FilterDescription.h>
|
||||
#include <Common/typeid_cast.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
@ -115,34 +116,16 @@ Block TotalsHavingBlockInputStream::readImpl()
|
||||
size_t filter_column_pos = finalized.getPositionByName(filter_column_name);
|
||||
ColumnPtr filter_column_ptr = finalized.safeGetByPosition(filter_column_pos).column;
|
||||
|
||||
if (auto converted = filter_column_ptr->convertToFullColumnIfConst())
|
||||
filter_column_ptr = converted;
|
||||
if (ColumnPtr materialized = filter_column_ptr->convertToFullColumnIfConst())
|
||||
filter_column_ptr = materialized;
|
||||
|
||||
bool filter_is_nullable = filter_column_ptr->isColumnNullable();
|
||||
ColumnUInt8 * filter_column = filter_is_nullable
|
||||
? typeid_cast<ColumnUInt8 *>(&static_cast<ColumnNullable *>(filter_column_ptr.get())->getNestedColumn())
|
||||
: typeid_cast<ColumnUInt8 *>(&*filter_column_ptr);
|
||||
|
||||
if (!filter_column)
|
||||
throw Exception("Filter column must have type UInt8, found " +
|
||||
finalized.safeGetByPosition(filter_column_pos).type->getName(),
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER);
|
||||
|
||||
IColumn::Filter & filter = filter_column->getData();
|
||||
|
||||
if (filter_column_ptr->isColumnNullable())
|
||||
{
|
||||
const NullMap & null_map = static_cast<ColumnNullable *>(filter_column_ptr.get())->getNullMapData();
|
||||
for (size_t i = 0, size = null_map.size(); i < size; ++i)
|
||||
if (null_map[i])
|
||||
filter[i] = 0;
|
||||
}
|
||||
FilterDescription filter_description(filter_column_ptr);
|
||||
|
||||
/// Add values to `totals` (if it was not already done).
|
||||
if (totals_mode == TotalsMode::BEFORE_HAVING)
|
||||
addToTotals(current_totals, block, nullptr);
|
||||
else
|
||||
addToTotals(current_totals, block, &filter);
|
||||
addToTotals(current_totals, block, filter_description.data);
|
||||
|
||||
/// Filter the block by expression in HAVING.
|
||||
size_t columns = finalized.columns();
|
||||
@ -150,7 +133,7 @@ Block TotalsHavingBlockInputStream::readImpl()
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
{
|
||||
ColumnWithTypeAndName & current_column = finalized.safeGetByPosition(i);
|
||||
current_column.column = current_column.column->filter(filter, -1);
|
||||
current_column.column = current_column.column->filter(*filter_description.data, -1);
|
||||
if (current_column.column->empty())
|
||||
{
|
||||
finalized.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user