Skip to content

Commit 46b8fa7

Browse files
committed
GH-4950 LMDB: use additional zigzag encoding for double exponents
1 parent 3ec78e6 commit 46b8fa7

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/inlined

core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/inlined/Decimals.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.eclipse.rdf4j.model.Literal;
1717
import org.eclipse.rdf4j.model.ValueFactory;
1818
import org.eclipse.rdf4j.sail.lmdb.ValueIds;
19+
import org.eclipse.rdf4j.sail.lmdb.Varint;
1920

2021
public class Decimals {
2122

@@ -68,12 +69,11 @@ public static int encodeExponent10Bits(int exponent11) {
6869

6970
// Normal number, unbiased exponent in [-1022, 1023]
7071
int unbiasedExp = exponent11 - 1023;
71-
int encoded = unbiasedExp + 511; // Shift range to [0, 1023]
72-
if (encoded < 1 || encoded > 1022) {
72+
if (unbiasedExp < 1 || unbiasedExp > 1022) {
7373
// Out of range for 10 bits (excluding reserved 0 and 0x3FF)
7474
return -1;
7575
}
76-
return encoded;
76+
return (int) Integers.encodeZigZag(unbiasedExp);
7777
}
7878

7979
/**
@@ -91,8 +91,7 @@ public static int decodeExponent10Bits(int encoded) {
9191
// Reserved for NaN/Inf
9292
return 0x7FF;
9393
}
94-
// Normal
95-
int unbiased = encoded - 511;
94+
int unbiased = (int) Integers.decodeZigZag(encoded);
9695
return unbiased + 1023;
9796
}
9897

0 commit comments

Comments
 (0)