wgtmac commented on code in PR #176:
URL: https://github.com/apache/iceberg-cpp/pull/176#discussion_r2295457848


##########
src/iceberg/v2_metadata.h:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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/v2_metadata.h
+
+#include "iceberg/manifest_adapter.h"
+#include "iceberg/manifest_entry.h"
+#include "iceberg/manifest_list.h"

Review Comment:
   ```suggestion
   ```



##########
src/iceberg/manifest_writer.cc:
##########
@@ -0,0 +1,182 @@
+/*
+ * 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.
+ */
+
+#include "iceberg/manifest_writer.h"
+
+#include "iceberg/manifest_entry.h"
+#include "iceberg/manifest_list.h"
+#include "iceberg/schema.h"
+#include "iceberg/util/macros.h"
+#include "iceberg/v1_metadata.h"
+#include "iceberg/v2_metadata.h"
+#include "iceberg/v3_metadata.h"
+
+namespace iceberg {
+
+Status ManifestWriter::Add(const ManifestEntry& entry) {
+  if (adapter_->size() >= kBatchSize) {
+    ICEBERG_ASSIGN_OR_RAISE(auto array, adapter_->FinishAppending());
+    ICEBERG_RETURN_UNEXPECTED(writer_->Write(array));
+    ICEBERG_RETURN_UNEXPECTED(adapter_->StartAppending());
+  }
+  return adapter_->Append(entry);
+}
+
+Status ManifestWriter::AddAll(const std::vector<ManifestEntry>& entries) {
+  for (const auto& entry : entries) {
+    ICEBERG_RETURN_UNEXPECTED(Add(entry));
+  }
+  return {};
+}
+
+Status ManifestWriter::Close() {
+  if (adapter_->size() > 0) {
+    ICEBERG_ASSIGN_OR_RAISE(auto array, adapter_->FinishAppending());
+    ICEBERG_RETURN_UNEXPECTED(writer_->Write(array));
+  }
+  return {};
+}
+
+Result<std::unique_ptr<Writer>> OpenFileWriter(std::string_view location,
+                                               const std::shared_ptr<Schema> 
schema,
+                                               std::shared_ptr<FileIO> 
file_io) {
+  ICEBERG_ASSIGN_OR_RAISE(
+      auto writer,
+      WriterFactoryRegistry::Open(
+          FileFormatType::kAvro,
+          {.path = std::string(location), .schema = schema, .io = 
std::move(file_io)}));
+  return writer;
+}

Review Comment:
   ```suggestion
   Result<std::unique_ptr<Writer>> OpenFileWriter(std::string_view location,
                                                  std::shared_ptr<Schema> 
schema,
                                                  std::shared_ptr<FileIO> 
file_io) {
     ICEBERG_ASSIGN_OR_RAISE(
         auto writer,
         WriterFactoryRegistry::Open(
             FileFormatType::kAvro,
             {.path = std::string(location), .schema = std::move(schema), .io = 
std::move(file_io)}));
     return writer;
   }
   ```



##########
src/iceberg/v3_metadata.h:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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/v3_metadata.h
+
+#include "iceberg/manifest_adapter.h"
+#include "iceberg/manifest_entry.h"
+#include "iceberg/manifest_list.h"

Review Comment:
   ```suggestion
   ```



##########
src/iceberg/manifest_adapter.h:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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"

Review Comment:
   ```suggestion
   #include "iceberg/type_fwd.h"
   ```



##########
src/iceberg/v1_metadata.h:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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/v1_metadata.h
+
+#include "iceberg/manifest_adapter.h"
+#include "iceberg/manifest_entry.h"
+#include "iceberg/manifest_list.h"

Review Comment:
   ```suggestion
   ```
   
   Let's use forward declaration.



##########
src/iceberg/manifest_adapter.h:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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 Base class of adapter for v1v2v3v4 metadata.

Review Comment:
   ```suggestion
   // \brief Base class to append manifest metadata to Arrow array.
   ```



-- 
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