blob: 3433bfa708cb1a4edabb7c5d4f7cc7748a42ccf1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#pragma once
#include <yt/yt/core/misc/public.h>
#include <numeric>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
class TCompressedViewBase
{
public:
using TWord = ui64;
static constexpr ui8 WordSize = sizeof(TWord) * 8;
TCompressedViewBase() = default;
TCompressedViewBase(ui32 size, ui8 width);
size_t GetSize() const;
size_t GetWidth() const;
size_t GetSizeInWords() const;
size_t GetSizeInBytes() const;
private:
ui32 Size_ = 0;
ui8 Width_ = 0;
};
class TCompressedVectorView
: public TCompressedViewBase
{
public:
TCompressedVectorView() = default;
TCompressedVectorView(const ui64* ptr, ui32 size, ui8 width);
explicit TCompressedVectorView(const ui64* ptr);
Y_FORCE_INLINE void Prefetch(size_t index) const;
Y_FORCE_INLINE TWord operator[] (size_t index) const;
template <class T>
void UnpackTo(T* output);
template <class T>
void UnpackTo(T* output, ui32 start, ui32 end);
protected:
static constexpr int WidthBitsOffset = 56;
const ui64* Ptr_ = nullptr;
};
class TCompressedVectorView32
: public TCompressedViewBase
{
public:
TCompressedVectorView32() = default;
TCompressedVectorView32(const ui64* ptr, ui32 size, ui8 width);
explicit TCompressedVectorView32(const ui64* ptr);
Y_FORCE_INLINE void Prefetch(size_t index) const;
Y_FORCE_INLINE ui32 operator[] (size_t index) const;
private:
const ui64* Ptr_ = nullptr;
};
////////////////////////////////////////////////////////////////////////////////
template <class T>
size_t UnpackBitVector(TCompressedVectorView view, std::vector<T>* container);
template <class T>
size_t UnpackBitVector(const ui64* input, std::vector<T>* container);
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
#define BIT_PACKING_INL_H_
#include "bit_packing-inl.h"
#undef BIT_PACKING_INL_H_
|