wgtmac commented on code in PR #160: URL: https://github.com/apache/iceberg-cpp/pull/160#discussion_r2256026893
########## src/iceberg/file_writer.h: ########## @@ -0,0 +1,86 @@ +/* + * 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. + */ + +#pragma once + +/// \file iceberg/file_writer.h +/// Writer interface for file formats like Parquet, Avro and ORC. + +#include <functional> +#include <memory> +#include <optional> + +#include "iceberg/arrow_c_data.h" +#include "iceberg/file_format.h" +#include "iceberg/result.h" +#include "iceberg/type_fwd.h" + +namespace iceberg { + +/// \brief Options for creating a writer. +struct ICEBERG_EXPORT WriterOptions { + /// \brief The path to the file to write. + std::string path; + /// \brief The schema of the data to write. + ArrowSchema schema; + /// \brief FileIO instance to open the file. Writer implementations should down cast it + /// to the specific FileIO implementation. By default, the `iceberg-bundle` library uses + /// `ArrowFileSystemFileIO` as the default implementation. + std::shared_ptr<class FileIO> io; + /// \brief Format-specific or implementation-specific properties. + std::unordered_map<std::string, std::string> properties; +}; + +/// \brief Base writer class to write data from different file formats. +class ICEBERG_EXPORT Writer { + public: + virtual ~Writer() = default; + Writer() = default; + Writer(const Writer&) = delete; + Writer& operator=(const Writer&) = delete; + + /// \brief Open the writer. + virtual Status Open(const struct WriterOptions& options) = 0; + + /// \brief Close the writer. + virtual Status Close() = 0; + + /// \brief Write arrow data to the file. + /// + /// \return Status of write results. + virtual Status Write(const ArrowArray& data) = 0; Review Comment: ```suggestion virtual Status Write(ArrowArray data) = 0; ``` Usually array data is moved to the callee. -- 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]
