Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ Optimizations

Bug Fixes
---------------------
* Fix missing null check in RamUsageEstimator.sizeOf(Accountable) to be consistent
with sizeOf(String) and sizeOf(Accountable[]). (Tim Grein)

* GITHUB#14049: Randomize KNN codec params in RandomCodec. Fixes scalar quantization div-by-zero
when all values are identical. (Mike Sokolov)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ private static long sizeOfObject(Object o, int depth, long defSize) {
* Accountable#ramBytesUsed()} method.
*/
public static long sizeOf(Accountable accountable) {
Comment thread
ChrisHegarty marked this conversation as resolved.
if (accountable == null) {
return 0;
}
return accountable.ramBytesUsed();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ public void testMap() {
assertEquals((double) actual, (double) estimated, (double) actual * errorFactor);
}

public void testAccountable() {
assertEquals(0L, RamUsageEstimator.sizeOf((Accountable) null));
assertEquals(1L, RamUsageEstimator.sizeOf(new DummyAccountable()));
}

public void testCollection() {
List<Object> list = new ArrayList<>();
list.add(1234L);
Expand Down Expand Up @@ -252,4 +257,11 @@ private static class HolderSubclass extends Holder {
private static class HolderSubclass2 extends Holder {
// empty, only inherits all fields -> size should be identical to superclass
}

private static class DummyAccountable implements Accountable {
@Override
public long ramBytesUsed() {
return 1L;
}
}
}
Loading