Skip to content

Commit a437a72

Browse files
author
ZENOTME
committed
remove **WriteResult trait
1 parent a040551 commit a437a72

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

crates/iceberg/src/writer/file_writer/mod.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
//! Iceberg File Writer
1919
20-
use super::{CurrentFileStatus, IcebergWriteResult};
21-
use crate::Result;
20+
use super::CurrentFileStatus;
21+
use crate::{spec::DataFileBuilder, Result};
2222
use arrow_array::RecordBatch;
2323
use arrow_schema::SchemaRef;
2424

@@ -34,18 +34,8 @@ pub trait FileWriterBuilder: Send + Clone + 'static {
3434
/// File writer focus on writing record batch to different physical file format.(Such as parquet. orc)
3535
#[async_trait::async_trait]
3636
pub trait FileWriter: Send + 'static + CurrentFileStatus {
37-
/// The associated file write result type.
38-
type R: FileWriteResult;
3937
/// Write record batch to file.
4038
async fn write(&mut self, batch: &RecordBatch) -> Result<()>;
4139
/// Close file writer.
42-
async fn close(self) -> Result<Vec<Self::R>>;
43-
}
44-
45-
/// File write result.
46-
pub trait FileWriteResult: Send + 'static {
47-
/// The associated iceberg write result type.
48-
type R: IcebergWriteResult;
49-
/// Convert to iceberg write result.
50-
fn to_iceberg_result(self) -> Self::R;
40+
async fn close(self) -> Result<Vec<DataFileBuilder>>;
5141
}

crates/iceberg/src/writer/mod.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
//! iceberg_writer.write(input).await?;
4949
//!
5050
//! let write_result = iceberg_writer.flush().await?;
51+
//!
52+
//! let data_file = write_result.into_iter().map(|builder|builder.build()).collect::<Vec<_>>();
5153
//! ```
5254
//!
5355
//! # Complex Case 2: Create a fanout partition data file writer using parquet file format.
@@ -65,12 +67,11 @@
6567
//! iceberg_writer.write(input).await?;
6668
//!
6769
//! let write_result = iceberg_writer.flush().await?;
70+
//!
71+
//! let data_file = write_result.into_iter().map(|builder|builder.build()).collect::<Vec<_>>();
6872
//! ```
6973
70-
use crate::{
71-
spec::{DataContentType, Struct},
72-
Result,
73-
};
74+
use crate::{spec::DataFileBuilder, Result};
7475
use arrow_array::RecordBatch;
7576
use arrow_schema::SchemaRef;
7677

@@ -90,22 +91,10 @@ pub trait IcebergWriterBuilder<I = DefaultInput>: Send + Clone + 'static {
9091
/// The iceberg writer used to write data to iceberg table.
9192
#[async_trait::async_trait]
9293
pub trait IcebergWriter<I = DefaultInput>: Send + 'static {
93-
/// The associated write result type.
94-
type R: IcebergWriteResult;
9594
/// Write data to iceberg table.
9695
async fn write(&mut self, input: I) -> Result<()>;
9796
/// Flush the writer and return the write result.
98-
async fn flush(&mut self) -> Result<Vec<Self::R>>;
99-
}
100-
101-
/// The write result of iceberg writer.
102-
pub trait IcebergWriteResult: Send + Sync + 'static {
103-
/// Set the content type of the write result.
104-
fn set_content(&mut self, content: DataContentType) -> &mut Self;
105-
/// Set the equality ids of the write result.
106-
fn set_equality_ids(&mut self, equality_ids: Vec<i32>) -> &mut Self;
107-
/// Set the partition of the write result.
108-
fn set_partition(&mut self, partition_value: Struct) -> &mut Self;
97+
async fn flush(&mut self) -> Result<Vec<DataFileBuilder>>;
10998
}
11099

111100
/// The current file status of iceberg writer. It implement for the writer which write a single

0 commit comments

Comments
 (0)