Function gkfs::utils::arithmetic::block_index

Function Documentation

constexpr uint64_t gkfs::utils::arithmetic::block_index(const uint64_t offset, const size_t block_size)

Given an @offset and a @block_size, compute the block index to which @offset belongs.

Note

Block indexes are (conceptually) computed by dividing @offset by @block_size, with index 0 referring to block [0, block_size - 1], index 1 to block [block_size, 2 * block_size - 1], and so on up to a maximum index FILE_LENGTH / block_size.

Note

This function assumes that @block_size is a power of 2.

Parameters
  • offset[in] the offset for which the block index should be computed.

  • block_size[in] the block_size that should be used to compute the index.

Returns

the index of the block containing @offset.