| 172 | |
| 173 | template <typename ArrayType> |
| 174 | void MergeNonNulls(std::span<CompressedChunkLocation> left, |
| 175 | std::span<CompressedChunkLocation> right, |
| 176 | std::span<const Array* const> arrays, |
| 177 | std::span<CompressedChunkLocation> temp_indices) { |
| 178 | using ArrowType = typename ArrayType::TypeClass; |
| 179 | |
| 180 | if (order_ == SortOrder::Ascending) { |
| 181 | std::merge(left.data(), left.data() + left.size(), right.data(), |
| 182 | right.data() + right.size(), temp_indices.data(), |
| 183 | [&](CompressedChunkLocation left, CompressedChunkLocation right) { |
| 184 | return ChunkValue<ArrowType>(arrays, left) < |
| 185 | ChunkValue<ArrowType>(arrays, right); |
| 186 | }); |
| 187 | } else { |
| 188 | std::merge(left.data(), left.data() + left.size(), right.data(), |
| 189 | right.data() + right.size(), temp_indices.data(), |
| 190 | [&](CompressedChunkLocation left, CompressedChunkLocation right) { |
| 191 | // We don't use 'left > right' here to reduce required |
| 192 | // operator. If we use 'right < left' here, '<' is only |
| 193 | // required. |
| 194 | return ChunkValue<ArrowType>(arrays, right) < |
| 195 | ChunkValue<ArrowType>(arrays, left); |
| 196 | }); |
| 197 | } |
| 198 | // Copy back temp area into main buffer |
| 199 | std::copy(temp_indices.data(), temp_indices.data() + left.size() + right.size(), |
| 200 | left.data()); |
| 201 | } |
| 202 | |
| 203 | template <typename ArrowType> |
| 204 | auto ChunkValue(std::span<const Array* const> arrays, |