MCPcopy Create free account
hub / github.com/apache/arrow / Iterator

Class Iterator

cpp/src/arrow/util/ree_util.h:245–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243 /// \brief Iterator representing the current run during iteration over a
244 /// run-end encoded array
245 class Iterator {
246 public:
247 Iterator(PrivateTag, const RunEndEncodedArraySpan& span, int64_t logical_pos,
248 int64_t physical_pos)
249 : span(span), logical_pos_(logical_pos), physical_pos_(physical_pos) {}
250
251 /// \brief Return the physical index of the run
252 ///
253 /// The values array can be addressed with this index to get the value
254 /// that makes up the run.
255 ///
256 /// NOTE: if this Iterator is equal to RunEndEncodedArraySpan::end(),
257 /// the value returned is undefined.
258 int64_t index_into_array() const { return physical_pos_; }
259
260 /// \brief Return the initial logical position of the run
261 ///
262 /// If this Iterator is equal to RunEndEncodedArraySpan::end(), this is
263 /// the same as RunEndEncodedArraySpan::length().
264 int64_t logical_position() const { return logical_pos_; }
265
266 /// \brief Return the logical position immediately after the run.
267 ///
268 /// Pre-condition: *this != RunEndEncodedArraySpan::end()
269 int64_t run_end() const { return span.run_end(physical_pos_); }
270
271 /// \brief Returns the logical length of the run.
272 ///
273 /// Pre-condition: *this != RunEndEncodedArraySpan::end()
274 int64_t run_length() const { return run_end() - logical_pos_; }
275
276 /// \brief Check if the iterator is at the end of the array.
277 ///
278 /// This can be used to avoid paying the cost of a call to
279 /// RunEndEncodedArraySpan::end().
280 ///
281 /// \return true if the iterator is at the end of the array
282 bool is_end(const RunEndEncodedArraySpan& span) const {
283 return logical_pos_ >= span.length();
284 }
285
286 Iterator& operator++() {
287 logical_pos_ = span.run_end(physical_pos_);
288 physical_pos_ += 1;
289 return *this;
290 }
291
292 Iterator operator++(int) {
293 const Iterator prev = *this;
294 ++(*this);
295 return prev;
296 }
297
298 Iterator& operator--() {
299 physical_pos_ -= 1;
300 logical_pos_ = (physical_pos_ > 0) ? span.run_end(physical_pos_ - 1) : 0;
301 return *this;
302 }

Callers

nothing calls this directly

Calls 1

run_endMethod · 0.45

Tested by

no test coverage detected