mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
dbms: development.
This commit is contained in:
parent
2dbd493503
commit
5442c79092
@ -112,7 +112,9 @@ public:
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
Poco::BinaryReader r(istr);
|
||||
r >> boost::get<UInt>(field);
|
||||
UInt x;
|
||||
r >> x;
|
||||
field = x;
|
||||
}
|
||||
|
||||
void serializeText(const DB::Field & field, std::ostream & ostr) const
|
||||
@ -122,7 +124,9 @@ public:
|
||||
|
||||
void deserializeText(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
istr >> boost::get<UInt>(field);
|
||||
UInt x;
|
||||
istr >> x;
|
||||
field = x;
|
||||
}
|
||||
};
|
||||
|
||||
@ -144,7 +148,7 @@ public:
|
||||
Poco::BinaryReader r(istr);
|
||||
Poco::UInt32 x;
|
||||
r >> x;
|
||||
boost::get<UInt>(field) = x;
|
||||
field = UInt(x);
|
||||
}
|
||||
|
||||
void serializeText(const DB::Field & field, std::ostream & ostr) const
|
||||
@ -156,7 +160,7 @@ public:
|
||||
{
|
||||
Poco::UInt32 x;
|
||||
istr >> x;
|
||||
boost::get<UInt>(field) = x;
|
||||
field = UInt(x);
|
||||
}
|
||||
};
|
||||
|
||||
@ -176,7 +180,9 @@ public:
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
Poco::BinaryReader r(istr);
|
||||
r >> boost::get<Int>(field);
|
||||
Int x;
|
||||
r >> x;
|
||||
field = x;
|
||||
}
|
||||
|
||||
void serializeText(const DB::Field & field, std::ostream & ostr) const
|
||||
@ -186,7 +192,9 @@ public:
|
||||
|
||||
void deserializeText(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
istr >> boost::get<Int>(field);
|
||||
Int x;
|
||||
istr >> x;
|
||||
field = x;
|
||||
}
|
||||
};
|
||||
|
||||
@ -208,7 +216,7 @@ public:
|
||||
Poco::BinaryReader r(istr);
|
||||
Poco::Int32 x;
|
||||
r >> x;
|
||||
boost::get<Int>(field) = x;
|
||||
field = Int(x);
|
||||
}
|
||||
|
||||
void serializeText(const DB::Field & field, std::ostream & ostr) const
|
||||
@ -220,7 +228,7 @@ public:
|
||||
{
|
||||
Poco::Int32 x;
|
||||
istr >> x;
|
||||
boost::get<Int>(field) = x;
|
||||
field = Int(x);
|
||||
}
|
||||
};
|
||||
|
||||
@ -238,7 +246,9 @@ public:
|
||||
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
readVarUInt(boost::get<UInt>(field), istr);
|
||||
UInt x;
|
||||
readVarUInt(x, istr);
|
||||
field = x;
|
||||
}
|
||||
|
||||
void serializeText(const DB::Field & field, std::ostream & ostr) const
|
||||
@ -248,7 +258,9 @@ public:
|
||||
|
||||
void deserializeText(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
istr >> boost::get<UInt>(field);
|
||||
UInt x;
|
||||
istr >> x;
|
||||
field = x;
|
||||
}
|
||||
};
|
||||
|
||||
@ -266,7 +278,9 @@ public:
|
||||
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
readVarInt(boost::get<Int>(field), istr);
|
||||
Int x;
|
||||
readVarInt(x, istr);
|
||||
field = x;
|
||||
}
|
||||
|
||||
void serializeText(const DB::Field & field, std::ostream & ostr) const
|
||||
@ -276,7 +290,9 @@ public:
|
||||
|
||||
void deserializeText(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
istr >> boost::get<Int>(field);
|
||||
Int x;
|
||||
istr >> x;
|
||||
field = x;
|
||||
}
|
||||
};
|
||||
|
||||
@ -296,10 +312,12 @@ public:
|
||||
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
field = std::string("");
|
||||
std::string & str = boost::get<String>(field);
|
||||
field = String("");
|
||||
String & str = boost::get<String>(field);
|
||||
UInt size;
|
||||
readVarUInt(size, istr);
|
||||
if (!istr.good())
|
||||
return;
|
||||
str.resize(size);
|
||||
/// непереносимо, но (действительно) быстрее
|
||||
istr.read(const_cast<char*>(str.data()), size);
|
||||
@ -312,6 +330,7 @@ public:
|
||||
|
||||
void deserializeText(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
field = std::string("");
|
||||
istr >> boost::get<String>(field);
|
||||
}
|
||||
};
|
||||
@ -346,7 +365,7 @@ public:
|
||||
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
field = std::string("");
|
||||
field = String("");
|
||||
std::string & str = boost::get<String>(field);
|
||||
str.resize(size);
|
||||
/// непереносимо, но (действительно) быстрее
|
||||
@ -360,6 +379,7 @@ public:
|
||||
|
||||
void deserializeText(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
field = String("");
|
||||
istr >> boost::get<String>(field);
|
||||
}
|
||||
};
|
||||
@ -392,9 +412,12 @@ public:
|
||||
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
field = FieldVector();
|
||||
FieldVector & vec = boost::get<FieldVector>(field);
|
||||
UInt size;
|
||||
readVarUInt(size, istr);
|
||||
if (!istr.good())
|
||||
return;
|
||||
vec.resize(size);
|
||||
for (UInt i(0); i < size; ++i)
|
||||
nested_type->deserializeBinary(vec[i], istr);
|
||||
@ -453,6 +476,7 @@ public:
|
||||
|
||||
void deserializeBinary(DB::Field & field, std::istream & istr) const
|
||||
{
|
||||
field = FieldVector();
|
||||
FieldVector & vec = boost::get<FieldVector>(field);
|
||||
vec.resize(size);
|
||||
for (UInt i(0); i < size; ++i)
|
||||
|
@ -62,16 +62,13 @@ bool PrimaryKeyNoneTablePartReader::fetch(Row & row)
|
||||
if (key.size() > pk->column_group->column_numbers.size())
|
||||
throw Exception("Too many columns specified for key", ErrorCodes::TOO_MANY_COLUMNS_FOR_KEY);
|
||||
|
||||
row.resize(pk->column_group->column_numbers.size());
|
||||
|
||||
while (1)
|
||||
{
|
||||
for (size_t i = 0; i < pk->column_group->column_numbers.size(); ++i)
|
||||
pk->table->columns->at(pk->column_group->column_numbers[i]).type->deserializeBinary(row[i], istr);
|
||||
|
||||
/// проверим, что ключи совпадают (замечание: столбцы ключа всегда идут первыми)
|
||||
for (size_t i = 0; i < key.size(); ++i)
|
||||
if (key[i] != row[i])
|
||||
continue;
|
||||
|
||||
if (istr.eof())
|
||||
return false;
|
||||
|
||||
@ -79,6 +76,11 @@ bool PrimaryKeyNoneTablePartReader::fetch(Row & row)
|
||||
throw Exception("Cannot read data file " + pk->data_file_name
|
||||
, ErrorCodes::CANT_READ_DATA_FILE);
|
||||
|
||||
/// проверим, что ключи совпадают (замечание: столбцы ключа всегда идут первыми)
|
||||
for (size_t i = 0; i < key.size(); ++i)
|
||||
if (key[i] != row[i])
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
/// создаём набор данных
|
||||
DB::AggregatedRowSet data;
|
||||
std::string text("http://www.google.com/custom?cof=LW%3A277%3BL%3Ahttp%3A%2F%2Fwww.boost.org%2Fboost.png%3BLH%3A86%3BAH%3Acenter%3BGL%3A0%3BS%3Ahttp%3A%2F%2Fwww.boost.org%3BAWFID%3A9b83d16ce652ed5a%3B&sa=Google+Search&domains=www.boost.org%3Blists.boost.org&hq=site%3Awww.boost.org+OR+site%3Alists.boost.org&q=boost%3A%3Ablank");
|
||||
{
|
||||
DB::Row key;
|
||||
key.push_back(DB::Field(DB::UInt(0)));
|
||||
@ -56,11 +57,11 @@ int main(int argc, char ** argv)
|
||||
|
||||
stopwatch.restart();
|
||||
|
||||
for (int i = 0; i < 1000000; ++i)
|
||||
for (DB::UInt i = 0; i < 1000000; ++i)
|
||||
{
|
||||
key[0] = DB::UInt(i);
|
||||
key[1] = DB::UInt(i * 123456789 % 1000000);
|
||||
key[2] = "http://www.google.com/custom?cof=LW%3A277%3BL%3Ahttp%3A%2F%2Fwww.boost.org%2Fboost.png%3BLH%3A86%3BAH%3Acenter%3BGL%3A0%3BS%3Ahttp%3A%2F%2Fwww.boost.org%3BAWFID%3A9b83d16ce652ed5a%3B&sa=Google+Search&domains=www.boost.org%3Blists.boost.org&hq=site%3Awww.boost.org+OR+site%3Alists.boost.org&q=boost%3A%3Ablank";
|
||||
key[0] = i;
|
||||
key[1] = i * 123456789 % 1000000;
|
||||
key[2] = text;
|
||||
|
||||
data[key] = value;
|
||||
}
|
||||
@ -81,5 +82,30 @@ int main(int argc, char ** argv)
|
||||
std::cout << "Saving data: " << static_cast<double>(stopwatch.elapsed()) / 1000000 << std::endl;
|
||||
}
|
||||
|
||||
/// читаем таблицу
|
||||
DB::AggregatedRowSet data_read;
|
||||
{
|
||||
DB::Row key;
|
||||
Poco::SharedPtr<DB::ITablePartReader> reader(column_group0.primary_key->read(key));
|
||||
|
||||
stopwatch.restart();
|
||||
|
||||
DB::Row row;
|
||||
DB::UInt i = 0;
|
||||
while (reader->fetch(row))
|
||||
{
|
||||
if (boost::get<DB::UInt>(row[0]) != i
|
||||
|| boost::get<DB::UInt>(row[1]) != i * 123456789 % 1000000
|
||||
|| boost::get<DB::String>(row[2]) != text)
|
||||
throw Poco::Exception("Incorrect data");
|
||||
++i;
|
||||
}
|
||||
if (i != 1000000)
|
||||
throw Poco::Exception("Number of rows doesn't match");
|
||||
|
||||
stopwatch.stop();
|
||||
std::cout << "Reading data: " << static_cast<double>(stopwatch.elapsed()) / 1000000 << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user