You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/06/16 08:10:41 UTC

[GitHub] [ozone] elek commented on a change in pull request #2331: HDDS-5247. EC: Create ECReplicationConfig on client side based on input string

elek commented on a change in pull request #2331:
URL: https://github.com/apache/ozone/pull/2331#discussion_r652453883



##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ECReplicationConfig.java
##########
@@ -36,6 +43,29 @@ public ECReplicationConfig(int data, int parity) {
     this.parity = parity;
   }
 
+  public ECReplicationConfig(String string) {
+    final Pattern pattern = Pattern.compile("(\\d+)-(\\d+)");
+    final Matcher matcher = pattern.matcher(string);

Review comment:
       Good point. Let me move it to a static final constant.
   
   Answering the question is slightly harder. Compilation time I couldn't see any optimization:
   
   
   ```
   javap -v org.apache.hadoop.hdds.client.ECReplicationConfig
   
   ...
   
     public org.apache.hadoop.hdds.client.ECReplicationConfig(java.lang.String);
       descriptor: (Ljava/lang/String;)V
       flags: ACC_PUBLIC
       Code:
         stack=3, locals=4, args_size=2
            0: aload_0
            1: invokespecial #1                  // Method java/lang/Object."<init>":()V
            4: ldc           #4                  // String (\d+)-(\d+)
            6: invokestatic  #5                  // Method java/util/regex/Pattern.compile:(Ljava/lang/String;)Ljava/util/regex/Pattern;
            9: astore_2
   ```
   
   The call is really compiled as is to the method.
   
   Runtime optimization it's another question, but I don't think that it's possible easily as hostpost JVM would require understanding about the idempotency of `Pattern.compile` (second call on `Pattern.compile` returns with a value which is equivalent to the first one.)
   
   --> looks better to move the compile to a static field...
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org