fn store_segment_header(
        &mut self,
        last: Header,
        lsn: Lsn,
        max_stable_lsn: Lsn,
    ) {
        debug!("storing lsn {} in beginning of buffer", lsn);
        assert!(self.capacity >= SEG_HEADER_LEN);

        self.stored_max_stable_lsn = max_stable_lsn;

        self.lsn = lsn;

        let header = SegmentHeader { lsn, max_stable_lsn, ok: true };
        let header_bytes: [u8; SEG_HEADER_LEN] = header.into();

        #[allow(unsafe_code)]
        unsafe {
            std::ptr::copy_nonoverlapping(
                header_bytes.as_ptr(),
                self.buf.0,
                SEG_HEADER_LEN,
            );
        }

        // ensure writes to the buffer land after our header.
        let last_salt = salt(last);
        let new_salt = bump_salt(last_salt);
        let bumped = bump_offset(new_salt, SEG_HEADER_LEN);
        self.set_header(bumped);
    }
// This is called upon the initialization of a fresh segment.
// We write a new segment header to the beginning of the buffer
// for assistance during recovery. The caller is responsible
// for ensuring that the IoBuf's capacity has been set properly.
This is called upon the initialization of a fresh segment.
We write a new segment header to the beginning of the buffer
for assistance during recovery. The caller is responsible
for ensuring that the IoBuf's capacity has been set properly.
This is called upon the initialization of a fresh segment . We write a new segment header to the beginning of the buffer for assistance during recovery . The caller is responsible for ensuring that the IoBuf ' s capacity has been set properly .
fn store_segment_header(
        &mut self,
        last: Header,
        lsn: Lsn,
        max_stable_lsn: Lsn,
    ) {
        debug!("storing lsn {} in beginning of buffer", lsn);
        assert!(self.capacity >= SEG_HEADER_LEN);
        self.stored_max_stable_lsn = max_stable_lsn;
        self.lsn = lsn;
        let header = SegmentHeader { lsn, max_stable_lsn, ok: true };
        let header_bytes: [u8; SEG_HEADER_LEN] = header.into();
        #[allow(unsafe_code)]
        unsafe {
            std::ptr::copy_nonoverlapping(
                header_bytes.as_ptr(),
                self.buf.0,
                SEG_HEADER_LEN,
            );
        }
        // ensure writes to the buffer land after our header.
        let last_salt = salt(last);
        let new_salt = bump_salt(last_salt);
        let bumped = bump_offset(new_salt, SEG_HEADER_LEN);
        self.set_header(bumped);
    }
fn store_segment_header ( & mut self , last : Header , lsn : Lsn , max_stable_lsn : Lsn , ) { debug ! ( " " lsn ) ; assert ! ( self capacity SEG_HEADER_LEN ) ; self . stored_max_stable_lsn = max_stable_lsn ; self . lsn = lsn ; let header = SegmentHeader { lsn , max_stable_lsn , ok : true } ; let header_bytes : [ u8 ; SEG_HEADER_LEN ] = header . into ( ) ; # [ allow ( unsafe_code ) ] unsafe { std :: ptr :: copy_nonoverlapping ( header_bytes . as_ptr ( ) , self . buf . 0 , SEG_HEADER_LEN , ) ; } // ensure writes to the buffer land after our header. let last_salt = salt ( last ) ; let new_salt = bump_salt ( last_salt ) ; let bumped = bump_offset ( new_salt , SEG_HEADER_LEN ) ; self . set_header ( bumped ) ; }
This is called upon the initialization of a fresh segment.
This is called upon the initialization of a fresh segment .
&mut self
last
Header
lsn
Lsn
max_stable_lsn
Lsn