LUCENE-9246: Remove `dOff` argument from `LZ4#decompress`. (#1283)

It is always set to 0 at call sites.
This commit is contained in:
Adrien Grand 2020-02-28 11:26:56 +01:00 committed by GitHub
parent e0164d1ac8
commit ebdfdaed9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 4 deletions

View File

@ -48,7 +48,7 @@ enum CompressionAlgorithm {
@Override
void read(DataInput in, byte[] out, int len) throws IOException {
org.apache.lucene.util.compress.LZ4.decompress(in, len, out, 0);
org.apache.lucene.util.compress.LZ4.decompress(in, len, out);
}
};

View File

@ -136,7 +136,7 @@ public abstract class CompressionMode {
if (bytes.bytes.length < originalLength + 7) {
bytes.bytes = new byte[ArrayUtil.oversize(originalLength + 7, 1)];
}
final int decompressedLength = LZ4.decompress(in, offset + length, bytes.bytes, 0);
final int decompressedLength = LZ4.decompress(in, offset + length, bytes.bytes);
if (decompressedLength > originalLength) {
throw new CorruptIndexException("Corrupted: lengths mismatch: " + decompressedLength + " > " + originalLength, in);
}

View File

@ -832,7 +832,7 @@ final class Lucene80DocValuesProducer extends DocValuesProducer implements Close
}
assert uncompressedBlockLength <= uncompressedBlock.length;
LZ4.decompress(compressedData, uncompressedBlockLength, uncompressedBlock, 0);
LZ4.decompress(compressedData, uncompressedBlockLength, uncompressedBlock);
}
uncompressedBytesRef.offset = uncompressedDocStarts[docInBlockId];

View File

@ -82,7 +82,8 @@ public final class LZ4 {
* enough to be able to hold <b>all</b> decompressed data (meaning that you
* need to know the total decompressed length).
*/
public static int decompress(DataInput compressed, int decompressedLen, byte[] dest, int dOff) throws IOException {
public static int decompress(DataInput compressed, int decompressedLen, byte[] dest) throws IOException {
int dOff = 0;
final int destEnd = dest.length;
do {

View File

@ -20,7 +20,9 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Random;
import org.apache.lucene.store.ByteArrayDataInput;
import org.apache.lucene.store.ByteBuffersDataOutput;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil;
@ -130,6 +132,11 @@ public abstract class LZ4TestCase extends LuceneTestCase {
ByteBuffersDataOutput out2 = new ByteBuffersDataOutput();
LZ4.compress(data, offset, length, out2, hashTable);
assertArrayEquals(compressed, out2.toArrayCopy());
// Now restore and compare bytes
byte[] restored = new byte[length + random().nextInt(10)];
LZ4.decompress(new ByteArrayDataInput(compressed), length, restored);
assertArrayEquals(ArrayUtil.copyOfSubArray(data, offset, offset+length), ArrayUtil.copyOfSubArray(restored, 0, length));
}
public void testEmpty() throws IOException {