keith-turner commented on code in PR #5478:
URL: https://github.com/apache/accumulo/pull/5478#discussion_r2047120898


##########
core/src/main/java/org/apache/accumulo/core/file/FilePrefix.java:
##########
@@ -18,25 +18,86 @@
  */
 package org.apache.accumulo.core.file;
 
-import java.util.stream.Stream;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+import com.google.common.base.Preconditions;
 
 public enum FilePrefix {
 
-  BULK_IMPORT("I"), MINOR_COMPACTION("F"), MAJOR_COMPACTION("C"), 
MAJOR_COMPACTION_ALL_FILES("A");
+  ALL("*", false),
+  MINOR_COMPACTION("F", true),
+  BULK_IMPORT("I", true),
+  MAJOR_COMPACTION("C", true),
+  MAJOR_COMPACTION_ALL_FILES("A", true),
+  MERGING_MINOR_COMPACTION("M", false);
 
   final String prefix;
+  final boolean canCreateFiles;
 
-  FilePrefix(String prefix) {
+  FilePrefix(String prefix, boolean canCreateFiles) {
     this.prefix = prefix;
+    this.canCreateFiles = canCreateFiles;
+  }
+
+  public String toPrefix() {
+    return this.prefix;
+  }
+
+  public String createFileName(String fileName) {
+    Objects.requireNonNull(fileName, "filename must be supplied");
+    Preconditions.checkArgument(!fileName.isBlank(), "Empty filename 
supplied");
+    if (!canCreateFiles) {
+      throw new IllegalStateException("Unable to create filename with prefix: 
" + prefix);
+    }
+    return prefix + fileName;
   }
 
   public static FilePrefix fromPrefix(String prefix) {
-    return Stream.of(FilePrefix.values()).filter(p -> 
p.prefix.equals(prefix)).findAny()
-        .orElseThrow(() -> new IllegalArgumentException("Unknown prefix type: 
" + prefix));
+    Objects.requireNonNull(prefix, "prefix must be supplied");
+    Preconditions.checkArgument(!prefix.isBlank(), "Empty prefix supplied");
+    Preconditions.checkArgument(prefix.length() == 1, "Invalid prefix 
supplied: " + prefix);
+    for (FilePrefix fp : values()) {
+      if (fp == ALL) {

Review Comment:
   seems like this check could be moved outside the loop



-- 
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]

Reply via email to