mirror of https://github.com/apache/lucene.git
DeletedTerms#clear should reset ByteBlockPool (#12630)
This commit is contained in:
parent
33a3af4260
commit
e20e245f47
|
@ -230,6 +230,7 @@ class BufferedUpdates implements Accountable {
|
|||
}
|
||||
|
||||
void clear() {
|
||||
pool.reset(false, false);
|
||||
bytesUsed.addAndGet(-bytesUsed.get());
|
||||
deleteTerms.clear();
|
||||
termsSize = 0;
|
||||
|
@ -280,10 +281,23 @@ class BufferedUpdates implements Accountable {
|
|||
}
|
||||
}
|
||||
|
||||
/** Visible for testing. */
|
||||
ByteBlockPool getPool() {
|
||||
return pool;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
|
|
|
@ -61,10 +61,10 @@ public class TestBufferedUpdates extends LuceneTestCase {
|
|||
public void testDeletedTerms() {
|
||||
int iters = atLeast(10);
|
||||
String[] fields = new String[] {"a", "b", "c"};
|
||||
BufferedUpdates.DeletedTerms actual = new BufferedUpdates.DeletedTerms();
|
||||
for (int iter = 0; iter < iters; iter++) {
|
||||
|
||||
Map<Term, Integer> expected = new HashMap<>();
|
||||
BufferedUpdates.DeletedTerms actual = new BufferedUpdates.DeletedTerms();
|
||||
assertTrue(actual.isEmpty());
|
||||
|
||||
int termCount = atLeast(5000);
|
||||
|
@ -95,6 +95,11 @@ public class TestBufferedUpdates extends LuceneTestCase {
|
|||
}));
|
||||
|
||||
assertEquals(expectedSorted, actualSorted);
|
||||
|
||||
actual.clear();
|
||||
assertEquals(0, actual.size());
|
||||
assertEquals(0, actual.ramBytesUsed());
|
||||
assertNull(actual.getPool().buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue