From 3d359e2b820d55066c9a193505dc40f37170fcb9 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 6 Nov 2014 09:32:23 +0300 Subject: [PATCH] Partially get rid of time2str.h [#METR-13554]. --- .../MergeTree/ReplicatedMergeTreeBlockOutputStream.h | 4 +--- dbms/src/Server/OLAPQueryParser.cpp | 3 +-- dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp | 10 +++++----- dbms/src/Storages/MergeTree/MergeTreeData.cpp | 5 ++--- dbms/src/Storages/StorageReplicatedMergeTree.cpp | 2 +- libs/libmysqlxx/src/tests/mysqlxx_test.cpp | 5 ++--- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h b/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h index b4cc1340657..5694ef60e60 100644 --- a/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h +++ b/dbms/include/DB/Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h @@ -2,7 +2,6 @@ #include #include -#include namespace DB @@ -32,8 +31,7 @@ public: ++block_index; String block_id = insert_id.empty() ? "" : insert_id + "__" + toString(block_index); - time_t min_date_time = DateLUT::instance().fromDayNum(DayNum_t(current_block.min_date)); - String month_name = toString(Date2OrderedIdentifier(min_date_time) / 100); + String month_name = toString(DateLUT::instance().toNumYYYYMMDD(DayNum_t(current_block.min_date)) / 100); AbandonableLockInZooKeeper block_number_lock = storage.allocateBlockNumber(month_name); diff --git a/dbms/src/Server/OLAPQueryParser.cpp b/dbms/src/Server/OLAPQueryParser.cpp index 3ccbf0c440a..defbcc7ebdd 100644 --- a/dbms/src/Server/OLAPQueryParser.cpp +++ b/dbms/src/Server/OLAPQueryParser.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -194,7 +193,7 @@ QueryParseResult QueryParser::parse(std::istream & s) result.limit = DB::parse(limit_nodes->item(0)->innerText()); LOG_DEBUG(log, "CounterID: " << result.CounterID - << ", dates: " << Date2Sql(result.date_first) << " - " << Date2Sql(result.date_last)); + << ", dates: " << mysqlxx::Date(result.date_first) << " - " << mysqlxx::Date(result.date_last)); /// получаем список имён атрибутов Poco::AutoPtr attributes = result.query->getElementsByTagName("attribute"); diff --git a/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp b/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp index 251763dcc44..b53d12ceb43 100644 --- a/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp +++ b/dbms/src/Storages/MergeTree/ActiveDataPartSet.cpp @@ -1,7 +1,7 @@ #include #include #include -#include + namespace DB { @@ -110,8 +110,8 @@ String ActiveDataPartSet::getPartName(DayNum_t left_date, DayNum_t right_date, U /// Имя директории для куска иммет вид: YYYYMMDD_YYYYMMDD_N_N_L. String res; { - unsigned left_date_id = Date2OrderedIdentifier(date_lut.fromDayNum(left_date)); - unsigned right_date_id = Date2OrderedIdentifier(date_lut.fromDayNum(right_date)); + unsigned left_date_id = date_lut.toNumYYYYMMDD(left_date); + unsigned right_date_id = date_lut.toNumYYYYMMDD(right_date); WriteBufferFromString wb(res); @@ -155,8 +155,8 @@ void ActiveDataPartSet::parsePartName(const String & file_name, Part & part, con DateLUT & date_lut = DateLUT::instance(); - part.left_date = date_lut.toDayNum(OrderedIdentifier2Date(file_name.substr(matches[1].offset, matches[1].length))); - part.right_date = date_lut.toDayNum(OrderedIdentifier2Date(file_name.substr(matches[2].offset, matches[2].length))); + part.left_date = date_lut.YYYYMMDDToDayNum(parse(file_name.substr(matches[1].offset, matches[1].length))); + part.right_date = date_lut.YYYYMMDDToDayNum(parse(file_name.substr(matches[2].offset, matches[2].length))); part.left = parse(file_name.substr(matches[3].offset, matches[3].length)); part.right = parse(file_name.substr(matches[4].offset, matches[4].length)); part.level = parse(file_name.substr(matches[5].offset, matches[5].length)); diff --git a/dbms/src/Storages/MergeTree/MergeTreeData.cpp b/dbms/src/Storages/MergeTree/MergeTreeData.cpp index 6f02a5f4e20..0910061ba25 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeData.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeData.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -1164,10 +1163,10 @@ static std::pair getMonthNameAndDayNum(const Field & partition throw Exception("Invalid partition format: " + month_name + ". Partition should consist of 6 digits: YYYYMM", ErrorCodes::INVALID_PARTITION_NAME); - DayNum_t date = DateLUT::instance().toDayNum(OrderedIdentifier2Date(month_name + "01")); + DayNum_t date = DateLUT::instance().YYYYMMDDToDayNum(parse(month_name + "01")); /// Не можем просто сравнить date с нулем, потому что 0 тоже валидный DayNum. - if (month_name != toString(Date2OrderedIdentifier(DateLUT::instance().fromDayNum(date)) / 100)) + if (month_name != toString(DateLUT::instance().toNumYYYYMMDD(date) / 100)) throw Exception("Invalid partition format: " + month_name + " doesn't look like month.", ErrorCodes::INVALID_PARTITION_NAME); diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index d4727d09216..34647d47dd5 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -2065,7 +2065,7 @@ static String getFakePartNameForDrop(const String & month_name, UInt64 left, UIn { /// Диапазон дат - весь месяц. DateLUT & lut = DateLUT::instance(); - time_t start_time = OrderedIdentifier2Date(month_name + "01"); + time_t start_time = DateLUT::instance().YYYYMMDDToDate(parse(month_name + "01")); DayNum_t left_date = lut.toDayNum(start_time); DayNum_t right_date = DayNum_t(static_cast(left_date) + lut.daysInMonth(start_time) - 1); diff --git a/libs/libmysqlxx/src/tests/mysqlxx_test.cpp b/libs/libmysqlxx/src/tests/mysqlxx_test.cpp index 736f6eef132..ae4abb92c22 100644 --- a/libs/libmysqlxx/src/tests/mysqlxx_test.cpp +++ b/libs/libmysqlxx/src/tests/mysqlxx_test.cpp @@ -1,6 +1,5 @@ #include #include -#include int main(int argc, char ** argv) @@ -23,8 +22,8 @@ int main(int argc, char ** argv) std::cerr << row[1] << ", " << row["d"] << ", " << row[1].getDate() << ", " << row[1].getDateTime() - << ", " << Date2Sql(row[1].getDate()) - << ", " << Time2Sql(row[1].getDateTime()) + << ", " << row[1].getDate() + << ", " << row[1].getDateTime() << std::endl << mysqlxx::escape << row[1].getDate() << ", " << mysqlxx::escape << row[1].getDateTime() << std::endl << mysqlxx::quote << row[1].getDate() << ", " << mysqlxx::quote << row[1].getDateTime() << std::endl