fn decompress_block(
    block: &mut Vec<u8>,
    decompress: &mut Vec<u8>,
    compression: Option<Compression>,
) -> Result<bool> {
    match compression {
        None => {
            std::mem::swap(block, decompress);
            Ok(true)
        }
        #[cfg(feature = "io_avro_compression")]
        Some(Compression::Deflate) => {
            decompress.clear();
            let mut decoder = libflate::deflate::Decoder::new(&block[..]);
            decoder.read_to_end(decompress)?;
            Ok(false)
        }
        #[cfg(feature = "io_avro_compression")]
        Some(Compression::Snappy) => {
            let len = snap::raw::decompress_len(&block[..block.len() - 4])
                .map_err(|_| ArrowError::ExternalFormat("Failed to decompress snap".to_string()))?;
            decompress.clear();
            decompress.resize(len, 0);
            snap::raw::Decoder::new()
                .decompress(&block[..block.len() - 4], decompress)
                .map_err(|_| ArrowError::ExternalFormat("Failed to decompress snap".to_string()))?;
            Ok(false)
        }
        #[cfg(not(feature = "io_avro_compression"))]
        Some(Compression::Deflate) => Err(ArrowError::Other(
            "The avro file is deflate-encoded but feature 'io_avro_compression' is not active."
                .to_string(),
        )),
        #[cfg(not(feature = "io_avro_compression"))]
        Some(Compression::Snappy) => Err(ArrowError::Other(
            "The avro file is snappy-encoded but feature 'io_avro_compression' is not active."
                .to_string(),
        )),
    }
}
/// Decompresses an avro block.
/// Returns whether the buffers where swapped.
Decompresses an avro block.
Returns whether the buffers where swapped.
Decompresses an avro block . Returns whether the buffers where swapped .
fn decompress_block(
    block: &mut Vec<u8>,
    decompress: &mut Vec<u8>,
    compression: Option<Compression>,
) -> Result<bool> {
    match compression {
        None => {
            std::mem::swap(block, decompress);
            Ok(true)
        }
        #[cfg(feature = "io_avro_compression")]
        Some(Compression::Deflate) => {
            decompress.clear();
            let mut decoder = libflate::deflate::Decoder::new(&block[..]);
            decoder.read_to_end(decompress)?;
            Ok(false)
        }
        #[cfg(feature = "io_avro_compression")]
        Some(Compression::Snappy) => {
            let len = snap::raw::decompress_len(&block[..block.len() - 4])
                .map_err(|_| ArrowError::ExternalFormat("Failed to decompress snap".to_string()))?;
            decompress.clear();
            decompress.resize(len, 0);
            snap::raw::Decoder::new()
                .decompress(&block[..block.len() - 4], decompress)
                .map_err(|_| ArrowError::ExternalFormat("Failed to decompress snap".to_string()))?;
            Ok(false)
        }
        #[cfg(not(feature = "io_avro_compression"))]
        Some(Compression::Deflate) => Err(ArrowError::Other(
            "The avro file is deflate-encoded but feature 'io_avro_compression' is not active."
                .to_string(),
        )),
        #[cfg(not(feature = "io_avro_compression"))]
        Some(Compression::Snappy) => Err(ArrowError::Other(
            "The avro file is snappy-encoded but feature 'io_avro_compression' is not active."
                .to_string(),
        )),
    }
}
fn decompress_block ( block : & mut Vec < u8 > , decompress : & mut Vec < u8 > , compression : Option < Compression > , ) -> Result < bool > { match compression { None => { std :: mem :: swap ( block , decompress ) ; Ok ( true ) } # [ cfg ( feature " " ) ] Some ( Compression :: Deflate ) => { decompress . clear ( ) ; let mut decoder = libflate :: deflate :: Decoder :: new ( & block [ .. ] ) ; decoder . read_to_end ( decompress ) ? ; Ok ( false ) } # [ cfg ( feature " " ) ] Some ( Compression :: Snappy ) => { let len = snap :: raw :: decompress_len ( & block [ .. block . len ( ) - 4 ] ) . map_err ( | _ | ArrowError :: ExternalFormat ( " " . to_string ( ) ) ) ? ; decompress . clear ( ) ; decompress . resize ( len , 0 ) ; snap :: raw :: Decoder :: new ( ) . decompress ( & block [ .. block . len ( ) - 4 ] , decompress ) . map_err ( | _ | ArrowError :: ExternalFormat ( " " . to_string ( ) ) ) ? ; Ok ( false ) } # [ cfg ( not ( feature " " ) ) ] Some ( Compression :: Deflate ) => Err ( ArrowError :: Other ( " " . to_string ( ) , ) ) , # [ cfg ( not ( feature " " ) ) ] Some ( Compression :: Snappy ) => Err ( ArrowError :: Other ( " " . to_string ( ) , ) ) , } }
Decompresses an avro block.
Decompresses an avro block .
block
&mut Vec<u8>
decompress
&mut Vec<u8>
compression
Option<Compression>
block
&mut Vec<u8>
decompress
&mut Vec<u8>
compression
Option<Compression>