Enable natural copies of the batch iterators without the need of the clone method (#4748)
- the synthesized copy constructor should do the appropriate job
This commit is contained in:
parent
19f9fd5de9
commit
198f3a6c4a
@ -285,7 +285,6 @@ template<typename T>
|
|||||||
class BatchIteratorImpl {
|
class BatchIteratorImpl {
|
||||||
public:
|
public:
|
||||||
virtual ~BatchIteratorImpl() {}
|
virtual ~BatchIteratorImpl() {}
|
||||||
virtual BatchIteratorImpl* Clone() = 0;
|
|
||||||
virtual T& operator*() = 0;
|
virtual T& operator*() = 0;
|
||||||
virtual const T& operator*() const = 0;
|
virtual const T& operator*() const = 0;
|
||||||
virtual void operator++() = 0;
|
virtual void operator++() = 0;
|
||||||
@ -298,14 +297,6 @@ class BatchIterator {
|
|||||||
using iterator_category = std::forward_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
explicit BatchIterator(BatchIteratorImpl<T>* impl) { impl_.reset(impl); }
|
explicit BatchIterator(BatchIteratorImpl<T>* impl) { impl_.reset(impl); }
|
||||||
|
|
||||||
BatchIterator(const BatchIterator& other) {
|
|
||||||
if (other.impl_) {
|
|
||||||
impl_.reset(other.impl_->Clone());
|
|
||||||
} else {
|
|
||||||
impl_.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator++() {
|
void operator++() {
|
||||||
CHECK(impl_ != nullptr);
|
CHECK(impl_ != nullptr);
|
||||||
++(*impl_);
|
++(*impl_);
|
||||||
@ -332,7 +323,7 @@ class BatchIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<BatchIteratorImpl<T>> impl_;
|
std::shared_ptr<BatchIteratorImpl<T>> impl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|||||||
@ -43,9 +43,6 @@ class SimpleBatchIteratorImpl : public BatchIteratorImpl<T> {
|
|||||||
}
|
}
|
||||||
void operator++() override { page_ = nullptr; }
|
void operator++() override { page_ = nullptr; }
|
||||||
bool AtEnd() const override { return page_ == nullptr; }
|
bool AtEnd() const override { return page_ == nullptr; }
|
||||||
SimpleBatchIteratorImpl* Clone() override {
|
|
||||||
return new SimpleBatchIteratorImpl(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* page_{nullptr};
|
T* page_{nullptr};
|
||||||
|
|||||||
@ -31,9 +31,6 @@ class SparseBatchIteratorImpl : public BatchIteratorImpl<T> {
|
|||||||
const T& operator*() const override { return source_->Value(); }
|
const T& operator*() const override { return source_->Value(); }
|
||||||
void operator++() override { at_end_ = !source_->Next(); }
|
void operator++() override { at_end_ = !source_->Next(); }
|
||||||
bool AtEnd() const override { return at_end_; }
|
bool AtEnd() const override { return at_end_; }
|
||||||
SparseBatchIteratorImpl* Clone() override {
|
|
||||||
return new SparseBatchIteratorImpl(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SparsePageSource<T>* source_{nullptr};
|
SparsePageSource<T>* source_{nullptr};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user