mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 09:10:48 +00:00
Using std::shared_ptr for columns [#METR-21503].
This commit is contained in:
parent
447b24cf98
commit
588ae3a790
@ -7,25 +7,26 @@
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
using namespace DB;
|
||||
|
||||
size_t n = atoi(argv[1]);
|
||||
|
||||
DB::ColumnWithTypeAndName descr1;
|
||||
DB::ColumnUInt8 * col1 = new DB::ColumnUInt8;
|
||||
descr1.type = new DB::DataTypeUInt8;
|
||||
ColumnWithTypeAndName descr1;
|
||||
auto col1 = std::make_shared<ColumnUInt8>();
|
||||
descr1.type = new DataTypeUInt8;
|
||||
descr1.column = col1;
|
||||
descr1.name = "x";
|
||||
col1->getData().resize(n);
|
||||
|
||||
DB::ColumnWithTypeAndName descr2;
|
||||
DB::ColumnInt16 * col2 = new DB::ColumnInt16;
|
||||
descr2.type = new DB::DataTypeInt16;
|
||||
ColumnWithTypeAndName descr2;
|
||||
auto col2 = std::make_shared<ColumnInt16>();
|
||||
descr2.type = new DataTypeInt16;
|
||||
descr2.column = col2;
|
||||
descr2.name = "x";
|
||||
|
||||
DB::Block block;
|
||||
Block block;
|
||||
block.insert(descr1);
|
||||
block.insert(descr2);
|
||||
col2->getData().resize(n);
|
||||
@ -36,20 +37,20 @@ int main(int argc, char ** argv)
|
||||
col2->getData()[i] = 3;
|
||||
}
|
||||
|
||||
DB::FunctionDivideFloating f;
|
||||
DB::DataTypes arg_types;
|
||||
FunctionDivideFloating f;
|
||||
DataTypes arg_types;
|
||||
arg_types.push_back(descr1.type);
|
||||
arg_types.push_back(descr2.type);
|
||||
|
||||
DB::ColumnNumbers arg_nums;
|
||||
ColumnNumbers arg_nums;
|
||||
arg_nums.push_back(0);
|
||||
arg_nums.push_back(1);
|
||||
|
||||
size_t res_num = 2;
|
||||
|
||||
DB::DataTypePtr res_type = f.getReturnType(arg_types);
|
||||
DataTypePtr res_type = f.getReturnType(arg_types);
|
||||
|
||||
DB::ColumnWithTypeAndName descr_res;
|
||||
ColumnWithTypeAndName descr_res;
|
||||
descr_res.type = res_type;
|
||||
descr_res.name = "z";
|
||||
|
||||
@ -66,17 +67,15 @@ int main(int argc, char ** argv)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
DB::Float64 x = 0;
|
||||
Float64 x = 0;
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
x += DB::get<DB::Float64>((*block.getByPosition(2).column)[i]);
|
||||
x += get<Float64>((*block.getByPosition(2).column)[i]);
|
||||
|
||||
std::cout << x << std::endl;
|
||||
}
|
||||
catch (const DB::Exception & e)
|
||||
{
|
||||
std::cerr << e.displayText() << std::endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (const DB::Exception & e)
|
||||
{
|
||||
std::cerr << e.displayText() << std::endl;
|
||||
throw;
|
||||
}
|
||||
|
@ -273,14 +273,14 @@ public:
|
||||
|
||||
convertToUInt8(other_in.back(), vec_res);
|
||||
other_in.pop_back();
|
||||
uint8_in.push_back(col_res);
|
||||
uint8_in.push_back(col_res.get());
|
||||
}
|
||||
|
||||
/// Эффективно скомбинируем все столбцы правильного типа.
|
||||
while (uint8_in.size() > 1)
|
||||
{
|
||||
AssociativeOperationImpl<Impl<UInt8>, 10>::execute(uint8_in, vec_res);
|
||||
uint8_in.push_back(col_res);
|
||||
uint8_in.push_back(col_res.get());
|
||||
}
|
||||
|
||||
/// По одному добавим все столбцы неправильного типа.
|
||||
@ -288,11 +288,11 @@ public:
|
||||
{
|
||||
executeUInt8Other(uint8_in[0]->getData(), other_in.back(), vec_res);
|
||||
other_in.pop_back();
|
||||
uint8_in[0] = col_res;
|
||||
uint8_in[0] = col_res.get();
|
||||
}
|
||||
|
||||
/// Такое возможно, если среди аргументов ровно один неконстантный, и он имеет тип UInt8.
|
||||
if (uint8_in[0] != col_res)
|
||||
if (uint8_in[0] != col_res.get())
|
||||
{
|
||||
vec_res.assign(uint8_in[0]->getData());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user