public class BZip2OutputStreamSettings extends Object implements Cloneable
BZip2OutputStream
.
When created, this object contains the default settings. Modify the settings by calling setter methods on this object.
BZip2OutputStream
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BLOCK_SIZE
The default block size.
|
static int |
DEFAULT_NO_OF_ENCODER_THREADS
The default number of encoder threads.
|
static int |
DEFAULT_NO_OF_HUFFMAN_TREE_REFINEMENT_ITERATIONS
The default number of Huffman tree refinement iterations.
|
static int |
MAX_BLOCK_SIZE
The maximum size of an encoded data block in hundreds of kilobytes.
|
static int |
MIN_BLOCK_SIZE
The minimum size of an encoded data block in hundreds of kilobytes.
|
Constructor and Description |
---|
BZip2OutputStreamSettings() |
Modifier and Type | Method and Description |
---|---|
BZip2OutputStreamSettings |
clone()
Make a copy of this object.
|
int |
getBlockSize()
Get the block size for a compressed data block.
|
BZip2EncoderExecutorService |
getExecutorService() |
org.entityfs.support.log.LogAdapter |
getLogAdapter()
Get the log adapter used for logging diagnostic output to.
|
int |
getNumberOfEncoderThreads() |
int |
getNumberOfHuffmanTreeRefinementIterations()
Get the number of Huffman tree refinement iterations.
|
BZip2OutputStreamSettings |
setBlockSize(int bs)
Set the size of compressed data blocks.
|
BZip2OutputStreamSettings |
setExecutorService(BZip2EncoderExecutorService executorService)
Set an executor service that the
BZip2OutputStream will use to
spread the encoding over several threads. |
BZip2OutputStreamSettings |
setLogAdapter(org.entityfs.support.log.LogAdapter la)
Set a
LogAdapter for logging diagnostic output to. |
BZip2OutputStreamSettings |
setNumberOfEncoderThreads(int no)
Set the number of encoder threads used for bzip2 compressing data.
|
BZip2OutputStreamSettings |
setNumberOfHuffmanTreeRefinementIterations(int no)
Set the number of tree refinement iterations that are run when creating
Huffman trees for each compressed data block.
|
public static final int MIN_BLOCK_SIZE
public static final int MAX_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZE
public static final int DEFAULT_NO_OF_HUFFMAN_TREE_REFINEMENT_ITERATIONS
public static final int DEFAULT_NO_OF_ENCODER_THREADS
public BZip2OutputStreamSettings setBlockSize(int bs) throws IllegalArgumentException
The default block size is 9 (the highest permitted value).
bs
- The block size in hundreds of kilobytes. This should be between
1 and 9 (inclusive).this
IllegalArgumentException
- If the block size is not in the
permitted range.public int getBlockSize()
public BZip2OutputStreamSettings setNumberOfHuffmanTreeRefinementIterations(int no) throws IllegalArgumentException
A higher value for this parameter should give better but slower compression. As the value increases the returns are diminishing.
The default value is five refinement iterations.
no
- The number of Huffman tree refinement iterations. This should
be a positive integer larger than zero.this
IllegalArgumentException
- If the number is not a positive integer
larger than zero.public int getNumberOfHuffmanTreeRefinementIterations()
public BZip2OutputStreamSettings setLogAdapter(org.entityfs.support.log.LogAdapter la)
LogAdapter
for logging diagnostic output to. Output is
logged to the debug and trace levels.
By default no log adapter is used and hence no diagnostic output is logged.
la
- A log adapter.this
public org.entityfs.support.log.LogAdapter getLogAdapter()
null
if no log adapter is set.public BZip2OutputStreamSettings setNumberOfEncoderThreads(int no) throws IllegalArgumentException
The default number of encoder threads is zero, which means that the
thread that is writing the data to the BZip2OutputStream
will be
used for the encoding.
For the shortest encoding time, use as many threads as there are available CPU:s in the system.
no
- The number of encoder threads to use. If this is set to 0
, the encoding will be done in the thread writing to the stream.this
IllegalArgumentException
- If no
is negative.setExecutorService(BZip2EncoderExecutorService)
public int getNumberOfEncoderThreads()
public BZip2OutputStreamSettings setExecutorService(BZip2EncoderExecutorService executorService)
BZip2OutputStream
will use to
spread the encoding over several threads. This executor can be shared
among several BZip2OutputStream
objects.
If an executor service is set using this method, all threads that are
available to the executor is used for the encoding and any value set
using setNumberOfEncoderThreads(int)
is ignored.
An executor service is created using the
BZip2OutputStream.createExecutorService()
or the
BZip2OutputStream.createExecutorService(int)
method.
executorService
- The executor service.this
setNumberOfEncoderThreads(int)
public BZip2EncoderExecutorService getExecutorService()
public BZip2OutputStreamSettings clone()