| 91 | /// \return a pair of physical offset and physical length |
| 92 | template <typename RunEndCType> |
| 93 | std::pair<int64_t, int64_t> FindPhysicalRange(const RunEndCType* run_ends, |
| 94 | int64_t run_ends_size, int64_t length, |
| 95 | int64_t offset) { |
| 96 | const int64_t physical_offset = |
| 97 | FindPhysicalIndex<RunEndCType>(run_ends, run_ends_size, 0, offset); |
| 98 | // The physical length is calculated by finding the offset of the last element |
| 99 | // and adding 1 to it, so first we ensure there is at least one element. |
| 100 | if (length == 0) { |
| 101 | return {physical_offset, 0}; |
| 102 | } |
| 103 | const int64_t physical_index_of_last = FindPhysicalIndex<RunEndCType>( |
| 104 | run_ends + physical_offset, run_ends_size - physical_offset, length - 1, offset); |
| 105 | |
| 106 | assert(physical_index_of_last < run_ends_size - physical_offset); |
| 107 | return {physical_offset, physical_index_of_last + 1}; |
| 108 | } |
| 109 | |
| 110 | /// \brief Uses binary-search to calculate the number of physical values (and |
| 111 | /// run-ends) necessary to represent the logical range of values from |
no outgoing calls