From e0b5af2a1e847f65c9f57bccf5b50da2416ae023 Mon Sep 17 00:00:00 2001 From: MrQuansy Date: Fri, 22 Mar 2024 19:18:49 +0800 Subject: [PATCH 1/2] remove duplicate lookup --- .../encoding/encoder/DictionaryEncoder.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java b/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java index df9e10464..27a57842a 100644 --- a/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java +++ b/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java @@ -61,14 +61,15 @@ public DictionaryEncoder() { @Override public void encode(Binary value, ByteArrayOutputStream out) { - entryIndex.computeIfAbsent( - value, - v -> { - indexEntry.add(v); - mapSize += v.getLength(); - return entryIndex.size(); - }); - valuesEncoder.encode(entryIndex.get(value), out); + valuesEncoder.encode( + entryIndex.computeIfAbsent( + value, + v -> { + indexEntry.add(v); + mapSize += v.getLength(); + return entryIndex.size(); + }), + out); } @Override From ab2c9a9a5fb97db5ccc0b893760f668c6edc8986 Mon Sep 17 00:00:00 2001 From: MrQuansy Date: Fri, 22 Mar 2024 21:07:28 +0800 Subject: [PATCH 2/2] fix --- .../apache/tsfile/encoding/encoder/DictionaryEncoder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java b/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java index 27a57842a..4a6fde552 100644 --- a/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java +++ b/tsfile/src/main/java/org/apache/tsfile/encoding/encoder/DictionaryEncoder.java @@ -61,15 +61,15 @@ public DictionaryEncoder() { @Override public void encode(Binary value, ByteArrayOutputStream out) { - valuesEncoder.encode( + int i = entryIndex.computeIfAbsent( value, v -> { indexEntry.add(v); mapSize += v.getLength(); return entryIndex.size(); - }), - out); + }); + valuesEncoder.encode(i, out); } @Override