CTTY commented on code in PR #1769: URL: https://github.com/apache/iceberg-rust/pull/1769#discussion_r2453977869
########## crates/iceberg/src/writer/partitioning/unpartitioned_writer.rs: ########## @@ -0,0 +1,443 @@ +// 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 provides the `UnpartitionedWriter` implementation. + +use std::marker::PhantomData; + +use crate::Result; +use crate::spec::PartitionKey; +use crate::writer::partitioning::PartitioningWriter; +use crate::writer::{DefaultInput, DefaultOutput, IcebergWriter, IcebergWriterBuilder}; + +/// A writer that adapts `IcebergWriterBuilder` to the `PartitioningWriter` interface +/// for non-partitioned tables. +/// +/// This writer ignores partition keys and writes all data to a single underlying writer. +/// It lazily creates the writer on the first write operation. +/// +/// # Type Parameters +/// +/// * `B` - The inner writer builder type +/// * `I` - Input type (defaults to `RecordBatch`) +/// * `O` - Output collection type (defaults to `Vec<DataFile>`) +pub struct UnpartitionedWriter<B, I = DefaultInput, O = DefaultOutput> +where + B: IcebergWriterBuilder<I, O>, + O: IntoIterator + FromIterator<<O as IntoIterator>::Item>, + <O as IntoIterator>::Item: Clone, +{ + inner_builder: B, + writer: Option<B::R>, + output: Vec<<O as IntoIterator>::Item>, + _phantom: PhantomData<I>, +} + +impl<B, I, O> UnpartitionedWriter<B, I, O> +where + B: IcebergWriterBuilder<I, O>, + I: Send + 'static, + O: IntoIterator + FromIterator<<O as IntoIterator>::Item>, + <O as IntoIterator>::Item: Send + Clone, +{ + /// Create a new `UnpartitionedWriter`. + pub fn new(inner_builder: B) -> Self { + Self { + inner_builder, + writer: None, + output: Vec::new(), + _phantom: PhantomData, + } + } +} + +#[async_trait::async_trait] +impl<B, I, O> PartitioningWriter<I, O> for UnpartitionedWriter<B, I, O> Review Comment: I've changed UnpartitionedWriter to just be a wrapper of IcebergWriter -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
