Top Description Inners Fields Constructors Methods
org.apache.commons.compress.harmony.pack200

public abstract Class BandSet

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.compress.harmony.pack200.BcBands, org.apache.commons.compress.harmony.pack200.ClassBands, org.apache.commons.compress.harmony.pack200.CpBands, org.apache.commons.compress.harmony.pack200.FileBands, org.apache.commons.compress.harmony.pack200.IcBands, org.apache.commons.compress.harmony.pack200.MetadataBandGroup, org.apache.commons.compress.harmony.pack200.NewAttributeBands, org.apache.commons.compress.harmony.pack200.SegmentHeader, org.apache.commons.compress.harmony.pack200.AttributeDefinitionBands
Imports
java.io.IOException, .OutputStream, java.util.ArrayList, .Arrays, .HashMap, .List, .Map, java.util.stream.IntStream

Abstract superclass for a set of bands

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
BandSet.BandAnalysisResults

Results obtained by trying different Codecs to encode a band

public class
BandSet.BandData

BandData represents information about a band, e.g. largest value etc and is used in the heuristics that calculate whether an alternative Codec could make the encoded band smaller.

Field Summary

Modifier and TypeField and Description
private long[]
private long[]
pack-priv final int
private static final int[]
private static final byte[]
protected final SegmentHeader

Constructor Summary

AccessConstructor and Description
public
BandSet(final int
- the packing effort to be used (must be 1-9)
effort
,
final SegmentHeader
- the segment header
header
)

Constructs a new BandSet.

Method Summary

Modifier and TypeMethod and Description
private BandSet.BandAnalysisResults
analyseBand(final String name, final int[] band, final BHSDCodec defaultCodec)

protected int[]

Returns:

conversion result.
cpEntryListToArray
(final List<? extends ConstantPoolEntry>
conversion source.
list
)

Converts a list of ConstantPoolEntrys to an int[] array of their indices

protected int[]

Returns:

conversion result.
cpEntryOrNullListToArray
(final List<? extends ConstantPoolEntry>
conversion source.
list
)

Converts a list of ConstantPoolEntrys or nulls to an int[] array of their indices +1 (or 0 for nulls)

public byte[]

Returns:

the encoded band
encodeBandInt
(final String
- name of the band (used for debugging)
name
,
final int[]
- the band
ints
,
final BHSDCodec
- the default Codec
defaultCodec
)

Encode a band of integers.

protected byte[]

Returns:

the encoded band
encodeFlags
(final String
- name of the band (for debugging purposes)
name
,
final long[]
- the band
flags
,
final BHSDCodec
- Codec for the low 32-bits band
loCodec
,
final BHSDCodec
- Codec for the high 32-bits band
hiCodec
,
final boolean
- ignores the high band if true as all values would be zero
haveHiFlags
)

