ctubbsii commented on a change in pull request #337: ACCUMULO-4732 No APIs to 
configure iterators or locality groups for new tables
URL: https://github.com/apache/accumulo/pull/337#discussion_r157080661
 
 

 ##########
 File path: 
core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java
 ##########
 @@ -146,4 +161,75 @@ public NewTableConfiguration 
enableSummarization(SummarizerConfiguration... conf
     summarizerProps = tmp;
     return this;
   }
+
+  /**
+   * Configures a table's locality groups prior to initial table creation.
+   *
+   * Allows locality groups to be set prior to table creation. Additional 
calls to this method prior to table creation will overwrite previous locality 
group
+   * mappings.
+   *
+   * @param groups
+   *          mapping of locality group names to column families in the 
locality group
+   *
+   * @since 2.0.0
+   *
+   * @see TableOperations#setLocalityGroups
+   */
+  public NewTableConfiguration setLocalityGroups(Map<String,Set<Text>> groups) 
{
+    // ensure locality groups do not overlap
+    LocalityGroupUtil.ensureNonOverlappingGroups(groups);
+    localityProps = new HashMap<>();
+    for (Entry<String,Set<Text>> entry : groups.entrySet()) {
+      Set<Text> colFams = entry.getValue();
+      String value = LocalityGroupUtil.encodeColumnFamilies(colFams);
+      localityProps.put(Property.TABLE_LOCALITY_GROUP_PREFIX + entry.getKey(), 
value);
+    }
+    localityProps.put(Property.TABLE_LOCALITY_GROUPS.getKey(), 
groups.keySet().stream().collect(Collectors.joining(",")));
+    return this;
+  }
+
+  /**
+   * Configure iterator settings for a table prior to its creation.
+   *
+   * Additional calls to this method before table creation will overwrite 
previous iterator settings.
+   *
+   * @param setting
+   *          object specifying the properties of the iterator
+   * @throws AccumuloException
+   *           if a general error occurs
+   *
+   * @since 2.0.0
+   */
+  public NewTableConfiguration attachIterator(IteratorSetting setting) throws 
AccumuloException {
+    return attachIterator(setting, EnumSet.allOf(IteratorScope.class));
+  }
+
+  /**
+   * Configure iterator settings for a table prior to its creation.
+   *
+   * @param setting
+   *          object specifying the properties of the iterator
+   * @param scopes
+   *          enumerated set of iterator scopes
+   * @throws AccumuloException
+   *           if a general error occurs
+   *
+   * @since 2.0.0
+   */
+  public NewTableConfiguration attachIterator(IteratorSetting setting, 
EnumSet<IteratorScope> scopes) throws AccumuloException {
+    checkArgument(setting != null, "setting is null");
+    checkArgument(scopes != null, "scopes is null");
+    if (iteratorProps.isEmpty())
+      iteratorProps = new HashMap<>();
 
 Review comment:
   If it's already empty, then there's no point in allocating a new empty one, 
assuming the previously allocated empty one can be updated. If not, we 
shouldn't use that empty one as a placeholder for "unset".

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to