Returns a new iterator for iterating over the range of elements in this dataset. This method may be called multiple times on the same instance, and the resulting iterators will have distinct state. Each iterator will traverse all elements in this dataset from the start. The prefix identifies the sequence of iterators leading up to the newly created iterator.
| 683 | // The prefix identifies the sequence of iterators leading up to the newly |
| 684 | // created iterator. |
| 685 | Status MakeIterator(IteratorContext* ctx, const string& output_prefix, |
| 686 | std::unique_ptr<IteratorBase>* iterator) const { |
| 687 | *iterator = MakeIteratorInternal(output_prefix); |
| 688 | if (const auto& model = ctx->model()) { |
| 689 | const string& prefix = (*iterator)->prefix(); |
| 690 | (*iterator)->SetNode(model->AddNode(MakeNodeFactory(ctx, iterator->get()), |
| 691 | prefix, output_prefix)); |
| 692 | (*iterator)->AddCleanupFunction( |
| 693 | [model, prefix]() { model->RemoveNode(prefix); }); |
| 694 | } |
| 695 | return (*iterator)->Initialize(ctx); |
| 696 | } |
| 697 | |
| 698 | Status MakeIterator(IteratorContext&& ctx, const string& output_prefix, |
| 699 | std::unique_ptr<IteratorBase>* iterator) const { |