Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public enum Key implements BaseKey
*/
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.
Expand All @@ -159,7 +159,7 @@ public enum Key implements BaseKey
*/
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,22 @@ public void deserializeTest() throws IOException
{
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));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a similar assert for CPU_CONSUMED_NANOS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code is equivalent making a test sort of redundant, but yes anything is possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still useful as a regression test, IMO.

ctx.add(ResponseContext.Key.CPU_CONSUMED_NANOS, 100);
Assert.assertEquals(100100L, ctx.get(ResponseContext.Key.CPU_CONSUMED_NANOS));
}

@Test(expected = IllegalStateException.class)
Expand Down