[fix](stats) support utf-8 string range compare (#22024)

in previous version, some utf-8 string literal are mapped to negative double. this issue makes our range check misfunction.
This commit is contained in:
minghong
2023-07-20 18:39:41 +08:00
committed by GitHub
parent ee65e0a6b1
commit aabe379527

View File

@ -36,9 +36,9 @@ public abstract class StringLikeLiteral extends Literal {
public double getDouble() {
long v = 0;
int pos = 0;
int len = Math.min(value.length(), 8);
int len = Math.min(value.length(), 7);
while (pos < len) {
v += ((long) value.charAt(pos)) << ((7 - pos) * 8);
v += Byte.toUnsignedLong(value.getBytes()[pos]) << ((6 - pos) * 8);
pos++;
}
return (double) v;