zhjwpku commented on code in PR #80:
URL: https://github.com/apache/iceberg-cpp/pull/80#discussion_r2059495353


##########
src/iceberg/catalog/memory_catalog.cc:
##########
@@ -0,0 +1,275 @@
+/*
+ * 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/catalog/memory_catalog.h"
+
+#include <algorithm>
+#include <iterator>  // IWYU pragma: keep
+
+#include "iceberg/exception.h"
+#include "iceberg/table.h"
+#include "iceberg/util/macros.h"
+
+namespace iceberg {
+
+namespace {
+
+Result<InMemoryNamespace*> GetNamespace(InMemoryNamespace* root,
+                                        const Namespace& namespace_ident) {
+  return InMemoryNamespace::GetNamespaceImpl(root, namespace_ident);
+}
+
+Result<const InMemoryNamespace*> GetNamespace(const InMemoryNamespace* root,
+                                              const Namespace& 
namespace_ident) {
+  return InMemoryNamespace::GetNamespaceImpl(root, namespace_ident);
+}
+
+}  // namespace
+
+InMemoryCatalog::InMemoryCatalog(std::shared_ptr<FileIO> file_io,
+                                 std::string warehouse_location)
+    : file_io_(std::move(file_io)),
+      warehouse_location_(std::move(warehouse_location)),
+      root_namespace_(std::make_unique<InMemoryNamespace>()) {}
+
+void InMemoryCatalog::Initialize(
+    const std::string& name,
+    const std::unordered_map<std::string, std::string>& properties) {
+  catalog_name_ = name;
+  properties_ = properties;
+}
+
+std::string_view InMemoryCatalog::name() const { return catalog_name_; }
+
+Result<std::vector<TableIdentifier>> InMemoryCatalog::ListTables(
+    const Namespace& ns) const {
+  std::unique_lock lock(mutex_);
+  const auto& table_names = root_namespace_->ListTables(ns);
+  ICEBERG_RETURN_UNEXPECTED(table_names);
+  std::vector<TableIdentifier> table_idents;
+  table_idents.reserve(table_names.value().size());
+  std::ranges::transform(
+      table_names.value(), std::back_inserter(table_idents),
+      [&ns](auto const& table_name) { return TableIdentifier(ns, table_name); 
});
+  return table_idents;
+}
+
+Result<std::unique_ptr<Table>> InMemoryCatalog::CreateTable(
+    const TableIdentifier& identifier, const Schema& schema, const 
PartitionSpec& spec,
+    const std::string& location,
+    const std::unordered_map<std::string, std::string>& properties) {
+  return unexpected<Error>(

Review Comment:
   return NotImplemented would be better. The same with other places that using 
unexpected.



##########
src/iceberg/catalog/memory_catalog.h:
##########
@@ -0,0 +1,204 @@
+/*

Review Comment:
   rename the filename to in_memory_catalog.h/cc?



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