| 77 | |
| 78 | template <typename VectorT> |
| 79 | void writeBoolVector(tar::FileWriter &writer, const std::string &name, const VectorT &data) |
| 80 | { |
| 81 | const auto count = data.size(); |
| 82 | writer.WriteElementCount64(name, count); |
| 83 | std::uint64_t index = 0; |
| 84 | |
| 85 | using BlockType = std::uint64_t; |
| 86 | constexpr std::uint64_t BLOCK_BITS = CHAR_BIT * sizeof(BlockType); |
| 87 | |
| 88 | // FIXME on old boost version the function_input_iterator does not work with lambdas |
| 89 | // so we need to wrap it in a function here. |
| 90 | const std::function<BlockType()> encode_function = [&]() -> BlockType |
| 91 | { |
| 92 | auto write_size = std::min<std::size_t>(count - index, BLOCK_BITS); |
| 93 | auto packed = packBits<VectorT, BlockType>(data, index, write_size); |
| 94 | index += BLOCK_BITS; |
| 95 | return packed; |
| 96 | }; |
| 97 | |
| 98 | std::uint64_t number_of_blocks = (count + BLOCK_BITS - 1) / BLOCK_BITS; |
| 99 | writer.WriteStreaming<BlockType>( |
| 100 | name, osrm::util::make_function_input_iterator(encode_function), number_of_blocks); |
| 101 | } |
| 102 | } // namespace detail |
| 103 | |
| 104 | /* All vector formats here use the same on-disk format. |
no test coverage detected