Encode a band of longs (values are split into their high and low 32 bits and then encoded as two separate bands

protected byte[]
encodeFlags(final String name, final long[][] flags, final BHSDCodec loCodec, final BHSDCodec hiCodec, final boolean haveHiFlags)

public byte[]

Returns:

the encoded value
encodeScalar
(final int
- the value to encode
value
,
final BHSDCodec
- Codec to use
codec
)

Encode a single value with the given Codec

public byte[]

Returns:

the encoded band
encodeScalar
(final int[]
- the band
band
,
final BHSDCodec
- the Codec to use
codec
)

Encode a band without considering other Codecs

private void
encodeWithPopulationCodec(final String name, final int[] band, final BHSDCodec defaultCodec, final BandSet.BandData bandData, final BandSet.BandAnalysisResults results)

private long[]
flatten(final long[][] flags)

protected int[]

Returns:

conversion result.
integerListToArray
(final List<Integer>
conversion source.
integerList
)

Converts a list of Integers to an int[] array.

protected long[]

Returns:

conversion result.
longListToArray
(final List<Long>
conversion source.
longList
)

Converts a list of Longs to an long[] array.

public abstract void
pack(OutputStream
TODO
out
)

Write the packed set of bands to the given output stream

private boolean
private void
tryCodecs(final String name, final int[] band, final BHSDCodec defaultCodec, final BandSet.BandData bandData, final BandSet.BandAnalysisResults results, final byte[] encoded, final BHSDCodec[] potentialCodecs)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canonicalLargestback to summary
private long[] canonicalLargest
canonicalSmallestback to summary
private long[] canonicalSmallest
effortback to summary
pack-priv final int effort
effortThresholdsback to summary
private static final int[] effortThresholds
EMPTY_BYTE_ARRAYback to summary
private static final byte[] EMPTY_BYTE_ARRAY
segmentHeaderback to summary
protected final SegmentHeader segmentHeader

Constructor Detail

BandSetback to summary
public BandSet(final int effort, final SegmentHeader header)

Constructs a new BandSet.

Parameters
effort:int

- the packing effort to be used (must be 1-9)

header:SegmentHeader

- the segment header

Method Detail

analyseBandback to summary
private BandSet.BandAnalysisResults analyseBand(final String name, final int[] band, final BHSDCodec defaultCodec) throws Pack200Exception
cpEntryListToArrayback to summary
protected int[] cpEntryListToArray(final List<? extends ConstantPoolEntry> list)

Converts a list of ConstantPoolEntrys to an int[] array of their indices

Parameters
list:List<? extends ConstantPoolEntry>

conversion source.

Returns:int[]

conversion result.

cpEntryOrNullListToArrayback to summary
protected int[] cpEntryOrNullListToArray(final List<? extends ConstantPoolEntry> list)

Converts a list of ConstantPoolEntrys or nulls to an int[] array of their indices +1 (or 0 for nulls)

Parameters
list:List<? extends ConstantPoolEntry>

conversion source.

Returns:int[]

conversion result.

encodeBandIntback to summary
public byte[] encodeBandInt(final String name, final int[] ints, final BHSDCodec defaultCodec) throws Pack200Exception

Encode a band of integers. The default codec may be used, but other Codecs are considered if effort is greater than 1.

Parameters
name:String

- name of the band (used for debugging)

ints:int[]

- the band

defaultCodec:BHSDCodec

- the default Codec

Returns:byte[]

the encoded band

Exceptions
Pack200Exception:
TODO
encodeFlagsback to summary
protected byte[] encodeFlags(final String name, final long[] flags, final BHSDCodec loCodec, final BHSDCodec hiCodec, final boolean haveHiFlags) throws Pack200Exception

Encode a band of longs (values are split into their high and low 32 bits and then encoded as two separate bands

Parameters
name:String

- name of the band (for debugging purposes)

flags:long[]

- the band

loCodec:BHSDCodec

- Codec for the low 32-bits band

hiCodec:BHSDCodec

- Codec for the high 32-bits band

haveHiFlags:boolean

- ignores the high band if true as all values would be zero

Returns:byte[]

the encoded band

Exceptions
Pack200Exception:
TODO
encodeFlagsback to summary
protected byte[] encodeFlags(final String name, final long[][] flags, final BHSDCodec loCodec, final BHSDCodec hiCodec, final boolean haveHiFlags) throws Pack200Exception
encodeScalarback to summary
public byte[] encodeScalar(final int value, final BHSDCodec codec) throws Pack200Exception

Encode a single value with the given Codec

Parameters
value:int

- the value to encode

codec:BHSDCodec

- Codec to use

Returns:byte[]

the encoded value

Exceptions
Pack200Exception:
TODO
encodeScalarback to summary
public byte[] encodeScalar(final int[] band, final BHSDCodec codec) throws Pack200Exception

Encode a band without considering other Codecs

Parameters
band:int[]

- the band

codec:BHSDCodec

- the Codec to use

Returns:byte[]

the encoded band

Exceptions
Pack200Exception:
TODO
encodeWithPopulationCodecback to summary
private void encodeWithPopulationCodec(final String name, final int[] band, final BHSDCodec defaultCodec, final BandSet.BandData bandData, final BandSet.BandAnalysisResults results) throws Pack200Exception
flattenback to summary
private long[] flatten(final long[][] flags)
integerListToArrayback to summary
protected int[] integerListToArray(final List<Integer> integerList)

Converts a list of Integers to an int[] array.

Parameters
integerList:List<Integer>

conversion source.

Returns:int[]

conversion result.

longListToArrayback to summary
protected long[] longListToArray(final List<Long> longList)

Converts a list of Longs to an long[] array.

Parameters
longList:List<Long>

conversion source.

Returns:long[]

conversion result.

packback to summary
public abstract void pack(OutputStream out) throws IOException, Pack200Exception

Write the packed set of bands to the given output stream

Parameters
out:OutputStream

TODO

Exceptions
IOException:
If an I/O error occurs.
Pack200Exception:
TODO
timeToStopback to summary
private boolean timeToStop(final BandSet.BandAnalysisResults results)
tryCodecsback to summary
private void tryCodecs(final String name, final int[] band, final BHSDCodec defaultCodec, final BandSet.BandData bandData, final BandSet.BandAnalysisResults results, final byte[] encoded, final BHSDCodec[] potentialCodecs) throws Pack200Exception
org.apache.commons.compress.harmony.pack200 back to summary

public Class BandSet.BandAnalysisResults

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.compress.harmony.pack200.BandSet.BandAnalysisResults

Results obtained by trying different Codecs to encode a band

Field Summary

Modifier and TypeField and Description
private Codec
private byte[]
private int[]
private int
private int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

betterCodecback to summary
private Codec betterCodec
encodedBandback to summary
private byte[] encodedBand
extraMetadataback to summary
private int[] extraMetadata
numCodecsTriedback to summary
private int numCodecsTried
savedback to summary
private int saved

Constructor Detail

BandAnalysisResultsback to summary
public BandAnalysisResults()
org.apache.commons.compress.harmony.pack200 back to summary

public Class BandSet.BandData

extends Object
Class Inheritance

BandData represents information about a band, e.g. largest value etc and is used in the heuristics that calculate whether an alternative Codec could make the encoded band smaller.

Field Summary

Modifier and TypeField and Description
private double
private double
private final int[]
private int
private Map<Integer, Integer>
private int
private int
private int
private int
private int

Constructor Summary

AccessConstructor and Description
public
BandData(final int[]
- the band of integers
band
)

Constructs a new instance of BandData.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if any band elements are negative.
anyNegatives
()

Returns true if any band elements are negative.

public boolean

Returns:

true if the band deltas are mainly positive (heuristic).
mainlyPositiveDeltas
()

Returns true if the band deltas are mainly positive (heuristic).

public boolean

Returns:

true if the deltas between adjacent band elements are mainly small (heuristic).
mainlySmallDeltas
()

Returns true if the deltas between adjacent band elements are mainly small (heuristic).

public int

Returns:

the total number of distinct values found in the band.
numDistinctValues
()

Returns the total number of distinct values found in the band.

public boolean

Returns:

true if the band is well correlated (i.e. would be suitable for a delta encoding) (heuristic).
wellCorrelated
()

Returns true if the band is well correlated (i.e. would be suitable for a delta encoding) (heuristic).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

averageAbsoluteDeltaback to summary
private double averageAbsoluteDelta
averageAbsoluteValueback to summary
private double averageAbsoluteValue
bandback to summary
private final int[] band
deltaIsAscendingback to summary
private int deltaIsAscending
distinctValuesback to summary
private Map<Integer, Integer> distinctValues
largestback to summary
private int largest
largestDeltaback to summary
private int largestDelta
smallDeltaCountback to summary
private int smallDeltaCount
smallestback to summary
private int smallest
smallestDeltaback to summary
private int smallestDelta

Constructor Detail

BandDataback to summary
public BandData(final int[] band)

Constructs a new instance of BandData. The band is then analysed.

Parameters
band:int[]

- the band of integers

Method Detail

anyNegativesback to summary
public boolean anyNegatives()

Returns true if any band elements are negative.

Returns:boolean

true if any band elements are negative.

mainlyPositiveDeltasback to summary
public boolean mainlyPositiveDeltas()

Returns true if the band deltas are mainly positive (heuristic).

Returns:boolean

true if the band deltas are mainly positive (heuristic).

mainlySmallDeltasback to summary
public boolean mainlySmallDeltas()

Returns true if the deltas between adjacent band elements are mainly small (heuristic).

Returns:boolean

true if the deltas between adjacent band elements are mainly small (heuristic).

numDistinctValuesback to summary
public int numDistinctValues()

Returns the total number of distinct values found in the band.

Returns:int

the total number of distinct values found in the band.

wellCorrelatedback to summary
public boolean wellCorrelated()

Returns true if the band is well correlated (i.e. would be suitable for a delta encoding) (heuristic).

Returns:boolean

true if the band is well correlated (i.e. would be suitable for a delta encoding) (heuristic).