OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParquetDateInDaysFromTimestampEncoder.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
20 
21 namespace foreign_storage {
22 
23 // The following semantics apply to the templated types below.
24 //
25 // V - type of omnisci data
26 // T - physical type of parquet data
27 // conversion_denominator - the denominator constant used in converting parquet to omnisci
28 // data
29 //
30 // The `conversion_denominator` template is used instead of a class member to
31 // specify it at compile-time versus run-time. In testing this has a major
32 // impact on the runtime of the conversion performed by this encoder since the
33 // compiler can significantly optimize if this is known at compile time.
34 template <typename V, typename T, T conversion_denominator, typename NullType = V>
36  : public ParquetTimestampEncoder<V,
37  T,
38  conversion_denominator * kSecsPerDay,
39  NullType> {
40  public:
43  const ColumnDescriptor* column_desciptor,
44  const parquet::ColumnDescriptor* parquet_column_descriptor)
45  : ParquetTimestampEncoder<V, T, conversion_denominator * kSecsPerDay, NullType>(
46  buffer,
47  column_desciptor,
48  parquet_column_descriptor) {}
49 
50  void validate(const int8_t* parquet_data,
51  const int64_t j,
52  const SQLTypeInfo& column_type) const override {
53  const auto& parquet_data_value = reinterpret_cast<const T*>(parquet_data)[j];
54  CHECK(column_type.is_date());
55  DateInDaysBoundsValidator<T>::validateValue(this->convert(parquet_data_value),
56  column_type);
57  }
58 
59  void validate(std::shared_ptr<parquet::Statistics> stats,
60  const SQLTypeInfo& column_type) const override {
61  UNREACHABLE() << "ParquetDateInDaysFromTimestampEncoder should never be used during "
62  "metadata scan"
63  << std::endl;
64  }
65 };
66 } // namespace foreign_storage
static constexpr int64_t kSecsPerDay
static void validateValue(const D &data_value, const SQLTypeInfo &column_type)
ParquetDateInDaysFromTimestampEncoder(Data_Namespace::AbstractBuffer *buffer, const ColumnDescriptor *column_desciptor, const parquet::ColumnDescriptor *parquet_column_descriptor)
#define UNREACHABLE()
Definition: Logger.h:338
dictionary stats
Definition: report.py:116
An AbstractBuffer is a unit of data management for a data manager.
specifies the content in-memory of a row in the column metadata table
#define CHECK(condition)
Definition: Logger.h:291
void validate(std::shared_ptr< parquet::Statistics > stats, const SQLTypeInfo &column_type) const override
bool is_date() const
Definition: sqltypes.h:1028
void validate(const int8_t *parquet_data, const int64_t j, const SQLTypeInfo &column_type) const override