pub fn merge(&mut self, other: &mut Self) -> Result<(), TsmError> {
        if self.name != other.name {
            return Err(TsmError {
                description: format!(
                    "cannot merge measurement {:?} into {:?}",
                    self.name, other.name
                ),
            });
        }
        self.tag_columns.append(&mut other.tag_columns);
        self.field_columns.append(&mut other.field_columns);

        for (other_tagset, other_field_key_blocks) in &mut other.tag_set_fields_blocks {
            let field_key_blocks = self
                .tag_set_fields_blocks
                .entry(other_tagset.clone())
                .or_default();

            for (other_field_key, other_blocks) in other_field_key_blocks.iter_mut() {
                match field_key_blocks.get_mut(other_field_key) {
                    Some(blocks) => {
                        assert!(
                            !other_blocks.is_empty(),
                            "tried to merge field with no blocks"
                        );

                        assert!(
                            !blocks.is_empty(),
                            "MeasurementTable has field with no blocks"
                        );

                        // Invariant: blocks are already sorted by time range.
                        // Self's blocks do not overlap each other.
                        // other's blocks do not overlap each other.
                        //
                        // It is possible that blocks for the same tagset and
                        // field in self overlap corresponding blocks in `other`

                        // happy path - all of other's blocks are after ours
                        if other_blocks[0].min_time > blocks[blocks.len() - 1].max_time {
                            blocks.extend_from_slice(other_blocks);
                            break;
                        }

                        // less happy path
                        blocks.extend_from_slice(other_blocks);
                        blocks.sort_by(|a, b| a.min_time.cmp(&b.min_time))
                    }
                    None => {
                        field_key_blocks.insert(other_field_key.clone(), other_blocks.clone());
                    }
                }
            }
        }
        Ok(())
    }
/// Merge another `MeasurementTable` into this one.
///
/// `other` must be associated with the same measurement, otherwise an error
/// will be returned.
///
/// Because measurement table data can originate from multiple sources (TSM
/// files) it is possible that blocks for the same tagset and field will
/// overlap with each other. It is the callers responsibility to handle
/// merging this data when decoding those blocks.
Merge another `MeasurementTable` into this one.
`other` must be associated with the same measurement, otherwise an error
will be returned.

Because measurement table data can originate from multiple sources (TSM
files) it is possible that blocks for the same tagset and field will
overlap with each other. It is the callers responsibility to handle
merging this data when decoding those blocks.
Merge another ` MeasurementTable ` into this one . ` other ` must be associated with the same measurement otherwise an error will be returned . Because measurement table data can originate from multiple sources ( TSM files ) it is possible that blocks for the same tagset and field will overlap with each other . It is the callers responsibility to handle merging this data when decoding those blocks .
pub fn merge(&mut self, other: &mut Self) -> Result<(), TsmError> {
        if self.name != other.name {
            return Err(TsmError {
                description: format!(
                    "cannot merge measurement {:?} into {:?}",
                    self.name, other.name
                ),
            });
        }
        self.tag_columns.append(&mut other.tag_columns);
        self.field_columns.append(&mut other.field_columns);
        for (other_tagset, other_field_key_blocks) in &mut other.tag_set_fields_blocks {
            let field_key_blocks = self
                .tag_set_fields_blocks
                .entry(other_tagset.clone())
                .or_default();
            for (other_field_key, other_blocks) in other_field_key_blocks.iter_mut() {
                match field_key_blocks.get_mut(other_field_key) {
                    Some(blocks) => {
                        assert!(
                            !other_blocks.is_empty(),
                            "tried to merge field with no blocks"
                        );
                        assert!(
                            !blocks.is_empty(),
                            "MeasurementTable has field with no blocks"
                        );
                        // Invariant: blocks are already sorted by time range.
                        // Self's blocks do not overlap each other.
                        // other's blocks do not overlap each other.
                        //
                        // It is possible that blocks for the same tagset and
                        // field in self overlap corresponding blocks in `other`
                        // happy path - all of other's blocks are after ours
                        if other_blocks[0].min_time > blocks[blocks.len() - 1].max_time {
                            blocks.extend_from_slice(other_blocks);
                            break;
                        }
                        // less happy path
                        blocks.extend_from_slice(other_blocks);
                        blocks.sort_by(|a, b| a.min_time.cmp(&b.min_time))
                    }
                    None => {
                        field_key_blocks.insert(other_field_key.clone(), other_blocks.clone());
                    }
                }
            }
        }
        Ok(())
    }
pub fn merge ( & mut self , other : & mut Self ) -> Result < ( ) , TsmError > { if self . name != other . name { return Err ( TsmError { description : format ! ( " " self name other name ) , } ) ; } self . tag_columns . append ( & mut other . tag_columns ) ; self . field_columns . append ( & mut other . field_columns ) ; for ( other_tagset , other_field_key_blocks ) in & mut other . tag_set_fields_blocks { let field_key_blocks = self . tag_set_fields_blocks . entry ( other_tagset . clone ( ) ) . or_default ( ) ; for ( other_field_key , other_blocks ) in other_field_key_blocks . iter_mut ( ) { match field_key_blocks . get_mut ( other_field_key ) { Some ( blocks ) => { assert ! ( other_blocks is_empty ( ) " " ) ; assert ! ( blocks is_empty ( ) " " ) ; // Invariant: blocks are already sorted by time range. // Self's blocks do not overlap each other. // other's blocks do not overlap each other. // // It is possible that blocks for the same tagset and // field in self overlap corresponding blocks in `other` // happy path - all of other's blocks are after ours if other_blocks [ 0 ] . min_time > blocks [ blocks . len ( ) - 1 ] . max_time { blocks . extend_from_slice ( other_blocks ) ; break ; } // less happy path blocks . extend_from_slice ( other_blocks ) ; blocks . sort_by ( | a , b | a . min_time . cmp ( & b . min_time ) ) } None => { field_key_blocks . insert ( other_field_key . clone ( ) , other_blocks . clone ( ) ) ; } } } } Ok ( ( ) ) }
Merge another `MeasurementTable` into this one.
Merge another ` MeasurementTable ` into this one .
&mut self
other
&mut Self
&mut self
other
&mut Self