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

Class ChunkedArrayIterator

cpp/src/arrow/stl_iterator.h:139–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137template <typename ArrayType,
138 typename ValueAccessor = detail::DefaultValueAccessor<ArrayType>>
139class ChunkedArrayIterator {
140 public:
141 using value_type = std::optional<typename ValueAccessor::ValueType>;
142 using difference_type = int64_t;
143 using pointer = value_type*;
144 using reference = value_type&;
145 using iterator_category = std::random_access_iterator_tag;
146
147 // Some algorithms need to default-construct an iterator
148 ChunkedArrayIterator() noexcept : chunked_array_(NULLPTR), index_(0) {}
149
150 explicit ChunkedArrayIterator(const ChunkedArray& chunked_array,
151 int64_t index = 0) noexcept
152 : chunked_array_(&chunked_array), index_(index) {}
153
154 // Value access
155 value_type operator*() const {
156 auto chunk_location = GetChunkLocation(index_);
157 ArrayIterator<ArrayType> target_iterator{
158 arrow::internal::checked_cast<const ArrayType&>(
159 *chunked_array_->chunk(static_cast<int>(chunk_location.chunk_index)))};
160 return target_iterator[chunk_location.index_in_chunk];
161 }
162
163 value_type operator[](difference_type n) const { return *(*this + n); }
164
165 int64_t index() const { return index_; }
166
167 // Forward / backward
168 ChunkedArrayIterator& operator++() {
169 (*this) += 1;
170 return *this;
171 }
172 ChunkedArrayIterator& operator--() {
173 (*this) -= 1;
174 return *this;
175 }
176
177 ChunkedArrayIterator operator++(int) {
178 ChunkedArrayIterator tmp(*this);
179 ++*this;
180 return tmp;
181 }
182 ChunkedArrayIterator operator--(int) {
183 ChunkedArrayIterator tmp(*this);
184 --*this;
185 return tmp;
186 }
187
188 // Arithmetic
189 difference_type operator-(const ChunkedArrayIterator& other) const {
190 return index_ - other.index_;
191 }
192 ChunkedArrayIterator operator+(difference_type n) const {
193 assert(chunked_array_);
194 return ChunkedArrayIterator(*chunked_array_, index_ + n);
195 }
196 ChunkedArrayIterator operator-(difference_type n) const {

Callers 2

operator+Method · 0.70
operator-Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected