From a29ac994e0537c4c399901bb47ac4b287f64bb0f Mon Sep 17 00:00:00 2001 From: Guy Khazma <33684427+guykhazma@users.noreply.github.com> Date: Tue, 8 Nov 2022 13:31:11 -0500 Subject: [PATCH] filter invalid event in object store trace (#814) --- .../parser/snia/keyvalue/ObjectStoreTraceReader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/snia/keyvalue/ObjectStoreTraceReader.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/snia/keyvalue/ObjectStoreTraceReader.java index 13e2836ff0..3309a3b4ad 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/snia/keyvalue/ObjectStoreTraceReader.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/snia/keyvalue/ObjectStoreTraceReader.java @@ -48,7 +48,7 @@ public Stream events() { return lines() .map(line -> line.split(" ")) .filter(array -> array[1].equals("REST.GET.OBJECT")) - .map(array -> { + .flatMap(array -> { long key = new BigInteger(array[2], 16).longValue(); int weight; if (array.length == 3) { @@ -58,7 +58,10 @@ public Stream events() { long end = Long.parseLong(array[5]); weight = Ints.saturatedCast(end - start); } - return AccessEvent.forKeyAndWeight(key, weight); + if (weight < 0) { + return Stream.empty(); + } + return Stream.of(AccessEvent.forKeyAndWeight(key, weight)); }); } }