Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iterator: typed API for new deserialization framework
This commit finishes the work related to adjusting the iterators module to the new deserialization framework. The previous commit brought RawRowsLendingStream, which can deserialize ColumnIterators. This commit introduces new TypedRowLendingStream, which type-checks once and then deserializes from ColumnIterators into rows. RawRowsLendingStream can be converted to TypedRowLendingStream by calling the `into_typed()` method. Unfortunately, due to the limitations of the Stream trait (no support for lending streams, analogous to lending iterators in case of RawRowsLendingIterator), a Stream cannot be used to deserialize borrowed types (i.e. those that borrow from the frame serialized contents). In order to give users both capabilities: 1) deserializing borrowed types (for efficiency), 2) deserializing using Stream (for convienience), two distinct types are used: TypedRowLendingStream and TypedRowStream. The first supports borrowed types and the second implements Stream. To sum up, instead of `RowIterator` (returning `Row`s) and `TypedRowIterator` (returning instances of the target type) both implementing `Stream`, now we have the following: - `RawRowsLendingStream` - cannot implement `Stream`, because returns `ColumnIterator`s that borrow from it, - provide `type_check()` and `next()` methods that can be used for low-level, manual deserialization (not recommended for ordinary users) - supports deserializing manually borrowed types (such as `&str`). - `TypedRowLendingStream` - created by calling `into_typed::<TargetType>()` on `RawIterator`, - type checks upon creation, - supports deserializing borrowed types (such as `&str`), - does not implement `Stream` in order to support borrowed types, - provides basic Stream-like methods (`next()`, `try_next()`), - `TypedRowStream` - created by calling `into_stream()` on `TypedRowLendingStream`, - implements `Stream` and hence does not support borrowed types. Co-authored-by: Piotr Dulikowski <[email protected]>
- Loading branch information