in asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBRowStore.java [1114:1144]
private <T> long parseInt64(T buffer, int begin, int end, ICharAccessor<T> charAccessor) throws SQLException {
if (end < begin) {
throw new IllegalArgumentException();
}
boolean positive = true;
long value = 0;
int offset = begin;
char c = charAccessor.charAt(buffer, offset);
if (c == '+') {
offset++;
} else if (c == '-') {
offset++;
positive = false;
}
try {
for (; offset < end; offset++) {
c = charAccessor.charAt(buffer, offset);
if (c >= '0' && c <= '9') {
value = Math.addExact(Math.multiplyExact(value, 10L), '0' - c);
} else {
throw getErrorReporter().errorInProtocol(String.valueOf(c));
}
}
if (positive) {
value = Math.multiplyExact(value, -1L);
}
return value;
} catch (ArithmeticException e) {
throw getErrorReporter().errorInProtocol();
}
}