@@ -47,16 +47,15 @@ class ICEBERG_EXPORT InMemoryNamespace {
4747 * \param[in] namespace_ident The namespace to check.
4848 * \return Status indicating success or failure.
4949 */
50- Status NamespaceExists (const Namespace& namespace_ident) const ;
50+ Result< bool > NamespaceExists (const Namespace& namespace_ident) const ;
5151
5252 /* *
5353 * \brief Lists immediate child namespaces under the given parent namespace.
54- * \param[in] parent_namespace_ident The optional parent namespace. If not provided,
55- * the children of the root are returned.
56- * \return A vector of child namespace names.
54+ * \param[in] parent_namespace_ident The optional parent namespace.
55+ * \return A vector of child namespaces.
5756 */
58- Result<std::vector<std::string >> ListChildrenNamespaces (
59- const std::optional< Namespace> & parent_namespace_ident = std:: nullopt ) const ;
57+ Result<std::vector<Namespace >> ListNamespaces (
58+ const Namespace& parent_namespace_ident) const ;
6059
6160 /* *
6261 * \brief Creates a new namespace with the specified properties.
@@ -72,7 +71,7 @@ class ICEBERG_EXPORT InMemoryNamespace {
7271 * \param[in] namespace_ident The namespace to delete.
7372 * \return Status indicating success or failure.
7473 */
75- Status DeleteNamespace (const Namespace& namespace_ident);
74+ Status DropNamespace (const Namespace& namespace_ident);
7675
7776 /* *
7877 * \brief Retrieves the properties of the specified namespace.
@@ -89,10 +88,20 @@ class ICEBERG_EXPORT InMemoryNamespace {
8988 * \param[in] properties The new properties map.
9089 * \return Status indicating success or failure.
9190 */
92- Status ReplaceProperties (
91+ Status SetNamespaceProperties (
9392 const Namespace& namespace_ident,
9493 const std::unordered_map<std::string, std::string>& properties);
9594
95+ // / \brief Remove a set of metadata properties from a namespace.
96+ // /
97+ // / \param namespace_ident the namespace to modify
98+ // / \param properties the set of property keys to remove
99+ // / \return Status::OK if removed successfully;
100+ // / ErrorKind::kNoSuchNamespace if the namespace does not exist;
101+ // / ErrorKind::kNotSupported if the operation is not supported
102+ Status RemoveNamespaceProperties (const Namespace& namespace_ident,
103+ const std::unordered_set<std::string>& properties);
104+
96105 /* *
97106 * \brief Lists all table names under the specified namespace.
98107 * \param[in] namespace_ident The namespace from which to list tables.
@@ -166,26 +175,31 @@ Result<const InMemoryNamespace*> GetNamespace(const InMemoryNamespace* root,
166175 return InMemoryNamespace::GetNamespaceImpl (root, namespace_ident);
167176}
168177
169- Status InMemoryNamespace::NamespaceExists (const Namespace& namespace_ident) const {
170- const auto ns = GetNamespace (this , namespace_ident);
171- ICEBERG_RETURN_UNEXPECTED (ns);
172- return {};
178+ Result<bool > InMemoryNamespace::NamespaceExists (const Namespace& namespace_ident) const {
179+ const auto & ns = GetNamespace (this , namespace_ident);
180+ if (ns.has_value ()) {
181+ return true ;
182+ }
183+ if (ns.error ().kind == ErrorKind::kNoSuchNamespace ) {
184+ return false ;
185+ }
186+ return unexpected<Error>(ns.error ());
173187}
174188
175- Result<std::vector<std::string>> InMemoryNamespace::ListChildrenNamespaces (
176- const std::optional<Namespace>& parent_namespace_ident) const {
177- auto ns = this ;
178- if (parent_namespace_ident.has_value ()) {
179- const auto nsRs = GetNamespace (this , *parent_namespace_ident);
180- ICEBERG_RETURN_UNEXPECTED (nsRs);
181- ns = *nsRs;
182- }
189+ Result<std::vector<Namespace>> InMemoryNamespace::ListNamespaces (
190+ const Namespace& parent_namespace_ident) const {
191+ const auto nsRs = GetNamespace (this , parent_namespace_ident);
192+ ICEBERG_RETURN_UNEXPECTED (nsRs);
193+ auto ns = *nsRs;
183194
184- std::vector<std::string > names;
195+ std::vector<Namespace > names;
185196 auto const & children = ns->children_ ;
186197 names.reserve (children.size ());
187- std::ranges::transform (children, std::back_inserter (names),
188- [](const auto & pair) { return pair.first ; });
198+ std::ranges::transform (children, std::back_inserter (names), [&](const auto & pair) {
199+ auto childNs = parent_namespace_ident;
200+ childNs.levels .emplace_back (pair.first );
201+ return childNs;
202+ });
189203 return names;
190204}
191205
@@ -214,7 +228,7 @@ Status InMemoryNamespace::CreateNamespace(
214228 return {};
215229}
216230
217- Status InMemoryNamespace::DeleteNamespace (const Namespace& namespace_ident) {
231+ Status InMemoryNamespace::DropNamespace (const Namespace& namespace_ident) {
218232 if (namespace_ident.levels .empty ()) {
219233 return InvalidArgument (" namespace identifier is empty" );
220234 }
@@ -247,7 +261,7 @@ Result<std::unordered_map<std::string, std::string>> InMemoryNamespace::GetPrope
247261 return ns.value ()->properties_ ;
248262}
249263
250- Status InMemoryNamespace::ReplaceProperties (
264+ Status InMemoryNamespace::SetNamespaceProperties (
251265 const Namespace& namespace_ident,
252266 const std::unordered_map<std::string, std::string>& properties) {
253267 const auto ns = GetNamespace (this , namespace_ident);
@@ -256,6 +270,15 @@ Status InMemoryNamespace::ReplaceProperties(
256270 return {};
257271}
258272
273+ Status InMemoryNamespace::RemoveNamespaceProperties (
274+ const Namespace& namespace_ident, const std::unordered_set<std::string>& properties) {
275+ const auto ns = GetNamespace (this , namespace_ident);
276+ ICEBERG_RETURN_UNEXPECTED (ns);
277+ std::ranges::for_each (properties,
278+ [&](const auto & prop) { ns.value ()->properties_ .erase (prop); });
279+ return {};
280+ }
281+
259282Result<std::vector<std::string>> InMemoryNamespace::ListTables (
260283 const Namespace& namespace_ident) const {
261284 const auto ns = GetNamespace (this , namespace_ident);
@@ -317,6 +340,25 @@ class ICEBERG_EXPORT InMemoryCatalogImpl {
317340
318341 std::string_view name () const ;
319342
343+ Status CreateNamespace (const Namespace& ns,
344+ const std::unordered_map<std::string, std::string>& properties);
345+
346+ Result<std::vector<Namespace>> ListNamespaces (const Namespace& ns) const ;
347+
348+ Status DropNamespace (const Namespace& ns);
349+
350+ Result<bool > NamespaceExists (const Namespace& ns) const ;
351+
352+ Result<std::unordered_map<std::string, std::string>> GetNamespaceProperties (
353+ const Namespace& ns) const ;
354+
355+ Status SetNamespaceProperties (
356+ const Namespace& ns,
357+ const std::unordered_map<std::string, std::string>& properties);
358+
359+ Status RemoveNamespaceProperties (const Namespace& ns,
360+ const std::unordered_set<std::string>& properties);
361+
320362 Result<std::vector<TableIdentifier>> ListTables (const Namespace& ns) const ;
321363
322364 Result<std::unique_ptr<Table>> CreateTable (
@@ -366,6 +408,46 @@ InMemoryCatalogImpl::InMemoryCatalogImpl(
366408
367409std::string_view InMemoryCatalogImpl::name () const { return catalog_name_; }
368410
411+ Status InMemoryCatalogImpl::CreateNamespace (
412+ const Namespace& ns, const std::unordered_map<std::string, std::string>& properties) {
413+ std::unique_lock lock (mutex_);
414+ return root_namespace_->CreateNamespace (ns, properties);
415+ }
416+
417+ Result<std::vector<Namespace>> InMemoryCatalogImpl::ListNamespaces (
418+ const Namespace& ns) const {
419+ std::unique_lock lock (mutex_);
420+ return root_namespace_->ListNamespaces (ns);
421+ }
422+
423+ Status InMemoryCatalogImpl::DropNamespace (const Namespace& ns) {
424+ std::unique_lock lock (mutex_);
425+ return root_namespace_->DropNamespace (ns);
426+ }
427+
428+ Result<bool > InMemoryCatalogImpl::NamespaceExists (const Namespace& ns) const {
429+ std::unique_lock lock (mutex_);
430+ return root_namespace_->NamespaceExists (ns);
431+ }
432+
433+ Result<std::unordered_map<std::string, std::string>>
434+ InMemoryCatalogImpl::GetNamespaceProperties (const Namespace& ns) const {
435+ std::unique_lock lock (mutex_);
436+ return root_namespace_->GetProperties (ns);
437+ }
438+
439+ Status InMemoryCatalogImpl::SetNamespaceProperties (
440+ const Namespace& ns, const std::unordered_map<std::string, std::string>& properties) {
441+ std::unique_lock lock (mutex_);
442+ return root_namespace_->SetNamespaceProperties (ns, properties);
443+ }
444+
445+ Status InMemoryCatalogImpl::RemoveNamespaceProperties (
446+ const Namespace& ns, const std::unordered_set<std::string>& properties) {
447+ std::unique_lock lock (mutex_);
448+ return root_namespace_->RemoveNamespaceProperties (ns, properties);
449+ }
450+
369451Result<std::vector<TableIdentifier>> InMemoryCatalogImpl::ListTables (
370452 const Namespace& ns) const {
371453 std::unique_lock lock (mutex_);
@@ -444,6 +526,39 @@ InMemoryCatalog::~InMemoryCatalog() = default;
444526
445527std::string_view InMemoryCatalog::name () const { return impl_->name (); }
446528
529+ Status InMemoryCatalog::CreateNamespace (
530+ const Namespace& ns, const std::unordered_map<std::string, std::string>& properties) {
531+ return impl_->CreateNamespace (ns, properties);
532+ }
533+
534+ Result<std::unordered_map<std::string, std::string>>
535+ InMemoryCatalog::GetNamespaceProperties (const Namespace& ns) const {
536+ return impl_->GetNamespaceProperties (ns);
537+ }
538+
539+ Result<std::vector<Namespace>> InMemoryCatalog::ListNamespaces (
540+ const Namespace& ns) const {
541+ return impl_->ListNamespaces (ns);
542+ }
543+
544+ Status InMemoryCatalog::DropNamespace (const Namespace& ns) {
545+ return impl_->DropNamespace (ns);
546+ }
547+
548+ Result<bool > InMemoryCatalog::NamespaceExists (const Namespace& ns) const {
549+ return impl_->NamespaceExists (ns);
550+ }
551+
552+ Status InMemoryCatalog::RemoveNamespaceProperties (
553+ const Namespace& ns, const std::unordered_set<std::string>& properties) {
554+ return impl_->RemoveNamespaceProperties (ns, properties);
555+ }
556+
557+ Status InMemoryCatalog::SetNamespaceProperties (
558+ const Namespace& ns, const std::unordered_map<std::string, std::string>& properties) {
559+ return impl_->SetNamespaceProperties (ns, properties);
560+ }
561+
447562Result<std::vector<TableIdentifier>> InMemoryCatalog::ListTables (
448563 const Namespace& ns) const {
449564 return impl_->ListTables (ns);
0 commit comments