Skip to content

Commit 3c6fc7c

Browse files
committed
Remove UncompressibleInputException
Since we can now calculate the maximum compressed length, there is no longer a need to handle underestimated output array lengths by throwing this exception.
1 parent 76acd69 commit 3c6fc7c

File tree

4 files changed

+3
-45
lines changed

4 files changed

+3
-45
lines changed

src/main/java/me/lemire/integercompression/IntCompressor.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,14 @@ public IntCompressor() {
3333
*
3434
* @param input array to be compressed
3535
* @return compressed array
36-
* @throws UncompressibleInputException if the data is too poorly compressible
3736
*/
3837
public int[] compress(int[] input) {
3938
int maxCompressedLength = codec.maxHeadlessCompressedLength(new IntWrapper(0), input.length);
4039
int[] compressed = new int[maxCompressedLength];
4140
// Store at index=0 the length of the input, hence enabling .headlessCompress
4241
compressed[0] = input.length;
4342
IntWrapper outpos = new IntWrapper(1);
44-
try {
45-
codec.headlessCompress(input, new IntWrapper(0),
46-
input.length, compressed, outpos);
47-
} catch (IndexOutOfBoundsException ioebe) {
48-
throw new
49-
UncompressibleInputException("Your input is too poorly compressible "
50-
+ "with the current codec : "+codec);
51-
}
43+
codec.headlessCompress(input, new IntWrapper(0), input.length, compressed, outpos);
5244
compressed = Arrays.copyOf(compressed,outpos.intValue());
5345
return compressed;
5446
}

src/main/java/me/lemire/integercompression/UncompressibleInputException.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/me/lemire/integercompression/differential/IntegratedIntCompressor.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.Arrays;
44

55
import me.lemire.integercompression.IntWrapper;
6-
import me.lemire.integercompression.UncompressibleInputException;
76

87
/**
98
* This is a convenience class that wraps a codec to provide
@@ -36,20 +35,14 @@ public IntegratedIntCompressor() {
3635
*
3736
* @param input array to be compressed
3837
* @return compressed array
39-
* @throws UncompressibleInputException if the data is too poorly compressible
4038
*/
4139
public int[] compress(int[] input) {
4240
int maxCompressedLength = codec.maxHeadlessCompressedLength(new IntWrapper(0), input.length);
4341
int [] compressed = new int[maxCompressedLength];
4442
compressed[0] = input.length;
4543
IntWrapper outpos = new IntWrapper(1);
4644
IntWrapper initvalue = new IntWrapper(0);
47-
try {
48-
codec.headlessCompress(input, new IntWrapper(0), input.length, compressed, outpos, initvalue);
49-
} catch (IndexOutOfBoundsException ioebe) {
50-
throw new UncompressibleInputException(
51-
"Your input is too poorly compressible with the current codec : " + codec);
52-
}
45+
codec.headlessCompress(input, new IntWrapper(0), input.length, compressed, outpos, initvalue);
5346
compressed = Arrays.copyOf(compressed,outpos.intValue());
5447
return compressed;
5548
}

src/main/java/me/lemire/longcompression/LongCompressor.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.Arrays;
44

55
import me.lemire.integercompression.IntWrapper;
6-
import me.lemire.integercompression.UncompressibleInputException;
76

87
/**
98
* This is a convenience class that wraps a codec to provide
@@ -37,21 +36,14 @@ public LongCompressor() {
3736
*
3837
* @param input array to be compressed
3938
* @return compressed array
40-
* @throws UncompressibleInputException if the data is too poorly compressible
4139
*/
4240
public long[] compress(long[] input) {
4341
int maxCompressedLength = codec.maxHeadlessCompressedLength(new IntWrapper(0), input.length);
4442
long[] compressed = new long[maxCompressedLength];
4543
// Store at index=0 the length of the input, hence enabling .headlessCompress
4644
compressed[0] = input.length;
4745
IntWrapper outpos = new IntWrapper(1);
48-
try {
49-
codec.headlessCompress(input, new IntWrapper(0),
50-
input.length, compressed, outpos);
51-
} catch (IndexOutOfBoundsException ioebe) {
52-
throw new UncompressibleInputException("Your input is too poorly compressible "
53-
+ "with the current codec : "+codec);
54-
}
46+
codec.headlessCompress(input, new IntWrapper(0), input.length, compressed, outpos);
5547
compressed = Arrays.copyOf(compressed,outpos.intValue());
5648
return compressed;
5749
}

0 commit comments

Comments
 (0)