mirror of https://github.com/apache/lucene.git
Rollback the tmp storage of BytesRefHash to -1 after sort (#13014)
This commit is contained in:
parent
3a205feb27
commit
d0098f8489
|
@ -214,6 +214,7 @@ public final class BytesRefHash implements Accountable {
|
|||
pool.fillBytesRef(result, bytesStart[compact[i]]);
|
||||
}
|
||||
}.sort(0, count);
|
||||
Arrays.fill(compact, tmpOffset, compact.length, -1);
|
||||
return compact;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,9 @@ public class TestBytesRefHash extends LuceneTestCase {
|
|||
hash.add(ref.get());
|
||||
strings.add(str);
|
||||
}
|
||||
for (int iter = 0; iter < 3; iter++) {
|
||||
// Test duplicate sort on a BytesRefHash instance work well. This makes no sense but some
|
||||
// users need that.
|
||||
int[] sort = hash.sort();
|
||||
assertTrue(strings.size() < sort.length);
|
||||
int i = 0;
|
||||
|
@ -184,6 +187,7 @@ public class TestBytesRefHash extends LuceneTestCase {
|
|||
ref.copyChars(string);
|
||||
assertEquals(ref.get(), hash.get(sort[i++], scratch));
|
||||
}
|
||||
}
|
||||
hash.clear();
|
||||
assertEquals(0, hash.size());
|
||||
hash.reinit();
|
||||
|
|
Loading…
Reference in New Issue