ctubbsii commented on a change in pull request #2221:
URL: https://github.com/apache/accumulo/pull/2221#discussion_r682893173



##########
File path: 
core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Compression.java
##########
@@ -250,33 +277,71 @@ public void initializeDefaultCodec() {
        */
       @Override
       protected CompressionCodec createNewCodec(final int bufferSize) {
-        DefaultCodec myCodec = new DefaultCodec();
-        Configuration myConf = new Configuration(conf);
-        // only use the buffersize if > 0, otherwise we'll use
-        // the default defined within the codec
-        if (bufferSize > 0)
-          myConf.setInt(BUFFER_SIZE_OPT, bufferSize);
-        myCodec.setConf(myConf);
-        return myCodec;
+        if (USE_QAT) {
+          String extClazz =
+              (conf.get(CONF_QAT_CLASS) == null ? 
System.getProperty(CONF_QAT_CLASS) : null);
+          String clazz = (extClazz != null) ? extClazz : DEFAULT_QAT_CLASS;
+          try {
+            LOG.info("Trying to load qat codec class: " + clazz);
+
+            Configuration myConf = new Configuration(conf);
+            // only use the buffersize if > 0, otherwise we'll use
+            // the default defined within the codec
+            if (bufferSize > 0)
+              myConf.setInt(QAT_BUFFER_SIZE_OPT, bufferSize);
+
+            CompressionCodec c =
+                (CompressionCodec) 
ReflectionUtils.newInstance(Class.forName(clazz), myConf);
+            if (c instanceof Configurable) {
+              ((Configurable) c).setConf(myConf);
+            }
+            return c;
+          } catch (ClassNotFoundException e) {
+            LOG.error("Unable to create QAT codec", e);
+          }
+          return null;

Review comment:
       Yeah, I understand the desire to fail fast instead of diagnose when 
things aren't working as expected. I'm just thinking we have to infer what the 
user is expecting. I'm sure some users might expect "I want QAT's impl of GZ 
only". But other users might expect "I want GZ, QAT to make it faster, if 
available". Personally, I'd be somebody in the latter camp.
   
   Could support both sets of user expectations with values of 
`.enabled=[true,false,required/force]`. However, considering the 
forwards-compatible requirement of 1.10.2 with 1.10.1/1.10.0, it's impossible 
for a user of "1.10.x" versions to expect that it will always fail if QAT isn't 
available. The user might set '.enabled=force', but then need to downgrade to 
1.10.1 for whatever reason, and the option is completely ignored. So, at best, 
the user can only reasonably expect 1.10 versions to treat this as an 
optimization, and never a requirement, unless they know for sure they are a 
sufficiently recent 1.10 version.




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