| 246 | } |
| 247 | |
| 248 | DenseHllView deserialize(const char* serialized) { |
| 249 | common::InputByteStream stream(serialized); |
| 250 | |
| 251 | auto version = stream.read<int8_t>(); |
| 252 | BOLT_CHECK_EQ(kPrestoDenseV2, version); |
| 253 | |
| 254 | auto indexBitLength = stream.read<int8_t>(); |
| 255 | auto baseline = stream.read<int8_t>(); |
| 256 | |
| 257 | auto numBuckets = 1 << indexBitLength; |
| 258 | // next numBuckets / 2 bytes are deltas |
| 259 | const int8_t* deltas = stream.read<int8_t>(numBuckets / 2); |
| 260 | |
| 261 | auto overflows = stream.read<int16_t>(); |
| 262 | |
| 263 | const uint16_t* overflowBuckets = |
| 264 | overflows ? stream.read<uint16_t>(overflows) : nullptr; |
| 265 | const int8_t* overflowValues = |
| 266 | overflows ? stream.read<int8_t>(overflows) : nullptr; |
| 267 | |
| 268 | return DenseHllView{ |
| 269 | indexBitLength, |
| 270 | baseline, |
| 271 | deltas, |
| 272 | overflows, |
| 273 | overflowBuckets, |
| 274 | overflowValues}; |
| 275 | } |
| 276 | } // namespace |
| 277 | |
| 278 | int64_t DenseHll::cardinality() const { |
no outgoing calls