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

Function write_long

arrow-avro/src/writer/encoder.rs:73–87  ·  view source on GitHub ↗
(out: &mut W, value: i64)

Source from the content-addressed store, hash-verified

71/// Spec: <https://avro.apache.org/docs/1.11.1/specification/#binary-encoding>
72#[inline]
73pub(crate) fn write_long<W: Write + ?Sized>(out: &mut W, value: i64) -> Result<(), AvroError> {
74 let mut zz = ((value << 1) ^ (value >> 63)) as u64;
75 // At most 10 bytes for 64-bit varint
76 let mut buf = [0u8; 10];
77 let mut i = 0;
78 while (zz & !0x7F) != 0 {
79 buf[i] = ((zz & 0x7F) as u8) | 0x80;
80 i += 1;
81 zz >>= 7;
82 }
83 buf[i] = (zz & 0x7F) as u8;
84 i += 1;
85 out.write_all(&buf[..i])
86 .map_err(|e| AvroError::IoError(format!("write long: {e}"), e))
87}
88
89#[inline]
90fn write_int<W: Write + ?Sized>(out: &mut W, value: i32) -> Result<(), AvroError> {

Callers 8

start_streamMethod · 0.85
write_bytesFunction · 0.85
write_ocf_blockMethod · 0.85
write_intFunction · 0.85
write_len_prefixedFunction · 0.85
encodeMethod · 0.85
encode_blocked_rangeFunction · 0.85

Calls 1

write_allMethod · 0.45

Tested by 1