Implement iterator facade for external sort. #4914
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
iterator_facade
class (in tiledb/common/iterator_facade.h) implements, well, an iterator facade. An iterator must provide a fairly rich set of functions to be fully conformant to the C++20 ranges iterator concepts (and to conform to theLegacyIterator
named requirements). Providing that functionality involves an enormous amount of boilerplate and can have subtle issues (e.g., withconst
, with the required type aliases, etc). Theiterator_facade
class generates all of the boilerplate, based on just a handful of functions that the user has to provide. Use of theiterator_facade
class is based on CRTP. A simple iterator only needs to provide three functions in the simplest case to be able to meet all of the requirements of an iterator. For example, we can define an iterator that wraps up a raw pointer and strides through its data by 10 elements at a time.To do the port, I removed all dependencies on other parts of the
neo-fun
library, primarily by substituting standard library functions, type traits, and concepts for those in theneo-fun
library. I also added some functionality to support assignment to an iterator.I also ported the unit testing from the
neo-fun
repository. I added a significant number of new tests, primarily to verify that an iterator based oniterator_facade
would conform to the expected range and iterator concepts.Note that there are a few tests that return slightly unexpected results (in that they differ from , e.g., what should be an equivalent iterator from
std::vector
). Those should have no impact on our immediate intended usage ofiterator_facade
, but at some point, we should address those issuesiterator_category
of some const variants does not appear to be correctoperator[]
seems to return nonsense in one usage mode in unit_iterator_facade.ccThe implementation of
iterator_facade
is ported from the implementation at vector-of-bool/neo-fun@b6c38c8, which I cloned on Mar 21, 2024 to use as the beginning of the port. The downloaded code is licensed under the Boost Software License 1.0 (which essentially the same as the MIT license). Thisiterator_facade
is a modernized approach to Boost.Iterator and is greatly simplified via the use of concepts and other modern C++ features (Boost.Iterator dates from the early 2000s). (One of the authors of Boost.Graph is Jeremy Siek, a former PhD student in my group at Indiana University.)[sc-43633]
TYPE: IMPROVEMENT
DESC: Implement iterator facade for external sort.