ORC-310 CR 1
Project: http://git-wip-us.apache.org/repos/asf/orc/repo Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/06c93b30 Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/06c93b30 Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/06c93b30 Branch: refs/heads/orc-310 Commit: 06c93b30b9b075969c984e0c60f783572c6a4a24 Parents: d9727cb Author: sergey <[email protected]> Authored: Thu Mar 1 15:41:45 2018 -0800 Committer: sergey <[email protected]> Committed: Thu Mar 1 15:41:45 2018 -0800 ---------------------------------------------------------------------- .../src/java/org/apache/orc/impl/OrcCodecPool.java | 17 +++++++++++++++-- .../java/org/apache/orc/impl/RecordReaderImpl.java | 5 +---- .../src/java/org/apache/orc/impl/WriterImpl.java | 5 +---- 3 files changed, 17 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/orc/blob/06c93b30/java/core/src/java/org/apache/orc/impl/OrcCodecPool.java ---------------------------------------------------------------------- diff --git a/java/core/src/java/org/apache/orc/impl/OrcCodecPool.java b/java/core/src/java/org/apache/orc/impl/OrcCodecPool.java index 34f0bd4..4ae43a2 100644 --- a/java/core/src/java/org/apache/orc/impl/OrcCodecPool.java +++ b/java/core/src/java/org/apache/orc/impl/OrcCodecPool.java @@ -60,10 +60,17 @@ public final class OrcCodecPool { return codec; } + /** + * Returns the codec to the pool or closes it, suppressing exceptions. + * @param kind Compression kind. + * @param codec Codec. + * @param observedError Whether the caller has definitely observed an error with the codec. + * The pool will also do basic correctness check on the codec itself. + */ public static void returnCodecSafely( - CompressionKind kind, CompressionCodec codec, boolean hasError) { + CompressionKind kind, CompressionCodec codec, boolean observedError) { try { - if (!hasError) { + if (!observedError) { returnCodec(kind, codec); } else { codec.close(); @@ -73,6 +80,12 @@ public final class OrcCodecPool { } } + /** + * Returns the codec to the pool, potentially failing if the codec cannot be reused, or if + * the codec is unneeded and cannot be closed. + * @param kind Compression kind. + * @param codec Codec. + */ public static void returnCodec(CompressionKind kind, CompressionCodec codec) { if (codec == null) { return; http://git-wip-us.apache.org/repos/asf/orc/blob/06c93b30/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java ---------------------------------------------------------------------- diff --git a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java index d7722d1..ff8dfd7 100644 --- a/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java +++ b/java/core/src/java/org/apache/orc/impl/RecordReaderImpl.java @@ -17,8 +17,6 @@ */ package org.apache.orc.impl; -import com.google.common.annotations.VisibleForTesting; - import org.apache.orc.CompressionKind; import java.io.IOException; import java.math.BigDecimal; @@ -1353,8 +1351,7 @@ public class RecordReaderImpl implements RecordReader { return result; } - // TODO: remove this - @VisibleForTesting + // TODO: pollutes the interface for tests only - we should remove this. public CompressionCodec getCompressionCodec() { return dataReader.getCompressionCodec(); } http://git-wip-us.apache.org/repos/asf/orc/blob/06c93b30/java/core/src/java/org/apache/orc/impl/WriterImpl.java ---------------------------------------------------------------------- diff --git a/java/core/src/java/org/apache/orc/impl/WriterImpl.java b/java/core/src/java/org/apache/orc/impl/WriterImpl.java index 343f565..0186445 100644 --- a/java/core/src/java/org/apache/orc/impl/WriterImpl.java +++ b/java/core/src/java/org/apache/orc/impl/WriterImpl.java @@ -18,8 +18,6 @@ package org.apache.orc.impl; -import com.google.common.annotations.VisibleForTesting; - import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -645,8 +643,7 @@ public class WriterImpl implements Writer, MemoryManager.Callback { return ReaderImpl.deserializeStats(builder.getStatisticsList()); } - // TODO: remove this - @VisibleForTesting + // TODO: pollutes the interface for tests only - we should remove this. public CompressionCodec getCompressionCodec() { return physicalWriter.getCompressionCodec(); }
