| 46 | : view_(std::move(view)), valid_(ValidContiguousView(view_)) {} |
| 47 | |
| 48 | int next_batch(uint32_t max_count, VectorBatch *out) override { |
| 49 | if (!out || !max_count) return IndexError_InvalidArgument; |
| 50 | auto &batch = out->emplace<ContiguousBatch>(); |
| 51 | if (!valid_) return IndexError_InvalidArgument; |
| 52 | if (offset_ == view_.count) return 0; |
| 53 | const auto count = std::min(max_count, view_.count - offset_); |
| 54 | batch = { |
| 55 | static_cast<const char *>(view_.data) + size_t(offset_) * view_.stride, |
| 56 | view_.first_id + offset_, count, view_.stride, view_.lease}; |
| 57 | offset_ += count; |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | private: |
| 62 | const ContiguousBatch view_; |