Skip to content

Commit 6589291

Browse files
chore: add approx heap size methods to index classes
1 parent 9b55695 commit 6589291

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

hollow/src/main/java/com/netflix/hollow/core/index/HollowHashIndex.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ public String[] getMatchFields() {
296296
return matchFields;
297297
}
298298

299+
public long approxHeapFootprintInBytes() {
300+
HollowHashIndexState hashState = hashStateVolatile;
301+
if (hashState == null) {
302+
return 0;
303+
}
304+
return hashState.getMatchHashTable().approxHeapFootprintInBytes() +
305+
hashState.getSelectHashArray().approxHeapFootprintInBytes();
306+
}
307+
299308
protected static class HollowHashIndexState {
300309

301310
final FixedLengthElementArray selectHashArray;

hollow/src/main/java/com/netflix/hollow/core/index/HollowPrimaryKeyIndex.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,14 @@ public Object[] getRecordKey(int ordinal) {
656656
return keyDeriver.getRecordKey(ordinal);
657657
}
658658

659+
public long approxHeapFootprintInBytes() {
660+
PrimaryKeyIndexHashTable state = hashTableVolatile;
661+
if (state == null) {
662+
return 0;
663+
}
664+
return state.hashTable.approxHeapFootprintInBytes();
665+
}
666+
659667
private boolean recordsHaveEqualKeys(int ordinal1, int ordinal2) {
660668
for(int i=0;i<fieldPathIndexes.length;i++) {
661669
if(!fieldsAreEqual(ordinal1, ordinal2, i))

hollow/src/main/java/com/netflix/hollow/core/index/HollowUniqueKeyIndex.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,14 @@ public Object[] getRecordKey(int ordinal) {
697697
return results;
698698
}
699699

700+
public long approxHeapFootprintInBytes() {
701+
PrimaryKeyIndexHashTable state = hashTableVolatile;
702+
if (state == null) {
703+
return 0;
704+
}
705+
return state.hashTable.approxHeapFootprintInBytes();
706+
}
707+
700708
/**
701709
* @param ordinal ordinal of root object
702710
* @param field field to traverse

0 commit comments

Comments
 (0)