keith-turner opened a new issue, #3505:
URL: https://github.com/apache/accumulo/issues/3505

   **Is your feature request related to a problem? Please describe.**
   
   The code in 
[MetadataConstraints](https://github.com/apache/accumulo/blob/main/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java)
 is very disorganized and is possibly inefficient.  The disorganization makes 
it difficult to anylyze the code to ensure the validation is as strict as 
possible for each column.  The inefficiency comes from the chained if else 
statements that may compare the same family multiple times.
   
   **Describe the solution you'd like**
   
   It would be nice to use a swtich statement on the column family for 
efficiency and have a function per colum family to better organize the code.  
With this structure it will be easier to analyze to ensure every column has 
coverage.  The following is a skeleton of what this might look like.
   
   ```java
     @Override
     public List<Short> check(Environment env, Mutation mutation) {
       final ServerContext context = ((SystemEnvironment) 
env).getServerContext();
   
       
       ArrayList<Short> violations = null;
   
       violations = validateRow(violations, mutation);
   
       for (ColumnUpdate columnUpdate : colUpdates) {
         var familyStr = new String(columnUpdate.getColumnFamily(), UTF_8);
         switch (familyStr) {
           case  TabletColumnFamily.STR_NAME:
             violations = validateTabletFamily(violations, columnUpdate);
             break;
           case ServerColumnFamily.STR_NAME:
             violations = validateServerFamily(violations, columnUpdate);
             break;
             // TODO add case stmt for each family
           default:
             violations = addViolation(violations, 2);
         }
       }
       
       return violations;
   }
   
     private ArrayList<Short> validateServerFamily(ArrayList<Short> violations, 
ColumnUpdate columnUpdate) {
       var qualStr = new String(columnUpdate.getColumnQualifier(), UTF_8);
       
       switch (qualStr) {
         case ServerColumnFamily.OPID_QUAL:
           // TODO validate this
           break;
         case ServerColumnFamily.DIRECTORY_QUAL:
           // TODO validate this
           break;
        //TODO validate other qualifiers
         default:
           violations = addViolation(violations, 2);
       }
       
       return violations;
     }
   ```
   
   


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