Date: Thu, 24 Oct 2019 15:06:48 -0500
Subject: [PATCH 2/3] Remove use of google VisibleForTesting annotation
https://github.com/xerial/snappy-java/issues/233
---
src/main/java/org/xerial/snappy/pool/CachingBufferPool.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/xerial/snappy/pool/CachingBufferPool.java b/src/main/java/org/xerial/snappy/pool/CachingBufferPool.java
index 7f0665ad..80232e33 100644
--- a/src/main/java/org/xerial/snappy/pool/CachingBufferPool.java
+++ b/src/main/java/org/xerial/snappy/pool/CachingBufferPool.java
@@ -6,8 +6,6 @@
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentMap;
-import com.google.common.annotations.VisibleForTesting;
-
/**
* A {@link BufferPool} implementation which caches values at fixed sizes.
*
@@ -127,7 +125,9 @@ private static E getOrCreate(final int size, final ConcurrentMap 0;
From ee8796228a3469d2fb9222475f0eb64fb10cc7f0 Mon Sep 17 00:00:00 2001
From: Brett Okken
Date: Mon, 28 Oct 2019 07:26:00 -0500
Subject: [PATCH 3/3] javadoc
---
.../snappy/SnappyFramedInputStream.java | 28 ++++++++++-
.../snappy/SnappyFramedOutputStream.java | 50 +++++++++++++++++--
.../org/xerial/snappy/pool/BufferPool.java | 5 ++
3 files changed, 78 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java b/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java
index 8be6cbb0..d96b866d 100644
--- a/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java
+++ b/src/main/java/org/xerial/snappy/SnappyFramedInputStream.java
@@ -83,8 +83,12 @@ public final class SnappyFramedInputStream
/**
* Creates a Snappy input stream to read data from the specified underlying
* input stream.
- *
- * @param in the underlying input stream. Must not be {@code null}.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
+ *
+ * @param in the underlying input stream. Must not be {@code null}.
+ * @throws IOException
*/
public SnappyFramedInputStream(InputStream in)
throws IOException
@@ -97,6 +101,8 @@ public SnappyFramedInputStream(InputStream in)
* input stream.
*
* @param in the underlying input stream. Must not be {@code null}.
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
*/
public SnappyFramedInputStream(InputStream in, BufferPool bufferPool)
throws IOException
@@ -107,9 +113,13 @@ public SnappyFramedInputStream(InputStream in, BufferPool bufferPool)
/**
* Creates a Snappy input stream to read data from the specified underlying
* input stream.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
*
* @param in the underlying input stream. Must not be {@code null}.
* @param verifyChecksums if true, checksums in input stream will be verified
+ * @throws IOException
*/
public SnappyFramedInputStream(InputStream in, boolean verifyChecksums)
throws IOException
@@ -123,6 +133,8 @@ public SnappyFramedInputStream(InputStream in, boolean verifyChecksums)
*
* @param in the underlying input stream. Must not be {@code null}.
* @param verifyChecksums if true, checksums in input stream will be verified
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
*/
public SnappyFramedInputStream(InputStream in, boolean verifyChecksums,
BufferPool bufferPool)
@@ -136,6 +148,8 @@ public SnappyFramedInputStream(InputStream in, boolean verifyChecksums,
* channel.
*
* @param in the underlying readable channel. Must not be {@code null}.
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
*/
public SnappyFramedInputStream(ReadableByteChannel in, BufferPool bufferPool)
throws IOException
@@ -146,8 +160,12 @@ public SnappyFramedInputStream(ReadableByteChannel in, BufferPool bufferPool)
/**
* Creates a Snappy input stream to read data from the specified underlying
* channel.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
*
* @param in the underlying readable channel. Must not be {@code null}.
+ * @throws IOException
*/
public SnappyFramedInputStream(ReadableByteChannel in)
throws IOException
@@ -158,9 +176,13 @@ public SnappyFramedInputStream(ReadableByteChannel in)
/**
* Creates a Snappy input stream to read data from the specified underlying
* channel.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
*
* @param in the underlying readable channel. Must not be {@code null}.
* @param verifyChecksums if true, checksums in input stream will be verified
+ * @throws IOException
*/
public SnappyFramedInputStream(ReadableByteChannel in,
boolean verifyChecksums)
@@ -175,6 +197,8 @@ public SnappyFramedInputStream(ReadableByteChannel in,
*
* @param in the underlying readable channel. Must not be {@code null}.
* @param verifyChecksums if true, checksums in input stream will be verified
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
*/
public SnappyFramedInputStream(ReadableByteChannel in,
boolean verifyChecksums, BufferPool bufferPool)
diff --git a/src/main/java/org/xerial/snappy/SnappyFramedOutputStream.java b/src/main/java/org/xerial/snappy/SnappyFramedOutputStream.java
index 6d17776e..6797b6c4 100644
--- a/src/main/java/org/xerial/snappy/SnappyFramedOutputStream.java
+++ b/src/main/java/org/xerial/snappy/SnappyFramedOutputStream.java
@@ -76,6 +76,9 @@ public final class SnappyFramedOutputStream
/**
* Creates a new {@link SnappyFramedOutputStream} using the {@link #DEFAULT_BLOCK_SIZE}
* and {@link #DEFAULT_MIN_COMPRESSION_RATIO}.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
*
* @param out The underlying {@link OutputStream} to write to. Must not be
* {@code null}.
@@ -84,9 +87,18 @@ public final class SnappyFramedOutputStream
public SnappyFramedOutputStream(OutputStream out)
throws IOException
{
- this(out, DEFAULT_BLOCK_SIZE, DEFAULT_MIN_COMPRESSION_RATIO);
+ this(out, DEFAULT_BLOCK_SIZE, DEFAULT_MIN_COMPRESSION_RATIO, DefaultPoolFactory.getDefaultPool());
}
+ /**
+ * Creates a new {@link SnappyFramedOutputStream} using the {@link #DEFAULT_BLOCK_SIZE}
+ * and {@link #DEFAULT_MIN_COMPRESSION_RATIO}.
+ *
+ * @param out The underlying {@link OutputStream} to write to. Must not be
+ * {@code null}.
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
+ */
public SnappyFramedOutputStream(OutputStream out, BufferPool bufferPool)
throws IOException
{
@@ -95,6 +107,9 @@ public SnappyFramedOutputStream(OutputStream out, BufferPool bufferPool)
/**
* Creates a new {@link SnappyFramedOutputStream} instance.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
*
* @param out The underlying {@link OutputStream} to write to. Must not be
* {@code null}.
@@ -109,9 +124,22 @@ public SnappyFramedOutputStream(OutputStream out, int blockSize,
double minCompressionRatio)
throws IOException
{
- this(Channels.newChannel(out), blockSize, minCompressionRatio);
+ this(Channels.newChannel(out), blockSize, minCompressionRatio, DefaultPoolFactory.getDefaultPool());
}
+ /**
+ * Creates a new {@link SnappyFramedOutputStream} instance.
+ *
+ * @param out The underlying {@link OutputStream} to write to. Must not be
+ * {@code null}.
+ * @param blockSize The block size (of raw data) to compress before writing frames
+ * to out. Must be in (0, 65536].
+ * @param minCompressionRatio Defines the minimum compression ratio (
+ * {@code compressedLength / rawLength}) that must be achieved to
+ * write the compressed data. This must be in (0, 1.0].
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
+ */
public SnappyFramedOutputStream(OutputStream out, int blockSize,
double minCompressionRatio, BufferPool bufferPool)
throws IOException
@@ -122,6 +150,9 @@ public SnappyFramedOutputStream(OutputStream out, int blockSize,
/**
* Creates a new {@link SnappyFramedOutputStream} using the
* {@link #DEFAULT_BLOCK_SIZE} and {@link #DEFAULT_MIN_COMPRESSION_RATIO}.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
*
* @param out The underlying {@link WritableByteChannel} to write to. Must
* not be {@code null}.
@@ -131,9 +162,21 @@ public SnappyFramedOutputStream(OutputStream out, int blockSize,
public SnappyFramedOutputStream(WritableByteChannel out)
throws IOException
{
- this(out, DEFAULT_BLOCK_SIZE, DEFAULT_MIN_COMPRESSION_RATIO);
+ this(out, DEFAULT_BLOCK_SIZE, DEFAULT_MIN_COMPRESSION_RATIO, DefaultPoolFactory.getDefaultPool());
}
+ /**
+ * Creates a new {@link SnappyFramedOutputStream} using the
+ * {@link #DEFAULT_BLOCK_SIZE} and {@link #DEFAULT_MIN_COMPRESSION_RATIO}.
+ *
+ * Uses {@link DefaultPoolFactory} to obtain {@link BufferPool} for buffers.
+ *
+ *
+ * @param out The underlying {@link WritableByteChannel} to write to. Must
+ * not be {@code null}.
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
+ * @throws IOException
+ */
public SnappyFramedOutputStream(WritableByteChannel out, BufferPool bufferPool)
throws IOException
{
@@ -170,6 +213,7 @@ public SnappyFramedOutputStream(WritableByteChannel out, int blockSize,
* @param minCompressionRatio Defines the minimum compression ratio (
* {@code compressedLength / rawLength}) that must be achieved to
* write the compressed data. This must be in (0, 1.0].
+ * @param bufferPool Used to obtain buffer instances. Must not be {@code null}.
* @throws IOException
* @since 1.1.1
*/
diff --git a/src/main/java/org/xerial/snappy/pool/BufferPool.java b/src/main/java/org/xerial/snappy/pool/BufferPool.java
index bf21198f..ae39a767 100644
--- a/src/main/java/org/xerial/snappy/pool/BufferPool.java
+++ b/src/main/java/org/xerial/snappy/pool/BufferPool.java
@@ -4,6 +4,11 @@
/**
* Makes various types of buffers available for use and potential re-use.
+ *
+ *
+ * Implementations must be safe for concurrent use by multiple threads.
+ *
+ *
* @author Brett Okken
*/
public interface BufferPool {