accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From keith-turner <...@git.apache.org>
Subject [GitHub] accumulo pull request #106: ACCUMULO-4153: Update the getCodec method to no ...
Date Wed, 01 Jun 2016 19:57:21 GMT
Github user keith-turner commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/106#discussion_r65430909
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Compression.java
---
    @@ -81,38 +89,60 @@ public void flush() throws IOException {
        * Compression algorithms.
        */
       public static enum Algorithm {
    +
         LZO(COMPRESSION_LZO) {
    -      private transient boolean checked = false;
    +      private AtomicBoolean checked = new AtomicBoolean(false);
           private static final String defaultClazz = "org.apache.hadoop.io.compress.LzoCodec";
           private transient CompressionCodec codec = null;
     
    +      /**
    +       * Configuration option for LZO buffer size
    +       */
    +      private static final String BUFFER_SIZE_OPT = "io.compression.codec.lzo.buffersize";
    +
    +      /**
    +       * Default buffer size
    +       */
    +      private static final int DEFAULT_BUFFER_SIZE = 64 * 1024;
    +
           @Override
    -      public synchronized boolean isSupported() {
    -        if (!checked) {
    -          checked = true;
    -          String extClazz = (conf.get(CONF_LZO_CLASS) == null ? System.getProperty(CONF_LZO_CLASS)
: null);
    -          String clazz = (extClazz != null) ? extClazz : defaultClazz;
    -          try {
    -            LOG.info("Trying to load Lzo codec class: " + clazz);
    -            codec = (CompressionCodec) ReflectionUtils.newInstance(Class.forName(clazz),
conf);
    -          } catch (ClassNotFoundException e) {
    -            // that is okay
    -          }
    -        }
    +      public boolean isSupported() {
             return codec != null;
           }
     
    +      public void createCodec() {
    +        if (!checked.get()) {
    +          checked.set(true);
    +          codec = createNewCodec(DEFAULT_BUFFER_SIZE);
    --- End diff --
    
    maybe codec should be volatile


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message