MCPcopy Create free account
hub / github.com/apache/paimon-rust / try_commit_once

Method try_commit_once

crates/paimon/src/table/table_commit.rs:350–451  ·  view source on GitHub ↗

Single commit attempt.

(
        &self,
        mut resolved: ResolvedCommit,
        latest_snapshot: &Option<Snapshot>,
    )

Source from the content-addressed store, hash-verified

348
349 /// Single commit attempt.
350 async fn try_commit_once(
351 &self,
352 mut resolved: ResolvedCommit,
353 latest_snapshot: &Option<Snapshot>,
354 ) -> Result<bool> {
355 let new_snapshot_id = latest_snapshot.as_ref().map(|s| s.id() + 1).unwrap_or(1);
356
357 // Row tracking
358 let mut next_row_id: Option<i64> = None;
359 if self.row_tracking_enabled {
360 let first_row_id_start = latest_snapshot
361 .as_ref()
362 .and_then(|s| s.next_row_id())
363 .unwrap_or(0);
364 let (assigned, nrid) = self.assign_row_tracking_meta(
365 new_snapshot_id,
366 first_row_id_start,
367 resolved.entries,
368 );
369 resolved.entries = assigned;
370 next_row_id = Some(nrid);
371 }
372
373 let file_io = self.snapshot_manager.file_io();
374 let manifest_dir = self.snapshot_manager.manifest_dir();
375
376 let unique_id = uuid::Uuid::new_v4();
377 let base_manifest_list_name = format!("manifest-list-{unique_id}-0");
378 let delta_manifest_list_name = format!("manifest-list-{unique_id}-1");
379 let new_manifest_name = format!("manifest-{}-0", uuid::Uuid::new_v4());
380
381 let base_manifest_list_path = format!("{manifest_dir}/{base_manifest_list_name}");
382 let delta_manifest_list_path = format!("{manifest_dir}/{delta_manifest_list_name}");
383 let new_manifest_path = format!("{manifest_dir}/{new_manifest_name}");
384
385 // Write manifest file
386 let new_manifest_file_meta = self
387 .write_manifest_file(
388 file_io,
389 &new_manifest_path,
390 &new_manifest_name,
391 &resolved.entries,
392 )
393 .await?;
394
395 // Write delta manifest list
396 ManifestList::write(
397 file_io,
398 &delta_manifest_list_path,
399 &[new_manifest_file_meta],
400 )
401 .await?;
402
403 // Read existing manifests (base + delta from previous snapshot) and write base manifest list
404 let mut total_record_count: i64 = 0;
405 let existing_manifest_files = if let Some(snap) = latest_snapshot {
406 let base_path = format!("{manifest_dir}/{}", snap.base_manifest_list());
407 let delta_path = format!("{manifest_dir}/{}", snap.delta_manifest_list());

Callers 1

try_commitMethod · 0.80

Calls 15

current_time_millisFunction · 0.85
next_row_idMethod · 0.80
manifest_dirMethod · 0.80
write_manifest_fileMethod · 0.80
total_record_countMethod · 0.80
kindMethod · 0.80
fileMethod · 0.80
index_manifestMethod · 0.80
delta_record_countMethod · 0.80
commit_kindMethod · 0.80
commit_identifierMethod · 0.80

Tested by

no test coverage detected