1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright The Lance Authors
use async_trait::async_trait;
use lance_table::format::Fragment;
use crate::Result;
/// Progress of writing a [Fragment].
///
/// When start writing a [`Fragment`], WriteProgress::begin() will be called before
/// writing any data.
///
/// When stop writing a [`Fragment`], WriteProgress::complete() will be called after.
///
/// This might be called concurrently when writing multiple [`Fragment`]s. Therefore,
/// the methods require non-exclusive access to `self`.
///
/// This is an experimental API and may change in the future.
#[async_trait]
pub trait WriteFragmentProgress: std::fmt::Debug + Sync + Send {
/// Indicate the beginning of writing a [Fragment], with the in-flight multipart ID.
async fn begin(&self, fragment: &Fragment) -> Result<()>;
/// Complete writing a [Fragment].
async fn complete(&self, fragment: &Fragment) -> Result<()>;
}
/// By default, Progress tracker is Noop.
#[derive(Debug, Clone, Default)]
pub struct NoopFragmentWriteProgress {}
impl NoopFragmentWriteProgress {
pub fn new() -> Self {
Self {}
}
}
#[async_trait]
impl WriteFragmentProgress for NoopFragmentWriteProgress {
#[inline]
async fn begin(&self, _fragment: &Fragment) -> Result<()> {
Ok(())
}
#[inline]
async fn complete(&self, _fragment: &Fragment) -> Result<()> {
Ok(())
}
}