MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / WriteBlockPrefix

Method WriteBlockPrefix

include/util/indexed_data.hpp:214–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212 /// Write a fixed length block prefix.
213 template <typename OffsetIterator, typename OutByteIter>
214 OutByteIter WriteBlockPrefix(OffsetIterator first, OffsetIterator last, OutByteIter out) const
215 {
216 constexpr std::size_t MAX_LENGTH =
217 std::numeric_limits<std::make_unsigned_t<ValueType>>::max();
218
219 auto index = 0;
220 std::array<ValueType, BLOCK_SIZE> prefix{};
221
222 for (OffsetIterator curr = first, next = std::next(first); curr != last; ++curr, ++next)
223 {
224 const std::uint32_t data_length = *next - *curr;
225 if (data_length > MAX_LENGTH)
226 throw util::exception(
227 std::format("too large data length {} > {}", data_length, MAX_LENGTH));
228
229 prefix[index++] = data_length;
230 }
231
232 out = std::copy_n((const char *)prefix.data(), sizeof(ValueType) * BLOCK_SIZE, out);
233 return out;
234 }
235
236 /// Advances the range to an item stored in the referenced block.
237 /// Input [first..last) is a range of the complete block data with prefix.

Callers 1

IndexedDataImplMethod · 0.45

Calls 3

exceptionClass · 0.85
formatFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected