[
https://issues.apache.org/jira/browse/FLINK-4268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15506206#comment-15506206
]
ASF GitHub Bot commented on FLINK-4268:
---------------------------------------
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/2304#discussion_r79572690
--- Diff:
flink-core/src/main/java/org/apache/flink/types/parser/BigDecParser.java ---
@@ -55,9 +56,20 @@ public int parseField(byte[] bytes, int startPos, int
limit, byte[] delimiter, B
return -1;
}
- String str = new String(bytes, startPos, i - startPos);
try {
- this.result = new BigDecimal(str);
+ final int length = i - startPos;
+ if (reuse == null || reuse.length != length) {
+ reuse = new char[length];
+ }
+ for (int j = 0; j < length; j++) {
+ final byte b = bytes[startPos + j];
+ if ((b < '0' || b > '9') && b != '-' && b !=
'+' && b != '.' && b != 'E' && b != 'e') {
+ throw new NumberFormatException();
+ }
+ reuse[j] = (char) bytes[startPos + j];
+ }
+
+ this.result = new BigDecimal(reuse);
--- End diff --
we can use the `BigDecimal(char[] in, int offset, int len)` and reuse the
`reuse` object also if it is larger than then provided input.
> Add a parsers for BigDecimal/BigInteger
> ---------------------------------------
>
> Key: FLINK-4268
> URL: https://issues.apache.org/jira/browse/FLINK-4268
> Project: Flink
> Issue Type: Improvement
> Components: Table API & SQL
> Affects Versions: 1.2.0
> Reporter: Timo Walther
> Assignee: Timo Walther
>
> Since BigDecimal and BigInteger are basic types now. It would be great if we
> also parse those.
> FLINK-628 did this a long time ago. This feature should be reintroduced.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)