-
Notifications
You must be signed in to change notification settings - Fork 135
Expand file tree
/
Copy pathcodecfactory.cpp
More file actions
220 lines (211 loc) · 7.29 KB
/
Copy pathcodecfactory.cpp
File metadata and controls
220 lines (211 loc) · 7.29 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#include "codecfactory.h"
#include "common.h"
#include "codecs.h"
#include "vsencoding.h"
#include "util.h"
#include "simple16.h"
#include "simple9.h"
#include "simple9_rle.h"
#include "simple8b.h"
#include "simple8b_rle.h"
#include "newpfor.h"
#include "simdnewpfor.h"
#include "optpfor.h"
#include "simdoptpfor.h"
#include "fastpfor.h"
#include "simdfastpfor.h"
#include "variablebyte.h"
#include "compositecodec.h"
#include "blockpacking.h"
#include "pfor.h"
#include "simdpfor.h"
#include "pfor2008.h"
#include "VarIntG8IU.h"
#include "simdbinarypacking.h"
#include "snappydelta.h"
#include "varintgb.h"
#include "simdvariablebyte.h"
#include "streamvariablebyte.h"
#include "simdgroupsimple.h"
namespace FastPForLib {
std::vector<std::shared_ptr<IntegerCODEC>> CODECFactory::allSchemes() const {
std::vector<std::shared_ptr<IntegerCODEC>> ans;
for (auto i = scodecmap.begin(); i != scodecmap.end(); ++i) {
ans.push_back(i->second);
}
return ans;
}
std::vector<std::string> CODECFactory::allNames() const {
std::vector<std::string> ans;
for (auto i = scodecmap.begin(); i != scodecmap.end(); ++i) {
ans.push_back(i->first);
}
return ans;
}
std::shared_ptr<IntegerCODEC> const& CODECFactory::getFromName(std::string name) const {
auto it = scodecmap.find(name);
if (it != scodecmap.end())
return it->second;
fprintf(stderr, "name %s does not refer to a CODEC.\n"
"possible choices:\n", name.c_str());
for (auto i = scodecmap.begin(); i != scodecmap.end(); ++i) {
fprintf(stderr, "%s\n", i->first.c_str());
}
fprintf(stderr, "for now, I'm going to just return 'copy'\n");
return scodecmap.at("copy");
}
// std::make_unique equivalent
template<typename T, typename... Args>
static std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
std::unique_ptr<IntegerCODEC> fastbinarypacking8_codec() {
return make_unique<CompositeCodec<FastBinaryPacking<8>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> fastbinarypacking16_codec() {
return make_unique<CompositeCodec<FastBinaryPacking<16>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> fastbinarypacking32_codec() {
return make_unique<CompositeCodec<FastBinaryPacking<32>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> BP32_codec() {
return make_unique<CompositeCodec<BP32, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> vsencoding_codec() {
return make_unique<vsencoding::VSEncodingBlocks>(1U << 16);
}
std::unique_ptr<IntegerCODEC> fastpfor128_codec() {
return make_unique<CompositeCodec<FastPFor<4>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> fastpfor256_codec() {
return make_unique<CompositeCodec<FastPFor<8>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdfastpfor128_codec() {
return make_unique<CompositeCodec<SIMDFastPFor<4>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdfastpfor256_codec() {
return make_unique<CompositeCodec<SIMDFastPFor<8>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simplepfor_codec() {
return make_unique<CompositeCodec<SimplePFor<>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdsimplepfor_codec() {
return make_unique<CompositeCodec<SIMDSimplePFor<>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> pfor_codec() {
return make_unique<CompositeCodec<PFor, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdpfor_codec() {
return make_unique<CompositeCodec<SIMDPFor, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> pfor2008_codec() {
return make_unique<CompositeCodec<PFor2008, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdnewpfor_codec() {
return make_unique<CompositeCodec<SIMDNewPFor<4, Simple16<false>>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> newpfor_codec() {
return make_unique<CompositeCodec<NewPFor<4, Simple16<false>>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> optpfor_codec() {
return make_unique<CompositeCodec<OPTPFor<4, Simple16<false>>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdoptpfor_codec() {
return make_unique<CompositeCodec<SIMDOPTPFor<4, Simple16<false>>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> varint_codec() {
return make_unique<VariableByte>();
}
std::unique_ptr<IntegerCODEC> vbyte_codec() {
return make_unique<VByte>();
}
std::unique_ptr<IntegerCODEC> maskedvbyte_codec() {
return make_unique<MaskedVByte>();
}
std::unique_ptr<IntegerCODEC> streamvbyte_codec() {
return make_unique<StreamVByte>();
}
std::unique_ptr<IntegerCODEC> varintgb_codec() {
return make_unique<VarIntGB<>>();
}
std::unique_ptr<IntegerCODEC> simple16_codec() {
return make_unique<Simple16<true>>();
}
std::unique_ptr<IntegerCODEC> simple9_codec() {
return make_unique<Simple9<true>>();
}
std::unique_ptr<IntegerCODEC> simple9_rle_codec() {
return make_unique<Simple9_RLE<true>>();
}
std::unique_ptr<IntegerCODEC> simple8b_codec() {
return make_unique<Simple8b<true>>();
}
std::unique_ptr<IntegerCODEC> simple8b_rle_codec() {
return make_unique<Simple8b_RLE<true>>();
}
#ifdef VARINTG8IU_H__
std::unique_ptr<IntegerCODEC> varintg8iu_codec() {
return make_unique<VarIntG8IU>();
}
#endif
#ifdef USESNAPPY
std::unique_ptr<IntegerCODEC> snappy_codec() {
return make_unique<JustSnappy>();
}
#endif
std::unique_ptr<IntegerCODEC> simdbinarypacking_codec() {
return make_unique<CompositeCodec<SIMDBinaryPacking, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdgroupsimple_codec() {
return make_unique<CompositeCodec<SIMDGroupSimple<false, false>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> simdgroupsimple_ringbuf_codec() {
return make_unique<CompositeCodec<SIMDGroupSimple<true, true>, VariableByte>>();
}
std::unique_ptr<IntegerCODEC> copy_codec() {
return make_unique<JustCopy>();
}
static CodecMap initializefactory() {
CodecMap map;
map["fastbinarypacking8"] = fastbinarypacking8_codec();
map["fastbinarypacking16"] = fastbinarypacking16_codec();
map["fastbinarypacking32"] = fastbinarypacking32_codec();
map["BP32"] = BP32_codec();
map["vsencoding"] = vsencoding_codec();
map["fastpfor128"] = fastpfor128_codec();
map["fastpfor256"] = fastpfor256_codec();
map["simdfastpfor128"] = simdfastpfor128_codec();
map["simdfastpfor256"] = simdfastpfor256_codec();
map["simplepfor"] = simplepfor_codec();
map["simdsimplepfor"] = simdsimplepfor_codec();
map["pfor"] = pfor_codec();
map["simdpfor"] = simdpfor_codec();
map["pfor2008"] = pfor2008_codec();
map["simdnewpfor"] = simdnewpfor_codec();
map["newpfor"] = newpfor_codec();
map["optpfor"] = optpfor_codec();
map["simdoptpfor"] = simdoptpfor_codec();
map["varint"] = varint_codec();
map["vbyte"] = vbyte_codec();
map["maskedvbyte"] = maskedvbyte_codec();
map["streamvbyte"] = streamvbyte_codec();
map["varintgb"] = varintgb_codec();
map["simple16"] = simple16_codec();
map["simple9"] = simple9_codec();
map["simple9_rle"] = simple9_rle_codec();
map["simple8b"] = simple8b_codec();
map["simple8b_rle"] = simple8b_rle_codec();
#ifdef VARINTG8IU_H__
map["varintg8iu"] = varintg8iu_codec();
#endif
#ifdef USESNAPPY
map["snappy"] = snappy_codec();
#endif
map["simdbinarypacking"] = simdbinarypacking_codec();
map["simdgroupsimple"] = simdgroupsimple_codec();
map["simdgroupsimple_ringbuf"] = simdgroupsimple_ringbuf_codec();
map["copy"] = copy_codec();
return map;
}
CODECFactory::CODECFactory() : scodecmap(initializefactory()) {}
} // namespace FastPForLib