MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / extend_from_self

Method extend_from_self

src/repr/src/row.rs:517–545  ·  view source on GitHub ↗
(&mut self, other: Self::Borrowed<'_>, range: Range<usize>)

Source from the content-addressed store, hash-verified

515
516 impl<BC: PushIndexAs<u64>> Container for Rows<BC, Vec<u8>> {
517 fn extend_from_self(&mut self, other: Self::Borrowed<'_>, range: Range<usize>) {
518 if !range.is_empty() {
519 // Imported bounds will be relative to this starting offset.
520 let values_len: u64 = self.values.len().try_into().expect("must fit");
521
522 // Push all bytes that we can, all at once.
523 let other_lower = if range.start == 0 {
524 0
525 } else {
526 other.bounds.index_as(range.start - 1)
527 };
528 let other_upper = other.bounds.index_as(range.end - 1);
529 self.values.extend_from_self(
530 other.values,
531 usize::try_from(other_lower).expect("must fit")
532 ..usize::try_from(other_upper).expect("must fit"),
533 );
534
535 // Each bound needs to be shifted by `values_len - other_lower`.
536 if values_len == other_lower {
537 self.bounds.extend_from_self(other.bounds, range);
538 } else {
539 for index in range {
540 let shifted = other.bounds.index_as(index) - other_lower + values_len;
541 self.bounds.push(&shifted)
542 }
543 }
544 }
545 }
546 fn reserve_for<'a, I>(&mut self, selves: I)
547 where
548 Self: 'a,

Callers 2

merge_fromMethod · 0.45
extractMethod · 0.45

Calls 5

expectMethod · 0.80
is_emptyMethod · 0.45
try_intoMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected