BZip2CompressorOutputStream.
This class is based on a Java port of Julian Seward's blocksort.c in his libbzip2
The Burrows-Wheeler transform is a reversible transform of the original data that is supposed to group similar bytes close to each other. The idea is to sort all permutations of the input and only keep the last byte of each permutation. E.g. for "Commons Compress" you'd get:
CompressCommons Commons Compress CompressCommons essCommons Compr mmons CompressCo mons CompressCom mpressCommons Co ns CompressCommo ommons CompressC ompressCommons C ons CompressComm pressCommons Com ressCommons Comp s CompressCommon sCommons Compres ssCommons Compre
Which results in a new text "ss romooCCmmpnse", in adition the index of the first line that contained the original text is kept - in this case it is 1. The idea is that in a long English text all permutations that start with "he" are likely suffixes of a "the" and thus they end in "t" leading to a larger block of "t"s that can better be compressed by the subsequent Move-to-Front, run-length und Huffman encoding steps.
For more information see for example:
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final int | |
| private int[] | |
| private static final int | |
| private static final int | |
| private boolean | |
| private final int[] | |
| private static final int | |
| private static final int[] | |
| private final boolean[] | |
| private final int[] | |
| private final int[] | |
| private static final int | |
| private final char[] | quadrant
Array instance identical to Data's sfmap, both are used only temporarily and indepently, so we do not need to allocate additional memory. |
| private static final int | |
| private static final int | |
| private final int[] | |
| private final int[] | |
| private final int[] | |
| private static final int | |
| private static final int | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| private void | fallbackQSort3(final int[]
points to the index of the starting point of a permutation inside the block of data in the current partially sorted order fmap, final int[] points from the index of a character inside the block to the first index in fmap that contains the bucket of its suffix that is sorted in
this step. eclass, final int lower boundary of the fmap-interval to be sorted loSt, final int upper boundary of the fmap-interval to be sorted hiSt)
|
| private void | fallbackSimpleSort(final int[]
points to the index of the starting point of a permutation inside the block of data in the current partially sorted order fmap, final int[] points from the index of a character inside the block to the first index in fmap that contains the bucket of its suffix that is sorted in
this step. eclass, final int lower boundary of the fmap-interval to be sorted lo, final int upper boundary of the fmap-interval to be sorted hi)
|
| pack-priv void | fallbackSort(final BZip2CompressorOutputStream.
Adapt fallbackSort to the expected interface of the rest of the code, in particular deal with the fact that block starts at offset 1 (in libbzip2 1.0.6 it starts at 0). |
| pack-priv void | fallbackSort(final int[]
points to the index of the starting point of a permutation inside the block of data in the current partially sorted order fmap, final byte[] the original data block, final int size of the block nblock)
|
| private int[] | |
| private void | |
| private void | |
| private void | fvswap(final int[] fmap, int yyp1, int yyp2, int yyn)
swaps two intervals starting at yyp1 and yyp2 of length yyn inside fmap. |
| private int[] | |
| private void | mainQSort3(final BZip2CompressorOutputStream.
Method "mainQSort3", file "blocksort.c", BZip2 1.0.2 |
| private boolean | mainSimpleSort(final BZip2CompressorOutputStream.
This is the most hammered method of this class. |
| pack-priv void | |
| private static int | |
| private static void |
| CLEARMASK | back to summary |
|---|---|
| private static final int CLEARMASK | |
| DEPTH_THRESH | back to summary |
|---|---|
| private static final int DEPTH_THRESH | |
| eclass | back to summary |
|---|---|
| private int[] eclass | |
| FALLBACK_QSORT_SMALL_THRESH | back to summary |
|---|---|
| private static final int FALLBACK_QSORT_SMALL_THRESH | |
| FALLBACK_QSORT_STACK_SIZE | back to summary |
|---|---|
| private static final int FALLBACK_QSORT_STACK_SIZE | |
| firstAttempt | back to summary |
|---|---|
| private boolean firstAttempt | |
| ftab | back to summary |
|---|---|
| private final int[] ftab | |
| FTAB_LENGTH | back to summary |
|---|---|
| private static final int FTAB_LENGTH | |
| INCS | back to summary |
|---|---|
| private static final int[] INCS | |
| mainSort_bigDone | back to summary |
|---|---|
| private final boolean[] mainSort_bigDone | |
| mainSort_copy | back to summary |
|---|---|
| private final int[] mainSort_copy | |
| mainSort_runningOrder | back to summary |
|---|---|
| private final int[] mainSort_runningOrder | |
| QSORT_STACK_SIZE | back to summary |
|---|---|
| private static final int QSORT_STACK_SIZE | |
| quadrant | back to summary |
|---|---|
| private final char[] quadrant Array instance identical to Data's sfmap, both are used only temporarily and indepently, so we do not need to allocate additional memory. | |
| SETMASK | back to summary |
|---|---|
| private static final int SETMASK | |
| SMALL_THRESH | back to summary |
|---|---|
| private static final int SMALL_THRESH | |
| stack_dd | back to summary |
|---|---|
| private final int[] stack_dd | |
| stack_hh | back to summary |
|---|---|
| private final int[] stack_hh | |
| stack_ll | back to summary |
|---|---|
| private final int[] stack_ll | |
| STACK_SIZE | back to summary |
|---|---|
| private static final int STACK_SIZE | |
| WORK_FACTOR | back to summary |
|---|---|
| private static final int WORK_FACTOR | |
| workDone | back to summary |
|---|---|
| private int workDone | |
| workLimit | back to summary |
|---|---|
| private int workLimit | |
| BlockSort | back to summary |
|---|---|
| pack-priv BlockSort(final BZip2CompressorOutputStream. | |
| blockSort | back to summary |
|---|---|
| pack-priv void blockSort(final BZip2CompressorOutputStream. | |
| fallbackQSort3 | back to summary |
|---|---|
private void fallbackQSort3(final int[] fmap, final int[] eclass, final int loSt, final int hiSt)
| |
| fallbackSimpleSort | back to summary |
|---|---|
private void fallbackSimpleSort(final int[] fmap, final int[] eclass, final int lo, final int hi)
| |
| fallbackSort | back to summary |
|---|---|
| pack-priv void fallbackSort(final BZip2CompressorOutputStream. Adapt fallbackSort to the expected interface of the rest of the code, in particular deal with the fact that block starts at offset 1 (in libbzip2 1.0.6 it starts at 0). | |
| fallbackSort | back to summary |
|---|---|
pack-priv void fallbackSort(final int[] fmap, final byte[] block, final int nblock)
| |
| fpop | back to summary |
|---|---|
| private int[] fpop(final int sp) | |
| fpush | back to summary |
|---|---|
| private void fpush(final int sp, final int lz, final int hz) | |
| fswap | back to summary |
|---|---|
| private void fswap(final int[] fmap, final int zz1, final int zz2) swaps two values in fmap | |
| fvswap | back to summary |
|---|---|
| private void fvswap(final int[] fmap, int yyp1, int yyp2, int yyn) swaps two intervals starting at yyp1 and yyp2 of length yyn inside fmap. | |
| getEclass | back to summary |
|---|---|
| private int[] getEclass() | |
| mainQSort3 | back to summary |
|---|---|
| private void mainQSort3(final BZip2CompressorOutputStream. Method "mainQSort3", file "blocksort.c", BZip2 1.0.2 | |
| mainSimpleSort | back to summary |
|---|---|
| private boolean mainSimpleSort(final BZip2CompressorOutputStream. This is the most hammered method of this class. This is the version using unrolled loops. Normally I never use such ones in Java code. The unrolling has shown a noticeable performance improvement on JRE 1.4.2 (Linux i586 / HotSpot Client). Of course it depends on the JIT compiler of the vm. | |
| mainSort | back to summary |
|---|---|
| pack-priv void mainSort(final BZip2CompressorOutputStream. | |
| med3 | back to summary |
|---|---|
| private static int med3(final int a, final int b, final int c) | |
| vswap | back to summary |
|---|---|
| private static void vswap(final int[] fmap, int p1, int p2, int n) | |