Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,16 @@ private void freeCurrentPage() {
protected FixedLengthRowBasedKeyValueBatch(StructType keySchema, StructType valueSchema,
int maxRows, TaskMemoryManager manager) {
super(keySchema, valueSchema, maxRows, manager);
klen = keySchema.defaultSize()
+ UnsafeRow.calculateBitSetWidthInBytes(keySchema.length());
vlen = valueSchema.defaultSize()
+ UnsafeRow.calculateBitSetWidthInBytes(valueSchema.length());
int keySize = 0;
int valueSize = 0;
for (String name : keySchema.fieldNames()) {
keySize += (keySchema.apply(name).dataType().defaultSize() + 7) / 8 * 8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a small comment about this implicit ceiling logic and the reason why schema.defaultSize() doesn't work.

}
for (String name : valueSchema.fieldNames()) {
valueSize += (valueSchema.apply(name).dataType().defaultSize() + 7) / 8 * 8;
}
klen = keySize + UnsafeRow.calculateBitSetWidthInBytes(keySchema.length());
vlen = valueSize + UnsafeRow.calculateBitSetWidthInBytes(valueSchema.length());
recordLength = klen + vlen + 8;
}
}
Loading