Encode a blocked range of items with Avro array block framing. `write_item` must take `(out, index)` to maintain the "out-first" convention.
(
out: &mut W,
start: usize,
end: usize,
mut write_item: F,
)
| 1983 | /// |
| 1984 | /// `write_item` must take `(out, index)` to maintain the "out-first" convention. |
| 1985 | fn encode_blocked_range<W: Write + ?Sized, F>( |
| 1986 | out: &mut W, |
| 1987 | start: usize, |
| 1988 | end: usize, |
| 1989 | mut write_item: F, |
| 1990 | ) -> Result<(), AvroError> |
| 1991 | where |
| 1992 | F: FnMut(&mut W, usize) -> Result<(), AvroError>, |
| 1993 | { |
| 1994 | let len = end.saturating_sub(start); |
| 1995 | if len == 0 { |
| 1996 | // Zero-length terminator per Avro spec. |
| 1997 | write_long(out, 0)?; |
| 1998 | return Ok(()); |
| 1999 | } |
| 2000 | // Emit a single positive block for performance, then the end marker. |
| 2001 | write_long(out, len as i64)?; |
| 2002 | for row in start..end { |
| 2003 | write_item(out, row)?; |
| 2004 | } |
| 2005 | write_long(out, 0)?; |
| 2006 | Ok(()) |
| 2007 | } |
| 2008 | |
| 2009 | struct ListEncoder<'a, O: OffsetSizeTrait> { |
| 2010 | list: &'a GenericListArray<O>, |
no test coverage detected