You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gu...@apache.org on 2023/10/07 06:49:53 UTC

[lucene] 01/03: DeletedTerms#clear should reset ByteBlockPool

This is an automated email from the ASF dual-hosted git repository.

guofeng pushed a commit to branch deleted_terms_should_reset_pool
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit 65a7fbcbb43f5d8a404f6b4d6f3b2433bcf3ae75
Author: guofeng.my <gu...@bytedance.com>
AuthorDate: Sat Oct 7 14:32:30 2023 +0800

    DeletedTerms#clear should reset ByteBlockPool
---
 .../core/src/java/org/apache/lucene/index/BufferedUpdates.java   | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdates.java b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdates.java
index f6a30e3e733..b01805dd451 100644
--- a/lucene/core/src/java/org/apache/lucene/index/BufferedUpdates.java
+++ b/lucene/core/src/java/org/apache/lucene/index/BufferedUpdates.java
@@ -230,6 +230,7 @@ class BufferedUpdates implements Accountable {
     }
 
     void clear() {
+      pool.reset(false, false);
       bytesUsed.addAndGet(-bytesUsed.get());
       deleteTerms.clear();
       termsSize = 0;
@@ -284,6 +285,14 @@ class BufferedUpdates implements Accountable {
     public long ramBytesUsed() {
       return bytesUsed.get();
     }
+
+    /** Used for {@link BufferedUpdates#VERBOSE_DELETES}. */
+    @Override
+    public String toString() {
+      return keySet().stream()
+          .map(t -> t + "=" + get(t))
+          .collect(Collectors.joining(", ", "{", "}"));
+    }
   }
 
   private static class BytesRefIntMap {