DomGarguilo commented on code in PR #2965:
URL: https://github.com/apache/accumulo/pull/2965#discussion_r997094548
##########
shell/src/main/java/org/apache/accumulo/shell/commands/CreateTableCommand.java:
##########
@@ -134,22 +135,24 @@ public int execute(final String fullCommand, final
CommandLine cl, final Shell s
shellState.setTableName(tableName); // switch shell to new table context
if (cl.hasOption(createTableNoDefaultIters.getOpt())) {
- for (String key :
IteratorConfigUtil.generateInitialTableProperties(true).keySet()) {
-
shellState.getAccumuloClient().tableOperations().removeProperty(tableName, key);
- }
+ Set<String> initialProps =
IteratorConfigUtil.generateInitialTableProperties(true).keySet();
+
shellState.getAccumuloClient().tableOperations().modifyProperties(tableName,
+ properties -> initialProps.forEach(properties::remove));
}
// Copy options if flag was set
if (cl.hasOption(createTableOptCopyConfig.getOpt())) {
if (shellState.getAccumuloClient().tableOperations().exists(tableName)) {
final Map<String,String> configuration =
shellState.getAccumuloClient().tableOperations()
.getConfiguration(cl.getOptionValue(createTableOptCopyConfig.getOpt()));
- for (Entry<String,String> entry : configuration.entrySet()) {
- if (Property.isValidTablePropertyKey(entry.getKey())) {
-
shellState.getAccumuloClient().tableOperations().setProperty(tableName,
entry.getKey(),
- entry.getValue());
- }
- }
+
+ Map<String,
+ String> propsToAdd = configuration.entrySet().stream()
+ .filter(entry ->
Property.isValidTablePropertyKey(entry.getKey()))
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+
+
shellState.getAccumuloClient().tableOperations().modifyProperties(tableName,
+ properties -> properties.putAll(propsToAdd));
Review Comment:
Do you think I should refactor all of the spots that are similar to this to
reduce the number of times we iterate?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]