Skip to content

Commit 559d606

Browse files
committed
Changes
1 parent db9fccb commit 559d606

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,10 @@ public String getKey() {
443443

444444
@Override
445445
public Object getValue() {
446-
if (shouldComputeValue && valueComputed == false) {
446+
if (shouldComputeValue == false) {
447+
// assert valueComputed == false;
448+
return type;
449+
} else if (valueComputed == false) {
447450
if (type == null) {
448451
cachedValue = null;
449452
} else if (type instanceof Mutation mutation) {

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,17 @@ private Token emitValue(ESONSource.Type esonType) {
250250

251251
// Helper method to materialize the current value on demand
252252
private Object getCurrentValue() {
253+
// TODO: Could probably optimize to not box all the numbers
253254
if (valueComputed == false) {
254-
currentValue = materializeValue(currentEsonType);
255+
currentValue = materializeValue();
255256
valueComputed = true;
256257
}
257258
return currentValue;
258259
}
259260

260261
// Helper method to materialize a value from an ESON type
261-
private Object materializeValue(ESONSource.Type esonType) {
262+
private Object materializeValue() {
263+
ESONSource.Type esonType = currentEsonType;
262264
if (esonType == null) {
263265
return null;
264266
} else if (esonType instanceof ESONSource.ESONObject obj) {
@@ -394,11 +396,13 @@ public CharBuffer charBuffer() throws IOException {
394396

395397
@Override
396398
public Object objectText() throws IOException {
399+
getCurrentValue();
397400
return currentValue;
398401
}
399402

400403
@Override
401404
public Object objectBytes() throws IOException {
405+
getCurrentValue();
402406
return currentValue;
403407
}
404408

@@ -424,6 +428,7 @@ public int textOffset() throws IOException {
424428

425429
@Override
426430
public Number numberValue() throws IOException {
431+
getCurrentValue();
427432
if (currentValue instanceof Number num) {
428433
return num;
429434
}
@@ -432,6 +437,7 @@ public Number numberValue() throws IOException {
432437

433438
@Override
434439
public NumberType numberType() throws IOException {
440+
getCurrentValue();
435441
if (currentValue instanceof Integer) {
436442
return NumberType.INT;
437443
} else if (currentValue instanceof Long) {
@@ -446,6 +452,7 @@ public NumberType numberType() throws IOException {
446452

447453
@Override
448454
protected boolean doBooleanValue() throws IOException {
455+
getCurrentValue();
449456
if (currentValue instanceof Boolean bool) {
450457
return bool;
451458
}
@@ -454,6 +461,7 @@ protected boolean doBooleanValue() throws IOException {
454461

455462
@Override
456463
protected short doShortValue() throws IOException {
464+
getCurrentValue();
457465
if (currentValue instanceof Number num) {
458466
return num.shortValue();
459467
}
@@ -462,6 +470,7 @@ protected short doShortValue() throws IOException {
462470

463471
@Override
464472
protected int doIntValue() throws IOException {
473+
getCurrentValue();
465474
if (currentValue instanceof Number num) {
466475
return num.intValue();
467476
}
@@ -470,6 +479,7 @@ protected int doIntValue() throws IOException {
470479

471480
@Override
472481
protected long doLongValue() throws IOException {
482+
getCurrentValue();
473483
if (currentValue instanceof Number num) {
474484
return num.longValue();
475485
}
@@ -478,6 +488,7 @@ protected long doLongValue() throws IOException {
478488

479489
@Override
480490
protected float doFloatValue() throws IOException {
491+
getCurrentValue();
481492
if (currentValue instanceof Number num) {
482493
return num.floatValue();
483494
}
@@ -486,6 +497,7 @@ protected float doFloatValue() throws IOException {
486497

487498
@Override
488499
protected double doDoubleValue() throws IOException {
500+
getCurrentValue();
489501
if (currentValue instanceof Number num) {
490502
return num.doubleValue();
491503
}
@@ -494,6 +506,7 @@ protected double doDoubleValue() throws IOException {
494506

495507
@Override
496508
public byte[] binaryValue() throws IOException {
509+
getCurrentValue();
497510
if (currentValue instanceof byte[] bytes) {
498511
return bytes;
499512
}

0 commit comments

Comments
 (0)