Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3B2712009E2 for ; Wed, 1 Jun 2016 22:26:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 39AE2160A4C; Wed, 1 Jun 2016 20:26:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8285E160A45 for ; Wed, 1 Jun 2016 22:26:54 +0200 (CEST) Received: (qmail 61917 invoked by uid 500); 1 Jun 2016 20:26:53 -0000 Mailing-List: contact dev-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list dev@accumulo.apache.org Received: (qmail 61906 invoked by uid 99); 1 Jun 2016 20:26:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2016 20:26:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 30B6DE0498; Wed, 1 Jun 2016 20:26:53 +0000 (UTC) From: keith-turner To: dev@accumulo.apache.org Reply-To: dev@accumulo.apache.org References: In-Reply-To: Subject: [GitHub] accumulo pull request #106: ACCUMULO-4153: Update the getCodec method to no ... Content-Type: text/plain Message-Id: <20160601202653.30B6DE0498@git1-us-west.apache.org> Date: Wed, 1 Jun 2016 20:26:53 +0000 (UTC) archived-at: Wed, 01 Jun 2016 20:26:55 -0000 Github user keith-turner commented on a diff in the pull request: https://github.com/apache/accumulo/pull/106#discussion_r65435729 --- Diff: core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Compression.java --- @@ -244,44 +361,58 @@ public synchronized OutputStream createCompressionStream(OutputStream downStream } else { bos1 = downStream; } - conf.setInt("io.compression.codec.snappy.buffersize", 64 * 1024); + // use the default codec CompressionOutputStream cos = snappyCodec.createOutputStream(bos1, compressor); BufferedOutputStream bos2 = new BufferedOutputStream(new FinishOnFlushCompressionStream(cos), DATA_OBUF_SIZE); return bos2; } @Override - public synchronized InputStream createDecompressionStream(InputStream downStream, Decompressor decompressor, int downStreamBufferSize) throws IOException { + public InputStream createDecompressionStream(InputStream downStream, Decompressor decompressor, int downStreamBufferSize) throws IOException { if (!isSupported()) { throw new IOException("SNAPPY codec class not specified. Did you forget to set property " + CONF_SNAPPY_CLASS + "?"); } - if (downStreamBufferSize > 0) { - conf.setInt("io.file.buffer.size", downStreamBufferSize); + + CompressionCodec decomCodec = snappyCodec; + // if we're not using the same buffer size, we'll pull the codec from the loading cache + if (DEFAULT_BUFFER_SIZE != downStreamBufferSize) { + Entry sizeOpt = Maps.immutableEntry(SNAPPY, downStreamBufferSize); + try { + decomCodec = codecCache.get(sizeOpt); + } catch (ExecutionException e) { + throw new IOException(e); + } } - CompressionInputStream cis = snappyCodec.createInputStream(downStream, decompressor); + + CompressionInputStream cis = decomCodec.createInputStream(downStream, decompressor); BufferedInputStream bis2 = new BufferedInputStream(cis, DATA_IBUF_SIZE); return bis2; } @Override - public synchronized boolean isSupported() { - if (!checked) { - checked = true; - String extClazz = (conf.get(CONF_SNAPPY_CLASS) == null ? System.getProperty(CONF_SNAPPY_CLASS) : null); - String clazz = (extClazz != null) ? extClazz : defaultClazz; - try { - LOG.info("Trying to load snappy codec class: " + clazz); - snappyCodec = (CompressionCodec) ReflectionUtils.newInstance(Class.forName(clazz), conf); - } catch (ClassNotFoundException e) { - // that is okay - } - } + public boolean isSupported() { + --- End diff -- I can't see a problem with removing transient... thats just for serialization. I am not sure why it was there in the 1st place which is why I was cautious about removing it. I am ok w/ removing transient. > All codecs are singletons, defined in the static initializer of the enum. I didn't notice these were set in a static initializer. I am not sure if volatile is need in this case. Would need to ensure it written to main memory. I suspect it is written to main memory in this case. --- 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. ---