mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
dbms: development.
This commit is contained in:
parent
e54544b92b
commit
f9bfcfa395
@ -72,58 +72,58 @@ int main(int argc, char ** argv)
|
||||
DB::Table table("TestTable", columns, primary_key_column_numbers, column_groups);
|
||||
|
||||
/// создаём набор данных
|
||||
DB::AggregatedRowSet data;
|
||||
DB::Row key;
|
||||
DB::Row value;
|
||||
std::vector<DB::AggregatedRowSet> data(columns->size());
|
||||
std::vector<DB::Row> value(columns->size());
|
||||
|
||||
key.push_back(DB::Field(DB::UInt(65765691660ULL)));
|
||||
value.push_back(DB::Field(DB::UInt(20090724165002400ULL)));
|
||||
value.push_back(DB::Field(DB::UInt(9154640)));
|
||||
value.push_back(DB::Field(DB::UInt(1)));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::String("Китайские ученые перепрограммировали клетки и создали из них мышей. Иностранная пресса о событиях в ")));
|
||||
value.push_back(DB::Field(DB::Int(1)));
|
||||
value.push_back(DB::Field(DB::UInt(1248456711)));
|
||||
value.push_back(DB::Field(DB::UInt(71551)));
|
||||
value.push_back(DB::Field(DB::UInt(1220865079)));
|
||||
value.push_back(DB::Field(DB::UInt(84)));
|
||||
value.push_back(DB::Field(DB::UInt(5243575589842965681ULL)));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::UInt(1)));
|
||||
value.push_back(DB::Field(DB::UInt(3)));
|
||||
value.push_back(DB::Field(DB::UInt(5)));
|
||||
value.push_back(DB::Field(DB::String("http://www.example.ru/wsj/2009/07/24/15:10:00/mouse")));
|
||||
value.push_back(DB::Field(DB::String("http://www.example.com/")));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::UInt(1024)));
|
||||
value.push_back(DB::Field(DB::UInt(768)));
|
||||
value.push_back(DB::Field(DB::UInt(16)));
|
||||
value.push_back(DB::Field(DB::UInt(10)));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::String("")));
|
||||
value.push_back(DB::Field(DB::UInt(3)));
|
||||
value.push_back(DB::Field(DB::UInt(5)));
|
||||
value.push_back(DB::Field(DB::UInt(8)));
|
||||
value.push_back(DB::Field(DB::String("0 ")));
|
||||
value.push_back(DB::Field(DB::UInt(1)));
|
||||
value.push_back(DB::Field(DB::UInt(1)));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::String("")));
|
||||
value.push_back(DB::Field(DB::String("")));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::Int(1)));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value.push_back(DB::Field(DB::String("")));
|
||||
value.push_back(DB::Field(DB::UInt(0)));
|
||||
value[0].push_back(DB::Field(DB::UInt(65765691660ULL)));
|
||||
value[1].push_back(DB::Field(DB::UInt(20090724165002400ULL)));
|
||||
value[2].push_back(DB::Field(DB::UInt(9154640)));
|
||||
value[3].push_back(DB::Field(DB::UInt(1)));
|
||||
value[4].push_back(DB::Field(DB::UInt(0)));
|
||||
value[5].push_back(DB::Field(DB::String("Китайские ученые перепрограммировали клетки и создали из них мышей. Иностранная пресса о событиях в ")));
|
||||
value[6].push_back(DB::Field(DB::Int(1)));
|
||||
value[7].push_back(DB::Field(DB::UInt(1248456711)));
|
||||
value[8].push_back(DB::Field(DB::UInt(71551)));
|
||||
value[9].push_back(DB::Field(DB::UInt(1220865079)));
|
||||
value[10].push_back(DB::Field(DB::UInt(84)));
|
||||
value[11].push_back(DB::Field(DB::UInt(5243575589842965681ULL)));
|
||||
value[12].push_back(DB::Field(DB::UInt(0)));
|
||||
value[13].push_back(DB::Field(DB::UInt(1)));
|
||||
value[14].push_back(DB::Field(DB::UInt(3)));
|
||||
value[15].push_back(DB::Field(DB::UInt(5)));
|
||||
value[16].push_back(DB::Field(DB::String("http://www.example.ru/wsj/2009/07/24/15:10:00/mouse")));
|
||||
value[17].push_back(DB::Field(DB::String("http://www.example.com/")));
|
||||
value[18].push_back(DB::Field(DB::UInt(0)));
|
||||
value[19].push_back(DB::Field(DB::UInt(1024)));
|
||||
value[20].push_back(DB::Field(DB::UInt(768)));
|
||||
value[21].push_back(DB::Field(DB::UInt(16)));
|
||||
value[22].push_back(DB::Field(DB::UInt(10)));
|
||||
value[23].push_back(DB::Field(DB::UInt(0)));
|
||||
value[24].push_back(DB::Field(DB::String("")));
|
||||
value[25].push_back(DB::Field(DB::UInt(3)));
|
||||
value[26].push_back(DB::Field(DB::UInt(5)));
|
||||
value[27].push_back(DB::Field(DB::UInt(8)));
|
||||
value[28].push_back(DB::Field(DB::String("0 ")));
|
||||
value[29].push_back(DB::Field(DB::UInt(1)));
|
||||
value[30].push_back(DB::Field(DB::UInt(1)));
|
||||
value[31].push_back(DB::Field(DB::UInt(0)));
|
||||
value[32].push_back(DB::Field(DB::UInt(0)));
|
||||
value[33].push_back(DB::Field(DB::String("")));
|
||||
value[34].push_back(DB::Field(DB::String("")));
|
||||
value[35].push_back(DB::Field(DB::UInt(0)));
|
||||
value[36].push_back(DB::Field(DB::Int(1)));
|
||||
value[37].push_back(DB::Field(DB::UInt(0)));
|
||||
value[38].push_back(DB::Field(DB::String("")));
|
||||
value[39].push_back(DB::Field(DB::UInt(0)));
|
||||
|
||||
{
|
||||
stopwatch.restart();
|
||||
|
||||
for (DB::UInt i = 0; i < 1000000; ++i)
|
||||
{
|
||||
data[key] = value;
|
||||
++boost::get<DB::UInt>(key[0]);
|
||||
for (size_t i = 0; i < columns->size(); ++i)
|
||||
data[i][value[0]] = value[i];
|
||||
++boost::get<DB::UInt>(value[0][0]);
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
@ -132,15 +132,19 @@ int main(int argc, char ** argv)
|
||||
|
||||
/// заполняем таблицу
|
||||
{
|
||||
DB::ColumnMask mask(columns->size(), false);
|
||||
DB::ColumnMask mask(2);
|
||||
mask[0] = false;
|
||||
mask[1] = true;
|
||||
|
||||
stopwatch.restart();
|
||||
|
||||
Poco::Stopwatch column_stopwatch;
|
||||
for (size_t i = 0; i < column_groups->size(); ++i)
|
||||
{
|
||||
mask[i] = true;
|
||||
(*column_groups)[i].storage->merge(data, mask);
|
||||
mask[i] = false;
|
||||
column_stopwatch.restart();
|
||||
(*column_groups)[i].storage->merge(data[i], mask);
|
||||
column_stopwatch.stop();
|
||||
std::cout << "Saving column" << i << ": " << static_cast<double>(column_stopwatch.elapsed()) / 1000000 << std::endl;
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
@ -150,19 +154,27 @@ int main(int argc, char ** argv)
|
||||
/// читаем таблицу
|
||||
{
|
||||
DB::Row key;
|
||||
Poco::SharedPtr<DB::ITablePartReader> reader((*column_groups)[30].storage->read(key)); /// UniqID
|
||||
|
||||
stopwatch.restart();
|
||||
|
||||
DB::UInt i = 0;
|
||||
DB::Row row;
|
||||
|
||||
Poco::Stopwatch column_stopwatch;
|
||||
for (size_t i = 0; i < column_groups->size(); ++i)
|
||||
{
|
||||
column_stopwatch.restart();
|
||||
|
||||
Poco::SharedPtr<DB::ITablePartReader> reader((*column_groups)[i].storage->read(key)); /// UniqID
|
||||
DB::UInt row_num = 0;
|
||||
while (reader->fetch(row))
|
||||
{
|
||||
++i;
|
||||
++row_num;
|
||||
}
|
||||
if (i != 1000000)
|
||||
if (row_num != 1000000)
|
||||
throw Poco::Exception("Number of rows doesn't match");
|
||||
|
||||
column_stopwatch.stop();
|
||||
std::cout << "Reading column" << i << ": " << static_cast<double>(column_stopwatch.elapsed()) / 1000000 << std::endl;
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
std::cout << "Reading data: " << static_cast<double>(stopwatch.elapsed()) / 1000000 << std::endl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user