Skip to content

Commit d34d085

Browse files
committed
Use Fast Double Parser in jackson
Signed-off-by: Mohit Godwani <[email protected]>
1 parent daa10be commit d34d085

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4343
- Change http code on create index API with bad input raising NotXContentException from 500 to 400 ([#4773](https://github.com/opensearch-project/OpenSearch/pull/4773))
4444
- Change http code for DecommissioningFailedException from 500 to 400 ([#5283](https://github.com/opensearch-project/OpenSearch/pull/5283))
4545
- Improve summary error message for invalid setting updates ([#4792](https://github.com/opensearch-project/OpenSearch/pull/4792))
46+
- Improved performance of parsing floating point numbers ([#7909](https://github.com/opensearch-project/OpenSearch/pull/7909))
4647

4748
### Deprecated
4849

libs/x-content/src/main/java/org/opensearch/common/xcontent/cbor/CborXContent.java

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.fasterxml.jackson.core.JsonGenerator;
3737
import com.fasterxml.jackson.core.JsonParser;
3838
import com.fasterxml.jackson.core.StreamReadConstraints;
39+
import com.fasterxml.jackson.core.StreamReadFeature;
3940
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
4041
import org.opensearch.core.xcontent.DeprecationHandler;
4142
import org.opensearch.core.xcontent.MediaType;
@@ -75,6 +76,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7576
cborFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
7677
cborFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7778
cborFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
79+
cborFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
7880
cborXContent = new CborXContent();
7981
}
8082

libs/x-content/src/main/java/org/opensearch/common/xcontent/json/JsonXContent.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import com.fasterxml.jackson.core.JsonGenerator;
3838
import com.fasterxml.jackson.core.JsonParser;
3939
import com.fasterxml.jackson.core.StreamReadConstraints;
40-
import com.fasterxml.jackson.core.StreamWriteFeature;
40+
import com.fasterxml.jackson.core.StreamReadFeature;
4141
import org.opensearch.core.xcontent.DeprecationHandler;
4242
import org.opensearch.core.xcontent.MediaType;
4343
import org.opensearch.core.xcontent.NamedXContentRegistry;
@@ -78,8 +78,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7878
jsonFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
7979
jsonFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
8080
jsonFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
81-
jsonFactory.configure(JsonParser.Feature.USE_FAST_DOUBLE_PARSER, true);
82-
jsonFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), true);
81+
jsonFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
8382
jsonXContent = new JsonXContent();
8483
}
8584

libs/x-content/src/main/java/org/opensearch/common/xcontent/smile/SmileXContent.java

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.fasterxml.jackson.core.JsonGenerator;
3737
import com.fasterxml.jackson.core.JsonParser;
3838
import com.fasterxml.jackson.core.StreamReadConstraints;
39+
import com.fasterxml.jackson.core.StreamReadFeature;
3940
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
4041
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
4142
import org.opensearch.core.xcontent.DeprecationHandler;
@@ -77,6 +78,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7778
smileFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
7879
smileFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7980
smileFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
81+
smileFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
8082
smileXContent = new SmileXContent();
8183
}
8284

libs/x-content/src/main/java/org/opensearch/common/xcontent/yaml/YamlXContent.java

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.fasterxml.jackson.core.JsonEncoding;
3636
import com.fasterxml.jackson.core.JsonParser;
3737
import com.fasterxml.jackson.core.StreamReadConstraints;
38+
import com.fasterxml.jackson.core.StreamReadFeature;
3839
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
3940
import org.opensearch.core.xcontent.DeprecationHandler;
4041
import org.opensearch.core.xcontent.NamedXContentRegistry;
@@ -70,6 +71,7 @@ public static XContentBuilder contentBuilder() throws IOException {
7071
yamlFactory = new YAMLFactory();
7172
yamlFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7273
yamlFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
74+
yamlFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
7375
yamlXContent = new YamlXContent();
7476
}
7577

0 commit comments

Comments
 (0)