Skip to content

Commit

Permalink
Fix array Block ramBytesUsed
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHegarty committed Oct 10, 2023
1 parent b31715d commit 9c7b3e5
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public BooleanBlock expand() {

public static long ramBytesEstimated(boolean[] values, int[] firstValueIndexes, BitSet nullsMask) {
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values) + BlockRamUsageEstimator.sizeOf(firstValueIndexes)
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask) + RamUsageEstimator.shallowSizeOfInstance(MvOrdering.class);
// TODO mvordering is shared
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ public BytesRefBlock expand() {

public static long ramBytesEstimated(BytesRefArray values, int[] firstValueIndexes, BitSet nullsMask) {
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values) + BlockRamUsageEstimator.sizeOf(firstValueIndexes)
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask) + RamUsageEstimator.shallowSizeOfInstance(MvOrdering.class);
// TODO mvordering is shared
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public DoubleBlock expand() {

public static long ramBytesEstimated(double[] values, int[] firstValueIndexes, BitSet nullsMask) {
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values) + BlockRamUsageEstimator.sizeOf(firstValueIndexes)
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask) + RamUsageEstimator.shallowSizeOfInstance(MvOrdering.class);
// TODO mvordering is shared
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public IntBlock expand() {

public static long ramBytesEstimated(int[] values, int[] firstValueIndexes, BitSet nullsMask) {
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values) + BlockRamUsageEstimator.sizeOf(firstValueIndexes)
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask) + RamUsageEstimator.shallowSizeOfInstance(MvOrdering.class);
// TODO mvordering is shared
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public LongBlock expand() {

public static long ramBytesEstimated(long[] values, int[] firstValueIndexes, BitSet nullsMask) {
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values) + BlockRamUsageEstimator.sizeOf(firstValueIndexes)
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask) + RamUsageEstimator.shallowSizeOfInstance(MvOrdering.class);
// TODO mvordering is shared
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ $endif$

public static long ramBytesEstimated($if(BytesRef)$BytesRefArray$else$$type$[]$endif$ values, int[] firstValueIndexes, BitSet nullsMask) {
return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values) + BlockRamUsageEstimator.sizeOf(firstValueIndexes)
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask) + RamUsageEstimator.shallowSizeOfInstance(MvOrdering.class);
// TODO mvordering is shared
+ BlockRamUsageEstimator.sizeOfBitSet(nullsMask);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public long accumulateObject(Object o, long shallowSize, Map<Field, Object> fiel
} else {
queue.add(entry.getValue());
}
} else if (o instanceof AbstractArrayBlock && entry.getValue() instanceof Block.MvOrdering) {
// skip; MvOrdering is an enum, so instances are shared
} else {
queue.add(entry.getValue());
}
Expand Down

0 comments on commit 9c7b3e5

Please sign in to comment.