MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / write_split_recorded

Method write_split_recorded

atomic-repository/src/repository/insert.rs:3174–3227  ·  view source on GitHub ↗
(
        &self,
        index: &RecordOutcome,
        remainder: &RecordOutcome,
        baseline_view: &str,
        snapshot_view: &str,
        snapshot: Hash,
    )

Source from the content-addressed store, hash-verified

3172 }
3173
3174 pub(super) fn write_split_recorded(
3175 &self,
3176 index: &RecordOutcome,
3177 remainder: &RecordOutcome,
3178 baseline_view: &str,
3179 snapshot_view: &str,
3180 snapshot: Hash,
3181 ) -> Result<(InsertOutcome, InsertOutcome), RepositoryError> {
3182 let mut txn = self
3183 .pristine
3184 .write_txn()
3185 .map_err(|error| RepositoryError::Database(error.to_string()))?;
3186
3187 let index_outcome = write_recorded_in_txn(self, &mut txn, index, baseline_view)?;
3188
3189 let mut private_view = txn
3190 .get_view(snapshot_view)
3191 .map_err(|error| RepositoryError::Database(error.to_string()))?
3192 .ok_or_else(|| RepositoryError::ViewNotFound {
3193 name: snapshot_view.to_string(),
3194 })?;
3195 let snapshot_id = txn
3196 .get_internal(&snapshot)
3197 .map_err(|error| RepositoryError::Database(error.to_string()))?
3198 .ok_or_else(|| RepositoryError::ChangeNotFound {
3199 hash: snapshot.to_base32(),
3200 })?;
3201 txn.del_change(&mut private_view, snapshot_id, &snapshot)
3202 .map_err(|error| RepositoryError::Database(error.to_string()))?
3203 .ok_or_else(|| RepositoryError::ChangeNotInView {
3204 hash: snapshot.to_base32(),
3205 view: snapshot_view.to_string(),
3206 })?;
3207 txn.update_view(&private_view)
3208 .map_err(|error| RepositoryError::Database(error.to_string()))?;
3209 self.realign_tree_projection_in_txn(&mut txn, snapshot_view)?;
3210
3211 // The remainder was assembled against the new durable index, so remove
3212 // the old snapshot from visibility before resolving/applying its contexts.
3213 let mut remainder_outcome =
3214 write_recorded_in_txn(self, &mut txn, remainder, snapshot_view)?;
3215 let private_view = txn
3216 .get_view(snapshot_view)
3217 .map_err(|error| RepositoryError::Database(error.to_string()))?
3218 .ok_or_else(|| RepositoryError::ViewNotFound {
3219 name: snapshot_view.to_string(),
3220 })?;
3221 remainder_outcome.new_state = private_view.state;
3222 remainder_outcome.sequence = private_view.change_count;
3223
3224 txn.commit()
3225 .map_err(|error| RepositoryError::Database(error.to_string()))?;
3226 Ok((index_outcome, remainder_outcome))
3227 }
3228
3229 // Cross-View Insert Methods
3230

Callers 1

publish_splitMethod · 0.80

Calls 9

write_recorded_in_txnFunction · 0.85
write_txnMethod · 0.80
del_changeMethod · 0.80
update_viewMethod · 0.80
get_viewMethod · 0.45
get_internalMethod · 0.45
to_base32Method · 0.45
commitMethod · 0.45

Tested by

no test coverage detected