| 1 | //===----------------------------------------------------------------------===// |
|---|---|
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/common/patas/patas.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/storage/compression/patas/algorithm/patas.hpp" |
| 12 | #include "duckdb/common/assert.hpp" |
| 13 | #include "duckdb/common/exception.hpp" |
| 14 | #include "duckdb/common/helper.hpp" |
| 15 | #include "duckdb/common/limits.hpp" |
| 16 | #include "duckdb/function/compression_function.hpp" |
| 17 | |
| 18 | namespace duckdb { |
| 19 | |
| 20 | using byte_index_t = uint32_t; |
| 21 | |
| 22 | //! FIXME: replace ChimpType with this |
| 23 | template <class T> |
| 24 | struct FloatingToExact {}; |
| 25 | |
| 26 | template <> |
| 27 | struct FloatingToExact<double> { |
| 28 | typedef uint64_t type; |
| 29 | }; |
| 30 | |
| 31 | template <> |
| 32 | struct FloatingToExact<float> { |
| 33 | typedef uint32_t type; |
| 34 | }; |
| 35 | |
| 36 | template <class T, bool EMPTY> |
| 37 | struct PatasState { |
| 38 | public: |
| 39 | using EXACT_TYPE = typename FloatingToExact<T>::type; |
| 40 | |
| 41 | PatasState(void *state_p = nullptr) : data_ptr(state_p), patas_state() { |
| 42 | } |
| 43 | //! The Compress/Analyze State |
| 44 | void *data_ptr; |
| 45 | patas::PatasCompressionState<EXACT_TYPE, EMPTY> patas_state; |
| 46 | |
| 47 | public: |
| 48 | void AssignDataBuffer(uint8_t *data_out) { |
| 49 | patas_state.SetOutputBuffer(data_out); |
| 50 | } |
| 51 | |
| 52 | template <class OP> |
| 53 | bool Update(T uncompressed_value, bool is_valid) { |
| 54 | OP::template Operation<T>(uncompressed_value, is_valid, data_ptr); |
| 55 | return true; |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | } // namespace duckdb |
| 60 |