userver: userver/storages/clickhouse/io/columns/datetime64_column.hpp Source File
Loading...
Searching...
No Matches
datetime64_column.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/storages/clickhouse/io/columns/datetime64_column.hpp
4/// @brief DateTime64 columns support
5/// @ingroup userver_clickhouse_types
6
7#include <chrono>
8
9#include <userver/storages/clickhouse/io/columns/column_includes.hpp>
10
11USERVER_NAMESPACE_BEGIN
12
13namespace storages::clickhouse::io::columns {
14
15/// @brief Helper class for instantiating DateTime64 columns
16///
17/// see
18/// - storages::clickhouse::io::columns::DateTime64ColumnMilli
19/// - storages::clickhouse::io::columns::DateTime64ColumnMicro
20/// - storages::clickhouse::io::columns::DateTime64ColumnNano
21template <size_t Precision, typename T>
22class DateTime64Column;
23
24template <size_t Precision, typename Rep, typename Period, template <typename, typename> typename Duration>
25class DateTime64Column<Precision, Duration<Rep, Period>>
26 : public ClickhouseColumn<DateTime64Column<Precision, Duration<Rep, Period>>> {
27public:
28 using cpp_type = std::chrono::system_clock::time_point;
29 using container_type = std::vector<cpp_type>;
30
31 struct Tag final {
32 static constexpr size_t kPrecision = Precision;
33 using time_resolution = Duration<Rep, Period>;
34 };
35 using time_resolution = typename Tag::time_resolution;
36
37 DateTime64Column(ColumnRef column);
38
39 static ColumnRef Serialize(const container_type& from);
40};
41
42/// @brief Represents ClickHouse DateTime64(3) column
43using DateTime64ColumnMilli = DateTime64Column<3, std::chrono::milliseconds>;
44
45/// @brief Represents ClickHouse DateTime64(6) column
46using DateTime64ColumnMicro = DateTime64Column<6, std::chrono::microseconds>;
47
48/// @brief Represents ClickHouse DateTime64(9) column
49using DateTime64ColumnNano = DateTime64Column<9, std::chrono::nanoseconds>;
50
51} // namespace storages::clickhouse::io::columns
52
53USERVER_NAMESPACE_END