// Read a random amount of data at a random offset from a random blob
Read a random amount of data at a random offset from a random blob
Read a random amount of data at a random offset from a random blob
async fn read_from_blob(&mut self) -> Result<(), Status> {
        // Decide how many blobs to create new handles for
        let blob_list = self.root_dir.entries().await?;
        if blob_list.is_empty() {
            // No blobs to read!
            return Ok(());
        }
        // Choose a random blob and open a handle to it
        let blob = blob_list.choose(&mut self.rng).unwrap();
        let file = self.root_dir.open_file(blob, OPEN_RIGHT_READABLE).await?;
        debug!("Reading from {}", blob);
        let data_size_bytes = file.uncompressed_size().await?;
        if data_size_bytes == 0 {
            // Nothing to read, blob is empty!
            return Ok(());
        }
        // Choose an offset
        let offset = self.rng.gen_range(0, data_size_bytes - 1);
        // Determine the length of this read
        let end_pos = self.rng.gen_range(offset, data_size_bytes);
        assert!(end_pos >= offset);
        let length = end_pos - offset;
        // Read the data from the handle and verify it
        file.seek(SeekOrigin::Start, offset).await?;
        let actual_data_bytes = file.read_num_bytes(length).await?;
        assert_eq!(actual_data_bytes.len(), length as usize);
        debug!("Read {} bytes from {}", length, blob);
        Ok(())
    }
async fn read_from_blob ( & mut self ) -> Result < ( ) , Status > { // Decide how many blobs to create new handles for let blob_list = self . root_dir . entries ( ) . await ? ; if blob_list . is_empty ( ) { // No blobs to read! return Ok ( ( ) ) ; } // Choose a random blob and open a handle to it let blob = blob_list . choose ( & mut self . rng ) . unwrap ( ) ; let file = self . root_dir . open_file ( blob , OPEN_RIGHT_READABLE ) . await ? ; debug ! ( " " blob ) ; let data_size_bytes = file . uncompressed_size ( ) . await ? ; if data_size_bytes == 0 { // Nothing to read, blob is empty! return Ok ( ( ) ) ; } // Choose an offset let offset = self . rng . gen_range ( 0 , data_size_bytes - 1 ) ; // Determine the length of this read let end_pos = self . rng . gen_range ( offset , data_size_bytes ) ; assert ! ( end_pos offset ) ; let length = end_pos - offset ; // Read the data from the handle and verify it file . seek ( SeekOrigin :: Start , offset ) . await ? ; let actual_data_bytes = file . read_num_bytes ( length ) . await ? ; assert_eq ! ( actual_data_bytes len ( ) length as usize ) ; debug ! ( " " length blob ) ; Ok ( ( ) ) }
Read a random amount of data at a random offset from a random blob
Read a random amount of data at a random offset from a random blob
&mut self