Fokko commented on code in PR #53:
URL: https://github.com/apache/iceberg-rust/pull/53#discussion_r1326885361


##########
crates/iceberg/src/io.rs:
##########
@@ -0,0 +1,426 @@
+// 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.
+
+//! File io implementation.
+//!
+//! File io is built on top of 
[`opendal`](https://docs.rs/opendal/latest/opendal/index.html), which already 
provided an abstraction over all kinds of storage.
+//!
+//! # How to build `FileIO`
+//!
+//! We provided a `FileIOBuilder` to build `FileIO` from scratch. For example:
+//! ```rust
+//! use iceberg::io::{FileIOBuilder, S3_ARGS_BUCKET, S3_ARGS_REGION};
+//!
+//! let file_io = FileIOBuilder::new("s3")
+//!     .with_arg(S3_ARGS_BUCKET, "test_bucket")
+//!     .with_arg(S3_ARGS_REGION, "us-east-1")
+//!     .build()
+//!     .unwrap();
+//! ```
+//!
+//! We also provided a convenient method to build `FileIO` from url:
+//!
+//! ```rust
+//! use iceberg::io::{FileIO, S3_ARGS_REGION};
+//! let file_io = FileIO::build_from_url("s3a://test_bucket/warehouse")
+//!     .unwrap()
+//!     .with_arg(S3_ARGS_REGION, "us-east-1")
+//!     .build()
+//!     .unwrap();
+//! ```
+//!
+//! # How to use `FileIO`
+//!
+//! Currently `FileIO` provides simple methods for file operations:
+//!
+//! - `delete`: Delete file.
+//! - `is_exist`: Check if file exists.
+//! - `new_input`: Create input file for reading.
+//! - `new_output`: Create output file for writing.
+
+use std::{collections::HashMap, sync::Arc};
+
+use crate::{error::Result, Error, ErrorKind};
+use futures::{AsyncRead, AsyncSeek, AsyncWrite};
+use opendal::{Operator, Scheme};
+use url::Url;
+
+/// Following are arguments for s3 operator.
+/// s3 root
+pub const S3_ARGS_ROOT: &str = "root";
+/// s3 bucket
+pub const S3_ARGS_BUCKET: &str = "bucket";
+/// s3 endpoint
+pub const S3_ARGS_ENDPOINT: &str = "endpoint";
+/// s3 region
+pub const S3_ARGS_REGION: &str = "region";
+/// s3 access key
+pub const S3_ARGS_ACCESS_KEY_ID: &str = "access_key_id";
+/// s3 access secret
+pub const S3_ARGS_ACCESS_KEY: &str = "secret_access_key";

Review Comment:
   > In fact, user can still provide security tokens using the 'with_arg' 
method in 'FileIOBuilder'. These constants are just some examples but doesn't 
prevent anything. I'm not sure if it's a good idea to enumerate all possible 
arguments in iceberg since this approach maybe not scalable. As @Xuanwo said, 
opendal supports 20+ underlying storage and it's best to put them in opendal.
   
   I think opendal is a great implementation, and it will make iceberg-rust 
very flexible, but I do think we should not leak any implementation details to 
the end user. The idea of a FileIO is that it is modular, and it can be swapped 
out with another implementation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to