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

Method write_split_recorded

atomic-repository/src/repository/insert.rs:3224–3277  ·  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

3222 }
3223
3224 pub(super) fn write_split_recorded(
3225 &self,
3226 index: &RecordOutcome,
3227 remainder: &RecordOutcome,
3228 baseline_view: &str,
3229 snapshot_view: &str,
3230 snapshot: Hash,
3231 ) -> Result<(InsertOutcome, InsertOutcome), RepositoryError> {
3232 let mut txn = self
3233 .pristine
3234 .write_txn()
3235 .map_err(|error| RepositoryError::Database(error.to_string()))?;
3236
3237 let index_outcome = write_recorded_in_txn(self, &mut txn, index, baseline_view)?;
3238
3239 let mut private_view = txn
3240 .get_view(snapshot_view)
3241 .map_err(|error| RepositoryError::Database(error.to_string()))?
3242 .ok_or_else(|| RepositoryError::ViewNotFound {
3243 name: snapshot_view.to_string(),
3244 })?;
3245 let snapshot_id = txn
3246 .get_internal(&snapshot)
3247 .map_err(|error| RepositoryError::Database(error.to_string()))?
3248 .ok_or_else(|| RepositoryError::ChangeNotFound {
3249 hash: snapshot.to_base32(),
3250 })?;
3251 txn.del_change(&mut private_view, snapshot_id, &snapshot)
3252 .map_err(|error| RepositoryError::Database(error.to_string()))?
3253 .ok_or_else(|| RepositoryError::ChangeNotInView {
3254 hash: snapshot.to_base32(),
3255 view: snapshot_view.to_string(),
3256 })?;
3257 txn.update_view(&private_view)
3258 .map_err(|error| RepositoryError::Database(error.to_string()))?;
3259 self.realign_tree_projection_in_txn(&mut txn, snapshot_view)?;
3260
3261 // The remainder was assembled against the new durable index, so remove
3262 // the old snapshot from visibility before resolving/applying its contexts.
3263 let mut remainder_outcome =
3264 write_recorded_in_txn(self, &mut txn, remainder, snapshot_view)?;
3265 let private_view = txn
3266 .get_view(snapshot_view)
3267 .map_err(|error| RepositoryError::Database(error.to_string()))?
3268 .ok_or_else(|| RepositoryError::ViewNotFound {
3269 name: snapshot_view.to_string(),
3270 })?;
3271 remainder_outcome.new_state = private_view.state;
3272 remainder_outcome.sequence = private_view.change_count;
3273
3274 txn.commit()
3275 .map_err(|error| RepositoryError::Database(error.to_string()))?;
3276 Ok((index_outcome, remainder_outcome))
3277 }
3278
3279 // Cross-View Insert Methods
3280

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