int[] band;
// Useful for debugging
// if(count > 0) {
// System.out.println("decoding " + name + " " + count);
// }
Codec codecUsed = codec;
if (codec.getB() == 1 || count == 0) {
return codec.decodeInts(count, in);
}
int[] getFirst = codec.decodeInts(1, in);
if (getFirst.length == 0) {
return getFirst;
}
int first = getFirst[0];
if (codec.isSigned() && first >= -256 && first <= -1) {
// Non-default codec should be used
codecUsed = CodecEncoding.getCodec((-1 - first), header
.getBandHeadersInputStream(), codec);
band = codecUsed.decodeInts(count, in);
} else if (!codec.isSigned() && first >= codec.getL()
&& first <= codec.getL() + 255) {
// Non-default codec should be used
codecUsed = CodecEncoding.getCodec(first - codec.getL(), header
.getBandHeadersInputStream(), codec);
band = codecUsed.decodeInts(count, in);
} else {
// First element should not be discarded
band = codec.decodeInts(count - 1, in, first);
}
// Useful for debugging -E options:
//if(!codecUsed.equals(codec)) {
// int bytes = codecUsed.lastBandLength;
// System.out.println(count + " " + name + " encoded with " + codecUsed + " " + bytes);
//}
if (codecUsed instanceof PopulationCodec) {
PopulationCodec popCodec = (PopulationCodec) codecUsed;
int[] favoured = (int[]) popCodec.getFavoured().clone();
Arrays.sort(favoured);
for (int i = 0; i < band.length; i++) {
boolean favouredValue = Arrays.binarySearch(favoured, band[i]) > -1;
Codec theCodec = favouredValue ? popCodec.getFavouredCodec()
: popCodec.getUnfavouredCodec();
if (theCodec instanceof BHSDCodec
&& ((BHSDCodec) theCodec).isDelta()) {
BHSDCodec bhsd = (BHSDCodec) theCodec;
long cardinality = bhsd.cardinality();