mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Partially get rid of time2str.h [#METR-13554].
This commit is contained in:
parent
6754ee8068
commit
3d359e2b82
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <DB/Storages/StorageReplicatedMergeTree.h>
|
#include <DB/Storages/StorageReplicatedMergeTree.h>
|
||||||
#include <DB/Storages/MergeTree/AbandonableLockInZooKeeper.h>
|
#include <DB/Storages/MergeTree/AbandonableLockInZooKeeper.h>
|
||||||
#include <Yandex/time2str.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
@ -32,8 +31,7 @@ public:
|
|||||||
|
|
||||||
++block_index;
|
++block_index;
|
||||||
String block_id = insert_id.empty() ? "" : insert_id + "__" + toString(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(DateLUT::instance().toNumYYYYMMDD(DayNum_t(current_block.min_date)) / 100);
|
||||||
String month_name = toString(Date2OrderedIdentifier(min_date_time) / 100);
|
|
||||||
|
|
||||||
AbandonableLockInZooKeeper block_number_lock = storage.allocateBlockNumber(month_name);
|
AbandonableLockInZooKeeper block_number_lock = storage.allocateBlockNumber(month_name);
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <Yandex/DateLUT.h>
|
#include <Yandex/DateLUT.h>
|
||||||
#include <Yandex/time2str.h>
|
|
||||||
#include <Poco/DateTimeParser.h>
|
#include <Poco/DateTimeParser.h>
|
||||||
#include <Poco/AutoPtr.h>
|
#include <Poco/AutoPtr.h>
|
||||||
|
|
||||||
@ -194,7 +193,7 @@ QueryParseResult QueryParser::parse(std::istream & s)
|
|||||||
result.limit = DB::parse<unsigned>(limit_nodes->item(0)->innerText());
|
result.limit = DB::parse<unsigned>(limit_nodes->item(0)->innerText());
|
||||||
|
|
||||||
LOG_DEBUG(log, "CounterID: " << result.CounterID
|
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<Poco::XML::NodeList> attributes = result.query->getElementsByTagName("attribute");
|
Poco::AutoPtr<Poco::XML::NodeList> attributes = result.query->getElementsByTagName("attribute");
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <DB/Storages/MergeTree/ActiveDataPartSet.h>
|
#include <DB/Storages/MergeTree/ActiveDataPartSet.h>
|
||||||
#include <DB/IO/WriteHelpers.h>
|
#include <DB/IO/WriteHelpers.h>
|
||||||
#include <DB/IO/ReadHelpers.h>
|
#include <DB/IO/ReadHelpers.h>
|
||||||
#include <Yandex/time2str.h>
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -110,8 +110,8 @@ String ActiveDataPartSet::getPartName(DayNum_t left_date, DayNum_t right_date, U
|
|||||||
/// Имя директории для куска иммет вид: YYYYMMDD_YYYYMMDD_N_N_L.
|
/// Имя директории для куска иммет вид: YYYYMMDD_YYYYMMDD_N_N_L.
|
||||||
String res;
|
String res;
|
||||||
{
|
{
|
||||||
unsigned left_date_id = Date2OrderedIdentifier(date_lut.fromDayNum(left_date));
|
unsigned left_date_id = date_lut.toNumYYYYMMDD(left_date);
|
||||||
unsigned right_date_id = Date2OrderedIdentifier(date_lut.fromDayNum(right_date));
|
unsigned right_date_id = date_lut.toNumYYYYMMDD(right_date);
|
||||||
|
|
||||||
WriteBufferFromString wb(res);
|
WriteBufferFromString wb(res);
|
||||||
|
|
||||||
@ -155,8 +155,8 @@ void ActiveDataPartSet::parsePartName(const String & file_name, Part & part, con
|
|||||||
|
|
||||||
DateLUT & date_lut = DateLUT::instance();
|
DateLUT & date_lut = DateLUT::instance();
|
||||||
|
|
||||||
part.left_date = date_lut.toDayNum(OrderedIdentifier2Date(file_name.substr(matches[1].offset, matches[1].length)));
|
part.left_date = date_lut.YYYYMMDDToDayNum(parse<UInt32>(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.right_date = date_lut.YYYYMMDDToDayNum(parse<UInt32>(file_name.substr(matches[2].offset, matches[2].length)));
|
||||||
part.left = parse<UInt64>(file_name.substr(matches[3].offset, matches[3].length));
|
part.left = parse<UInt64>(file_name.substr(matches[3].offset, matches[3].length));
|
||||||
part.right = parse<UInt64>(file_name.substr(matches[4].offset, matches[4].length));
|
part.right = parse<UInt64>(file_name.substr(matches[4].offset, matches[4].length));
|
||||||
part.level = parse<UInt32>(file_name.substr(matches[5].offset, matches[5].length));
|
part.level = parse<UInt32>(file_name.substr(matches[5].offset, matches[5].length));
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include <Yandex/time2str.h>
|
|
||||||
#include <Poco/Ext/ScopedTry.h>
|
#include <Poco/Ext/ScopedTry.h>
|
||||||
|
|
||||||
#include <DB/Storages/MergeTree/MergeTreeData.h>
|
#include <DB/Storages/MergeTree/MergeTreeData.h>
|
||||||
@ -1164,10 +1163,10 @@ static std::pair<String, DayNum_t> getMonthNameAndDayNum(const Field & partition
|
|||||||
throw Exception("Invalid partition format: " + month_name + ". Partition should consist of 6 digits: YYYYMM",
|
throw Exception("Invalid partition format: " + month_name + ". Partition should consist of 6 digits: YYYYMM",
|
||||||
ErrorCodes::INVALID_PARTITION_NAME);
|
ErrorCodes::INVALID_PARTITION_NAME);
|
||||||
|
|
||||||
DayNum_t date = DateLUT::instance().toDayNum(OrderedIdentifier2Date(month_name + "01"));
|
DayNum_t date = DateLUT::instance().YYYYMMDDToDayNum(parse<UInt32>(month_name + "01"));
|
||||||
|
|
||||||
/// Не можем просто сравнить date с нулем, потому что 0 тоже валидный DayNum.
|
/// Не можем просто сравнить 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.",
|
throw Exception("Invalid partition format: " + month_name + " doesn't look like month.",
|
||||||
ErrorCodes::INVALID_PARTITION_NAME);
|
ErrorCodes::INVALID_PARTITION_NAME);
|
||||||
|
|
||||||
|
@ -2065,7 +2065,7 @@ static String getFakePartNameForDrop(const String & month_name, UInt64 left, UIn
|
|||||||
{
|
{
|
||||||
/// Диапазон дат - весь месяц.
|
/// Диапазон дат - весь месяц.
|
||||||
DateLUT & lut = DateLUT::instance();
|
DateLUT & lut = DateLUT::instance();
|
||||||
time_t start_time = OrderedIdentifier2Date(month_name + "01");
|
time_t start_time = DateLUT::instance().YYYYMMDDToDate(parse<UInt32>(month_name + "01"));
|
||||||
DayNum_t left_date = lut.toDayNum(start_time);
|
DayNum_t left_date = lut.toDayNum(start_time);
|
||||||
DayNum_t right_date = DayNum_t(static_cast<size_t>(left_date) + lut.daysInMonth(start_time) - 1);
|
DayNum_t right_date = DayNum_t(static_cast<size_t>(left_date) + lut.daysInMonth(start_time) - 1);
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mysqlxx/mysqlxx.h>
|
#include <mysqlxx/mysqlxx.h>
|
||||||
#include <Yandex/time2str.h>
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
@ -23,8 +22,8 @@ int main(int argc, char ** argv)
|
|||||||
std::cerr << row[1] << ", " << row["d"]
|
std::cerr << row[1] << ", " << row["d"]
|
||||||
<< ", " << row[1].getDate()
|
<< ", " << row[1].getDate()
|
||||||
<< ", " << row[1].getDateTime()
|
<< ", " << row[1].getDateTime()
|
||||||
<< ", " << Date2Sql(row[1].getDate())
|
<< ", " << row[1].getDate()
|
||||||
<< ", " << Time2Sql(row[1].getDateTime())
|
<< ", " << row[1].getDateTime()
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< mysqlxx::escape << row[1].getDate() << ", " << mysqlxx::escape << 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
|
<< mysqlxx::quote << row[1].getDate() << ", " << mysqlxx::quote << row[1].getDateTime() << std::endl
|
||||||
|
Loading…
Reference in New Issue
Block a user