fn read_chunks(
        &self,
        blob_id: &str,
        blob_offset: u64,
        blob_size: usize,
        cki_set: &[Arc<dyn RafsChunkInfo>],
    ) -> Result<Vec<Vec<u8>>> {
        let mut c_buf = alloc_buf(blob_size);
        let mut chunks: Vec<Vec<u8>> = Vec::new();
        // TODO: Currently, request length to backend may span a whole chunk,
        // Do we need to split it into smaller pieces like 128K or 256K?
        let nr_read = self
            .backend()
            .read(blob_id, c_buf.as_mut_slice(), blob_offset)?;

        if nr_read != blob_size {
            return Err(eio!(format!(
                "request for {} bytes but got {} bytes",
                blob_size, nr_read
            )));
        }

        for cki in cki_set {
            // TODO: Also check if adjacent here?
            let offset_merged = (cki.compress_offset() - blob_offset) as usize;
            let size_merged = cki.compress_size() as usize;
            let mut chunk = alloc_buf(cki.decompress_size() as usize);
            self.process_raw_chunk(
                cki.as_ref(),
                &c_buf[offset_merged..(offset_merged + size_merged)],
                &mut chunk,
            )?;
            chunks.push(chunk);
        }

        Ok(chunks)
    }
/// Read multiple complete chunks from backend in batch. Caller must ensure that
/// range [`blob_offset`..`blob_offset` + `blob_size`] exactly covers more than one
/// chunks and `cki_set` can correctly describe how to extract chunk from batched buffer.
/// Afterwards, several chunks are returned, caller does not have to decompress them.
Read multiple complete chunks from backend in batch.
Read multiple complete chunks from backend in batch .
fn read_chunks(
        &self,
        blob_id: &str,
        blob_offset: u64,
        blob_size: usize,
        cki_set: &[Arc<dyn RafsChunkInfo>],
    ) -> Result<Vec<Vec<u8>>> {
        let mut c_buf = alloc_buf(blob_size);
        let mut chunks: Vec<Vec<u8>> = Vec::new();
        // TODO: Currently, request length to backend may span a whole chunk,
        // Do we need to split it into smaller pieces like 128K or 256K?
        let nr_read = self
            .backend()
            .read(blob_id, c_buf.as_mut_slice(), blob_offset)?;
        if nr_read != blob_size {
            return Err(eio!(format!(
                "request for {} bytes but got {} bytes",
                blob_size, nr_read
            )));
        }
        for cki in cki_set {
            // TODO: Also check if adjacent here?
            let offset_merged = (cki.compress_offset() - blob_offset) as usize;
            let size_merged = cki.compress_size() as usize;
            let mut chunk = alloc_buf(cki.decompress_size() as usize);
            self.process_raw_chunk(
                cki.as_ref(),
                &c_buf[offset_merged..(offset_merged + size_merged)],
                &mut chunk,
            )?;
            chunks.push(chunk);
        }
        Ok(chunks)
    }
fn read_chunks ( & self , blob_id : & str , blob_offset : u64 , blob_size : usize , cki_set : & [ Arc < dyn RafsChunkInfo > ] , ) -> Result < Vec < Vec < u8 > > > { let mut c_buf = alloc_buf ( blob_size ) ; let mut chunks : Vec < Vec < u8 > > = Vec :: new ( ) ; // TODO: Currently, request length to backend may span a whole chunk, // Do we need to split it into smaller pieces like 128K or 256K? let nr_read = self . backend ( ) . read ( blob_id , c_buf . as_mut_slice ( ) , blob_offset ) ? ; if nr_read != blob_size { return Err ( eio ! ( format ( " " blob_size nr_read ) ) ) ; } for cki in cki_set { // TODO: Also check if adjacent here? let offset_merged = ( cki . compress_offset ( ) - blob_offset ) as usize ; let size_merged = cki . compress_size ( ) as usize ; let mut chunk = alloc_buf ( cki . decompress_size ( ) as usize ) ; self . process_raw_chunk ( cki . as_ref ( ) , & c_buf [ offset_merged .. ( offset_merged + size_merged ) ] , & mut chunk , ) ? ; chunks . push ( chunk ) ; } Ok ( chunks ) }
Read multiple complete chunks from backend in batch.
Read multiple complete chunks from backend in batch .
&self
blob_id
&str
blob_offset
u64
blob_size
usize
cki_set
&[Arc<dyn RafsChunkInfo>]
&self
blob_id
&str
blob_offset
u64
blob_size
usize
cki_set
&[Arc<dyn RafsChunkInfo>]