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

Method mint

src/storage/src/source/reclock.rs:118–169  ·  view source on GitHub ↗
(
        &mut self,
        binding_ts: IntoTime,
        mut new_into_upper: Antichain<IntoTime>,
        new_from_upper: AntichainRef<'_, FromTime>,
    )

Source from the content-addressed store, hash-verified

116 }
117
118 pub async fn mint(
119 &mut self,
120 binding_ts: IntoTime,
121 mut new_into_upper: Antichain<IntoTime>,
122 new_from_upper: AntichainRef<'_, FromTime>,
123 ) -> ReclockBatch<FromTime, IntoTime> {
124 assert!(!new_into_upper.less_equal(&binding_ts));
125 // The updates to the remap trace that occured during minting.
126 let mut batch = ReclockBatch {
127 updates: vec![],
128 upper: self.upper.clone(),
129 };
130
131 while *self.upper == [IntoTime::minimum()]
132 || (PartialOrder::less_equal(&self.source_upper.frontier(), &new_from_upper)
133 && PartialOrder::less_than(&self.upper, &new_into_upper)
134 && self.upper.less_equal(&binding_ts))
135 {
136 // If source is closed, close remap shard as well.
137 if new_from_upper.is_empty() {
138 new_into_upper = Antichain::new();
139 }
140
141 // If this is the first binding we mint then we will mint it at the minimum target
142 // timestamp. The first source upper is always the upper of the snapshot and by mapping
143 // it to the minimum target timestamp we make it so that the final shard never appears
144 // empty at any timestamp.
145 let binding_ts = if *self.upper == [IntoTime::minimum()] {
146 IntoTime::minimum()
147 } else {
148 binding_ts.clone()
149 };
150
151 let mut updates = vec![];
152 for src_ts in self.source_upper.frontier().iter().cloned() {
153 updates.push((src_ts, binding_ts.clone(), Diff::MINUS_ONE));
154 }
155 for src_ts in new_from_upper.iter().cloned() {
156 updates.push((src_ts, binding_ts.clone(), Diff::ONE));
157 }
158 consolidation::consolidate_updates(&mut updates);
159
160 let new_batch = match self.append_batch(updates, &new_into_upper).await {
161 Ok(trace_batch) => trace_batch,
162 Err(UpperMismatch { current, .. }) => self.sync(current.borrow()).await,
163 };
164 batch.updates.extend(new_batch.updates);
165 batch.upper = new_batch.upper;
166 }
167
168 batch
169 }
170
171 /// Appends the provided updates to the remap collection at the next available minting
172 /// IntoTime and updates this operator's in-memory state accordingly.

Callers 6

remap_operatorFunction · 0.45
make_test_operatorFunction · 0.45
test_basic_usageFunction · 0.45
test_compactionFunction · 0.45
test_concurrencyFunction · 0.45
test_since_holdFunction · 0.45

Calls 10

cloneMethod · 0.45
frontierMethod · 0.45
less_equalMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
append_batchMethod · 0.45
syncMethod · 0.45
borrowMethod · 0.45
extendMethod · 0.45

Tested by 4

test_basic_usageFunction · 0.36
test_compactionFunction · 0.36
test_concurrencyFunction · 0.36
test_since_holdFunction · 0.36