VeloGraphX
High-performance dynamic graph analytics in C++20
Loading...
Searching...
No Matches
compression_policy.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstddef>
7#include <vector>
8
9namespace velographx::storage {
10
15
23
25 const std::vector<VertexId>& ids,
26 std::size_t block_size = 128,
27 double max_fixed_width_overhead = 1.10) {
28 if (max_fixed_width_overhead < 1.0)
29 throw std::invalid_argument("max fixed-width overhead must be at least 1.0");
30
31 const auto varbyte = variable_byte_delta_encode(ids);
32 const auto fixed = simd_friendly_delta_encode(ids, block_size);
33 const auto backend = vector_decode_backend();
34
35 const auto varbyte_bytes = varbyte.size();
36 const auto fixed_bytes = fixed.payload.size();
37 const double overhead = varbyte_bytes == 0
38 ? 1.0
39 : static_cast<double>(fixed_bytes) / static_cast<double>(varbyte_bytes);
40
42 if (fixed_bytes < varbyte_bytes) {
44 } else if (backend != VectorDecodeBackend::scalar &&
45 !ids.empty() &&
46 overhead <= max_fixed_width_overhead) {
48 }
49
50 return {selected, varbyte_bytes, fixed_bytes, backend, overhead};
51}
52
53} // namespace velographx::storage
VectorDecodeBackend vector_decode_backend() noexcept
SimdFriendlyAdjacency simd_friendly_delta_encode(const std::vector< VertexId > &ids, std::size_t block_size=128)
std::vector< std::uint8_t > variable_byte_delta_encode(const std::vector< VertexId > &ids)
CompressionRecommendation recommend_compression_codec(const std::vector< VertexId > &ids, std::size_t block_size=128, double max_fixed_width_overhead=1.10)