Skip to content

Commit de8bdbd

Browse files
authored
Merge pull request #73 from PHJ2000/fix-byte-decoder-input-offset
Fix byte decoder input positions for nonzero offsets
2 parents 982df74 + 7283fe0 commit de8bdbd

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎src/main/java/me/lemire/integercompression/VariableByte.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void uncompress(byte[] in, IntWrapper inpos, int inlength,
173173
p += 5;
174174
}
175175
outpos.set(tmpoutpos);
176-
inpos.add(p);
176+
inpos.set(p);
177177
}
178178

179179
@Override

‎src/main/java/me/lemire/integercompression/differential/IntegratedVariableByte.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void uncompress(byte[] in, IntWrapper inpos, int inlength,
174174
p+= 5;
175175
}
176176
outpos.set(tmpoutpos);
177-
inpos.add(p);
177+
inpos.set(p);
178178
}
179179

180180
@Override

‎src/test/java/me/lemire/integercompression/ByteBasicTest.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,26 @@ public void saulTest() {
5151
System.out.println("Problem with "+C);
5252
}
5353
assertArrayEquals(a, c);
54+
assertEquals(C.toString(), x + len, bOffset.get());
55+
assertEquals(C.toString(), a.length, cOffset.get());
5456
}
5557
}
5658
}
59+
@Test
60+
public void emptyInputPreservesOffsets() {
61+
for (ByteIntegerCODEC codec : codecs) {
62+
IntWrapper inpos = new IntWrapper(5);
63+
IntWrapper outpos = new IntWrapper(2);
64+
int[] output = { 10, 20, 30 };
65+
66+
codec.uncompress(new byte[5], inpos, 0, output, outpos);
67+
68+
assertEquals(codec.toString(), 5, inpos.get());
69+
assertEquals(codec.toString(), 2, outpos.get());
70+
assertArrayEquals(new int[] { 10, 20, 30 }, output);
71+
}
72+
}
73+
5774
/**
5875
*
5976
*/

0 commit comments

Comments
 (0)