mirror of https://github.com/apache/druid.git
use Number instead of long for response context (#8342)
* use Number instead of long for response context to be forgiving of json serde to int or long * test that encounters issue without fix * now with more test * is ints
This commit is contained in:
parent
d5a19675dd
commit
c87b68d2a4
|
@ -150,7 +150,7 @@ public abstract class ResponseContext
|
|||
*/
|
||||
NUM_SCANNED_ROWS(
|
||||
"count",
|
||||
(oldValue, newValue) -> (long) oldValue + (long) newValue
|
||||
(oldValue, newValue) -> ((Number) oldValue).longValue() + ((Number) newValue).longValue()
|
||||
),
|
||||
/**
|
||||
* The total CPU time for threads related to Sequence processing of the query.
|
||||
|
@ -159,7 +159,7 @@ public abstract class ResponseContext
|
|||
*/
|
||||
CPU_CONSUMED_NANOS(
|
||||
"cpuConsumed",
|
||||
(oldValue, newValue) -> (long) oldValue + (long) newValue
|
||||
(oldValue, newValue) -> ((Number) oldValue).longValue() + ((Number) newValue).longValue()
|
||||
),
|
||||
/**
|
||||
* Indicates if a {@link ResponseContext} was truncated during serialization.
|
||||
|
|
|
@ -280,11 +280,22 @@ public class ResponseContextTest
|
|||
{
|
||||
final DefaultObjectMapper mapper = new DefaultObjectMapper();
|
||||
final ResponseContext ctx = ResponseContext.deserialize(
|
||||
mapper.writeValueAsString(ImmutableMap.of("ETag", "string-value", "count", 100)),
|
||||
mapper.writeValueAsString(
|
||||
ImmutableMap.of(
|
||||
"ETag", "string-value",
|
||||
"count", 100L,
|
||||
"cpuConsumed", 100000L
|
||||
)
|
||||
),
|
||||
mapper
|
||||
);
|
||||
Assert.assertEquals("string-value", ctx.get(ResponseContext.Key.ETAG));
|
||||
Assert.assertEquals(100, ctx.get(ResponseContext.Key.NUM_SCANNED_ROWS));
|
||||
Assert.assertEquals(100000, ctx.get(ResponseContext.Key.CPU_CONSUMED_NANOS));
|
||||
ctx.add(ResponseContext.Key.NUM_SCANNED_ROWS, 10L);
|
||||
Assert.assertEquals(110L, ctx.get(ResponseContext.Key.NUM_SCANNED_ROWS));
|
||||
ctx.add(ResponseContext.Key.CPU_CONSUMED_NANOS, 100);
|
||||
Assert.assertEquals(100100L, ctx.get(ResponseContext.Key.CPU_CONSUMED_NANOS));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
|
|
Loading…
Reference in New Issue