Skip to content

Commit bada848

Browse files
committed
Work
1 parent b5125d5 commit bada848

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/eson/ESONDeserializationBenchmark.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.common.xcontent.XContentHelper;
1717
import org.elasticsearch.core.Tuple;
1818
import org.elasticsearch.ingest.ESONSource;
19+
import org.elasticsearch.ingest.ESONXContentSerializer;
1920
import org.elasticsearch.xcontent.ToXContent;
2021
import org.elasticsearch.xcontent.XContentBuilder;
2122
import org.elasticsearch.xcontent.XContentFactory;
@@ -126,6 +127,14 @@ public void writeJSONFromESON(Blackhole bh) throws IOException {
126127
bh.consume(bytes);
127128
}
128129

130+
@Benchmark
131+
public void writeJSONFromESONFlatten(Blackhole bh) throws IOException {
132+
XContentBuilder builder = XContentFactory.contentBuilder(JsonXContent.jsonXContent.type());
133+
ESONXContentSerializer.flattedToXContent(esonObject, builder, ToXContent.EMPTY_PARAMS);
134+
BytesReference bytes = BytesReference.bytes(builder);
135+
bh.consume(bytes);
136+
}
137+
129138
@Benchmark
130139
public void readMap(Blackhole bh) throws IOException {
131140
Tuple<XContentType, Map<String, Object>> tuple = XContentHelper.convertToMap(source, false, XContentType.JSON);

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
7575

7676
Map<String, Object> matches = grok.captures(fieldValue);
7777
if (matches == null) {
78-
logger.warn(">[{}] Grok expressions do not match field value: [{}]", tag, fieldValue);
78+
logger.warn(">[{}] Grok expressions do not match field value: [{}][{}]", tag, matchField, fieldValue);
7979
throw new IllegalArgumentException("Provided Grok expressions do not match field value: [" + fieldValue + "]");
8080
}
8181

server/src/main/java/org/elasticsearch/ingest/ESONSource.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.xcontent.ToXContent;
1818
import org.elasticsearch.xcontent.XContentBuilder;
1919
import org.elasticsearch.xcontent.XContentParser;
20+
import org.elasticsearch.xcontent.XContentString;
2021

2122
import java.io.IOException;
2223
import java.util.AbstractCollection;
@@ -115,9 +116,9 @@ private static Type parseSimpleValue(XContentParser parser, BytesStreamOutput by
115116

116117
return switch (token) {
117118
case VALUE_STRING -> {
118-
byte[] stringBytes = parser.text().getBytes(java.nio.charset.StandardCharsets.UTF_8);
119-
bytes.write(stringBytes);
120-
yield new VariableValue((int) position, stringBytes.length, ValueType.STRING);
119+
XContentString.UTF8Bytes stringBytes = parser.optimizedText().bytes();
120+
bytes.write(stringBytes.bytes(), stringBytes.offset(), stringBytes.length());
121+
yield new VariableValue((int) position, stringBytes.length(), ValueType.STRING);
121122
}
122123
case VALUE_NUMBER -> {
123124
XContentParser.NumberType numberType = parser.numberType();

0 commit comments

Comments
 (0)