accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] jmark99 commented on a change in pull request #337: ACCUMULO-4732 No APIs to configure iterators or locality groups for new tables
Date Thu, 01 Jan 1970 00:00:00 GMT
jmark99 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_r156779479
 
 

 ##########
 File path: core/src/main/java/org/apache/accumulo/core/client/admin/NewTableConfiguration.java
 ##########
 @@ -146,4 +163,116 @@ 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
+   */
+  public void 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(), Joiner.on(",").join(groups.keySet()));
+    localityProps.put(Property.TABLE_LOCALITY_GROUPS.getKey(), groups.keySet().stream().collect(Collectors.joining(",")));
+    // localityProps.put(Property.TABLE_LOCALITY_GROUPS.getKey(), Stream.of(groups.keySet().collect(Collectors.joining(","));
+    // Stream.of(groups.keySet()).collect(joining(","));
+  }
+
+  /**
+   * 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 AccumuloSecurityException
+   *           thrown if the user does not have the ability to set properties on the table
+   * @throws AccumuloException
+   *           if a general error occurs
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   *
+   * @since 2.0.0
+   */
+  public void attachIterator(IteratorSetting setting) throws AccumuloException, TableNotFoundException
{
+    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
+   * @throws AccumuloSecurityException
+   *           thrown if the user does not have the ability to set properties on the table
+   * @throws TableNotFoundException
+   *           if the table does not exist
+   *
+   * @since 2.0.0
+   */
+  public void attachIterator(IteratorSetting setting, EnumSet<IteratorScope> scopes)
throws AccumuloException, TableNotFoundException {
+    checkArgument(setting != null, "setting is null");
+    checkArgument(scopes != null, "scopes is null");
+    if (iteratorProps.isEmpty()) {
+      iteratorProps = new HashMap<>();
+    }
+    checkIteratorConflicts(setting, scopes);
+    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()) {
+        iteratorProps.put(root + ".opt." + prop.getKey(), prop.getValue());
+      }
+      iteratorProps.put(root, setting.getPriority() + "," + setting.getIteratorClass());
+    }
+  }
+
+  private void checkIteratorConflicts(IteratorSetting setting, EnumSet<IteratorScope>
scopes) throws AccumuloException, TableNotFoundException {
+    checkArgument(setting != null, "setting is null");
 
 Review comment:
   @keith-turner I have a question concerning this. It's strightforward enough to create the
new method and refactor the old. Perhaps I'm not completely versed on its usage yet, but wouldn't
calling the method from NewTableConfiguration require instantiation of the TableOperationsImpl
object? When I was playing around with it, this required a ClientConfiguration object which
then required an Instance object,etc. It seemed to get messy attempting the call. Am I missing
something obvious?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message