wgtmac commented on code in PR #176: URL: https://github.com/apache/iceberg-cpp/pull/176#discussion_r2289776405
########## src/iceberg/manifest_adapter.h: ########## @@ -0,0 +1,66 @@ +/* + * 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/metadata_adapter.h +/// Base class of adapter for v1v2v3v4 metadata. + +#include "iceberg/arrow_c_data.h" +#include "iceberg/manifest_entry.h" +#include "iceberg/manifest_list.h" +#include "iceberg/result.h" + +namespace iceberg { + +// \brief Implemented by different versions with different schemas to +// append a list of `ManifestEntry`s to an `ArrowArray`. +class ManifestEntryAdapter { Review Comment: ```suggestion class ICEBERG_EXPORT ManifestEntryAdapter { ``` ########## src/iceberg/manifest_writer.h: ########## @@ -35,14 +35,57 @@ namespace iceberg { class ICEBERG_EXPORT ManifestWriter { public: virtual ~ManifestWriter() = default; - virtual Status WriteManifestEntries( - const std::vector<ManifestEntry>& entries) const = 0; + + /// \brief Write manifest entry to file. + /// \param entry Manifest entry to write. + /// \return Status::OK() if entry was written successfully + virtual Status Add(const ManifestEntry& entry) = 0; Review Comment: I don't think we will mock these writers. The constructor only sets the pointers of adaptor and writer, then does nothing. All the logics are in the adaptor code. If we keep `Add` as a virtual function, adding a single `ManifestEntry` may require two virtual functions calls, one from here and one from the adapter. The cost may be non-trivial if we call them repeatedly for many times. So I'm inclined to change classes here to remove virtual functions. ########## src/iceberg/manifest_adapter.h: ########## @@ -0,0 +1,66 @@ +/* + * 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/metadata_adapter.h +/// Base class of adapter for v1v2v3v4 metadata. + +#include "iceberg/arrow_c_data.h" +#include "iceberg/manifest_entry.h" +#include "iceberg/manifest_list.h" +#include "iceberg/result.h" + +namespace iceberg { + +// \brief Implemented by different versions with different schemas to +// append a list of `ManifestEntry`s to an `ArrowArray`. +class ManifestEntryAdapter { + public: + ManifestEntryAdapter() = default; + virtual ~ManifestEntryAdapter() = default; + + virtual Status StartAppending() = 0; + virtual Status Append(const ManifestEntry& entry) = 0; + virtual Result<ArrowArray> FinishAppending() = 0; + int64_t size() const { return size_; } + + protected: + ArrowArray array_; // array to append `ManifestEntry`s + int64_t size_ = 0; +}; + +// \brief Implemented by different versions with different schemas to +// append a list of `ManifestFile`s to an `ArrowArray`. +class ManifestFileAdapter { Review Comment: ```suggestion class ICEBERG_EXPORT ManifestFileAdapter { ``` ########## src/iceberg/manifest_adapter.h: ########## @@ -0,0 +1,66 @@ +/* + * 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/metadata_adapter.h +/// Base class of adapter for v1v2v3v4 metadata. + +#include "iceberg/arrow_c_data.h" +#include "iceberg/manifest_entry.h" +#include "iceberg/manifest_list.h" +#include "iceberg/result.h" + +namespace iceberg { + +// \brief Implemented by different versions with different schemas to +// append a list of `ManifestEntry`s to an `ArrowArray`. +class ManifestEntryAdapter { + public: + ManifestEntryAdapter() = default; + virtual ~ManifestEntryAdapter() = default; + + virtual Status StartAppending() = 0; Review Comment: Both adaptors have StartAppending and FinishAppending, should be abstract a common base class for appending to nanoarrow arrays? -- 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