This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new a9104dc  feat: init file writer interface (#168)
a9104dc is described below

commit a9104dc428fbdab4ddbe5e8a8090877132a6ddb7
Author: ZENOTME <[email protected]>
AuthorDate: Thu Jan 25 15:51:36 2024 +0800

    feat: init file writer interface (#168)
    
    * init file writer interface
    
    * refine
    
    ---------
    
    Co-authored-by: ZENOTME <[email protected]>
---
 crates/iceberg/src/lib.rs                    |  2 ++
 crates/iceberg/src/writer/file_writer/mod.rs | 39 +++++++++++++++++++++++
 crates/iceberg/src/{lib.rs => writer/mod.rs} | 46 +++++++++-------------------
 3 files changed, 55 insertions(+), 32 deletions(-)

diff --git a/crates/iceberg/src/lib.rs b/crates/iceberg/src/lib.rs
index 7d652d8..9ceadca 100644
--- a/crates/iceberg/src/lib.rs
+++ b/crates/iceberg/src/lib.rs
@@ -51,3 +51,5 @@ mod scan;
 pub mod expr;
 pub mod transaction;
 pub mod transform;
+
+pub mod writer;
diff --git a/crates/iceberg/src/writer/file_writer/mod.rs 
b/crates/iceberg/src/writer/file_writer/mod.rs
new file mode 100644
index 0000000..c8251fd
--- /dev/null
+++ b/crates/iceberg/src/writer/file_writer/mod.rs
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! This module contains the writer for data file format supported by iceberg: 
parquet, orc.
+
+use super::{CurrentFileStatus, DefaultOutput};
+use crate::Result;
+use arrow_array::RecordBatch;
+use futures::Future;
+
+/// File writer builder trait.
+pub trait FileWriterBuilder<O = DefaultOutput>: Send + Clone + 'static {
+    /// The associated file writer type.
+    type R: FileWriter<O>;
+    /// Build file writer.
+    fn build(self) -> impl Future<Output = Result<Self::R>> + Send;
+}
+
+/// File writer focus on writing record batch to different physical file 
format.(Such as parquet. orc)
+pub trait FileWriter<O = DefaultOutput>: Send + CurrentFileStatus + 'static {
+    /// Write record batch to file.
+    fn write(&mut self, batch: &RecordBatch) -> impl Future<Output = 
Result<()>> + Send;
+    /// Close file writer.
+    fn close(self) -> impl Future<Output = Result<O>> + Send;
+}
diff --git a/crates/iceberg/src/lib.rs b/crates/iceberg/src/writer/mod.rs
similarity index 56%
copy from crates/iceberg/src/lib.rs
copy to crates/iceberg/src/writer/mod.rs
index 7d652d8..ac79d7b 100644
--- a/crates/iceberg/src/lib.rs
+++ b/crates/iceberg/src/writer/mod.rs
@@ -15,39 +15,21 @@
 // specific language governing permissions and limitations
 // under the License.
 
-//! Native Rust implementation of Apache Iceberg
+//! The iceberg writer module.
 
-#![deny(missing_docs)]
+use crate::spec::DataFileBuilder;
 
-#[macro_use]
-extern crate derive_builder;
+pub mod file_writer;
 
-mod error;
-pub use error::Error;
-pub use error::ErrorKind;
-pub use error::Result;
+type DefaultOutput = Vec<DataFileBuilder>;
 
-mod catalog;
-
-pub use catalog::Catalog;
-pub use catalog::Namespace;
-pub use catalog::NamespaceIdent;
-pub use catalog::TableCommit;
-pub use catalog::TableCreation;
-pub use catalog::TableIdent;
-pub use catalog::TableRequirement;
-pub use catalog::TableUpdate;
-
-#[allow(dead_code)]
-pub mod table;
-
-mod avro;
-pub mod io;
-pub mod spec;
-
-mod scan;
-
-#[allow(dead_code)]
-pub mod expr;
-pub mod transaction;
-pub mod transform;
+/// The current file status of iceberg writer. It implement for the writer 
which write a single
+/// file.
+pub trait CurrentFileStatus {
+    /// Get the current file path.
+    fn current_file_path(&self) -> String;
+    /// Get the current file row number.
+    fn current_row_num(&self) -> usize;
+    /// Get the current file written size.
+    fn current_written_size(&self) -> usize;
+}

Reply via email to