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
18namespace duckdb {
19
20using byte_index_t = uint32_t;
21
22//! FIXME: replace ChimpType with this
23template <class T>
24struct FloatingToExact {};
25
26template <>
27struct FloatingToExact<double> {
28 typedef uint64_t type;
29};
30
31template <>
32struct FloatingToExact<float> {
33 typedef uint32_t type;
34};
35
36template <class T, bool EMPTY>
37struct PatasState {
38public:
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
47public:
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