MCPcopy Create free account
hub / github.com/apache/arrow-rs / encode_blocked_range

Function encode_blocked_range

arrow-avro/src/writer/encoder.rs:1985–2007  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

1983///
1984/// `write_item` must take `(out, index)` to maintain the "out-first" convention.
1985fn 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>
1991where
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
2009struct ListEncoder<'a, O: OffsetSizeTrait> {
2010 list: &'a GenericListArray<O>,

Callers 3

encode_map_entriesMethod · 0.85
encode_list_rangeMethod · 0.85
encodeMethod · 0.85

Calls 1

write_longFunction · 0.85

Tested by

no test coverage detected