This is an automated email from the ASF dual-hosted git repository.

cshannon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 0499ab6804 Use NamespaceOperations.modifyProperties() in more places 
(#3025)
0499ab6804 is described below

commit 0499ab68043c2fabb3a25546519e31d09f572a1c
Author: Dom G <domgargu...@apache.org>
AuthorDate: Mon Oct 17 17:08:51 2022 -0400

    Use NamespaceOperations.modifyProperties() in more places (#3025)
    
    Use NamespaceOperations.modifyProperties() in more places
    
    Co-authored-by: Christopher L. Shannon <christopher.l.shan...@gmail.com>
---
 .../core/clientImpl/NamespaceOperationsHelper.java     | 18 ++++++++++--------
 .../shell/commands/CreateNamespaceCommand.java         | 12 +++++-------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsHelper.java
 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsHelper.java
index 59336acebd..ad0000958c 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsHelper.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsHelper.java
@@ -59,10 +59,12 @@ public abstract class NamespaceOperationsHelper implements 
NamespaceOperations {
     for (IteratorScope scope : scopes) {
       String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX,
           scope.name().toLowerCase(), setting.getName());
-      for (Entry<String,String> prop : setting.getOptions().entrySet()) {
-        this.setProperty(namespace, root + ".opt." + prop.getKey(), 
prop.getValue());
-      }
-      this.setProperty(namespace, root, setting.getPriority() + "," + 
setting.getIteratorClass());
+      this.modifyProperties(namespace, properties -> {
+        for (Entry<String,String> prop : setting.getOptions().entrySet()) {
+          properties.put(root + ".opt." + prop.getKey(), prop.getValue());
+        }
+        properties.put(root, setting.getPriority() + "," + 
setting.getIteratorClass());
+      });
     }
   }
 
@@ -75,10 +77,10 @@ public abstract class NamespaceOperationsHelper implements 
NamespaceOperations {
     for (IteratorScope scope : scopes) {
       String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX,
           scope.name().toLowerCase(), name);
-      for (Entry<String,String> property : copy.entrySet()) {
-        if (property.getKey().equals(root) || 
property.getKey().startsWith(root + ".opt."))
-          this.removeProperty(namespace, property.getKey());
-      }
+      this.modifyProperties(namespace,
+          properties -> copy.keySet().stream()
+              .filter(key -> key.equals(root) || key.startsWith(root + 
".opt."))
+              .forEach(properties::remove));
     }
   }
 
diff --git 
a/shell/src/main/java/org/apache/accumulo/shell/commands/CreateNamespaceCommand.java
 
b/shell/src/main/java/org/apache/accumulo/shell/commands/CreateNamespaceCommand.java
index d7bd7c06af..d7f509c75b 100644
--- 
a/shell/src/main/java/org/apache/accumulo/shell/commands/CreateNamespaceCommand.java
+++ 
b/shell/src/main/java/org/apache/accumulo/shell/commands/CreateNamespaceCommand.java
@@ -20,7 +20,6 @@ package org.apache.accumulo.shell.commands;
 
 import java.io.IOException;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -62,12 +61,11 @@ public class CreateNamespaceCommand extends Command {
       }
     }
     if (configuration != null) {
-      for (Entry<String,String> entry : configuration.entrySet()) {
-        if (Property.isValidTablePropertyKey(entry.getKey())) {
-          
shellState.getAccumuloClient().namespaceOperations().setProperty(namespace,
-              entry.getKey(), entry.getValue());
-        }
-      }
+      final Map<String,String> config = configuration;
+      
shellState.getAccumuloClient().namespaceOperations().modifyProperties(namespace,
+          properties -> config.entrySet().stream()
+              .filter(entry -> 
Property.isValidTablePropertyKey(entry.getKey()))
+              .forEach(entry -> properties.put(entry.getKey(), 
entry.getValue())));
     }
 
     return 0;

Reply via email to