@@ -113,4 +113,73 @@ ItemView ColumnDateTime::GetItem(size_t index) const {
113
113
return data_->GetItem (index );
114
114
}
115
115
116
+ ColumnDateTime64::ColumnDateTime64 (size_t precision)
117
+ : ColumnDateTime64(Type::CreateDateTime64(precision), std::make_shared<ColumnDecimal>(18ul , precision))
118
+ {}
119
+
120
+ ColumnDateTime64::ColumnDateTime64 (TypeRef type, std::shared_ptr<ColumnDecimal> data)
121
+ : Column(type),
122
+ data_ (data),
123
+ precision_(type->As<DateTime64Type>()->GetPrecision())
124
+ {}
125
+
126
+ void ColumnDateTime64::Append (const Int64& value) {
127
+ // TODO: we need a type, which safely represents datetime.
128
+ // The precision of Poco.DateTime is not big enough.
129
+ data_->Append (value);
130
+ }
131
+
132
+ // void ColumnDateTime64::Append(const std::string& value) {
133
+ // data_->Append(value);
134
+ // }
135
+
136
+ Int64 ColumnDateTime64::At (size_t n) const {
137
+ return data_->At (n);
138
+ }
139
+
140
+ void ColumnDateTime64::Append (ColumnRef column) {
141
+ if (auto col = column->As <ColumnDateTime64>()) {
142
+ data_->Append (col->data_ );
143
+ }
144
+ }
145
+
146
+ bool ColumnDateTime64::Load (CodedInputStream* input, size_t rows) {
147
+ return data_->Load (input, rows);
148
+ }
149
+
150
+ void ColumnDateTime64::Save (CodedOutputStream* output) {
151
+ data_->Save (output);
152
+ }
153
+
154
+ void ColumnDateTime64::Clear () {
155
+ data_->Clear ();
156
+ }
157
+ size_t ColumnDateTime64::Size () const {
158
+ return data_->Size ();
159
+ }
160
+
161
+ ItemView ColumnDateTime64::GetItem (size_t index) const {
162
+ return data_->GetItem (index );
163
+ }
164
+
165
+ void ColumnDateTime64::Swap (Column& other) {
166
+ auto & col = dynamic_cast <ColumnDateTime64&>(other);
167
+ if (col.GetPrecision () != GetPrecision ()) {
168
+ throw std::runtime_error (" Can't swap DateTime64 columns when precisions are not the same: "
169
+ + std::to_string (GetPrecision ()) + " (this) != " + std::to_string (col.GetPrecision ()) + " (that)" );
170
+ }
171
+
172
+ data_.swap (col.data_ );
173
+ }
174
+
175
+ ColumnRef ColumnDateTime64::Slice (size_t begin, size_t len) {
176
+ auto sliced_data = data_->Slice (begin, len)->As <ColumnDecimal>();
177
+
178
+ return ColumnRef{new ColumnDateTime64 (type_, sliced_data)};
179
+ }
180
+
181
+ size_t ColumnDateTime64::GetPrecision () const {
182
+ return precision_;
183
+ }
184
+
116
185
}
0 commit comments