Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json: enable fast double operations #1483

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions atlas-json/src/main/scala/com/netflix/atlas/json/Json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ object Json {
.enable(JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS)
.enable(StreamReadFeature.AUTO_CLOSE_SOURCE)
.enable(StreamWriteFeature.AUTO_CLOSE_TARGET)
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
.enable(StreamWriteFeature.USE_FAST_DOUBLE_WRITER)
.enable(JsonWriteFeature.WRITE_NAN_AS_STRINGS)
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package com.netflix.atlas.json

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonToken
import com.fasterxml.jackson.core.io.doubleparser.FastDoubleParser

object JsonParserHelper {

Expand Down Expand Up @@ -93,7 +94,7 @@ object JsonParserHelper {
parser.nextToken() match {
case VALUE_NUMBER_INT => parser.getValueAsDouble
case VALUE_NUMBER_FLOAT => parser.getValueAsDouble
case VALUE_STRING => java.lang.Double.parseDouble(parser.getText)
case VALUE_STRING => FastDoubleParser.parseDouble(parser.getText)
case t => fail(parser, s"expected VALUE_NUMBER_FLOAT but received $t")
}
}
Expand Down