Skip to content

Commit 2df9813

Browse files
committed
Normalize numeric values to Double for consistent filtering and serialization
1 parent 5a26121 commit 2df9813

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

nitrite/src/main/java/org/dizitart/no2/common/DBValue.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private DBValue() {
4242
}
4343

4444
public DBValue(Comparable<?> value) {
45-
this.value = value;
45+
this.value = normalizeNumber(value);
4646
}
4747

4848
@Override
@@ -58,6 +58,15 @@ public int compareTo(DBValue o) {
5858
return Comparables.compare(value, o.value);
5959
}
6060

61+
private static Comparable<?> normalizeNumber(Comparable<?> value) {
62+
// Normalize all numeric types to Double for consistent serialization
63+
// This ensures Integer(5) and Double(5.0) are treated the same in indexes
64+
if (value instanceof Number && !(value instanceof Double)) {
65+
return ((Number) value).doubleValue();
66+
}
67+
return value;
68+
}
69+
6170
private void writeObject(ObjectOutputStream stream) throws IOException {
6271
stream.writeObject(value);
6372
}

0 commit comments

Comments
 (0)