[HUDI-605] Avoid calculating the size of schema redundantly (#1317)
This commit is contained in:
@@ -35,11 +35,10 @@ public class HoodieRecordSizeEstimator<T extends HoodieRecordPayload> implements
|
|||||||
|
|
||||||
private static final Logger LOG = LogManager.getLogger(HoodieRecordSizeEstimator.class);
|
private static final Logger LOG = LogManager.getLogger(HoodieRecordSizeEstimator.class);
|
||||||
|
|
||||||
// Schema used to get GenericRecord from HoodieRecordPayload then convert to bytes and vice-versa
|
private final long sizeOfSchema;
|
||||||
private final Schema schema;
|
|
||||||
|
|
||||||
public HoodieRecordSizeEstimator(Schema schema) {
|
public HoodieRecordSizeEstimator(Schema schema) {
|
||||||
this.schema = schema;
|
sizeOfSchema = ObjectSizeCalculator.getObjectSize(schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,8 +48,9 @@ public class HoodieRecordSizeEstimator<T extends HoodieRecordPayload> implements
|
|||||||
// note the sizes and differences. A correct estimation in such cases is handled in
|
// note the sizes and differences. A correct estimation in such cases is handled in
|
||||||
/** {@link ExternalSpillableMap} **/
|
/** {@link ExternalSpillableMap} **/
|
||||||
long sizeOfRecord = ObjectSizeCalculator.getObjectSize(hoodieRecord);
|
long sizeOfRecord = ObjectSizeCalculator.getObjectSize(hoodieRecord);
|
||||||
long sizeOfSchema = ObjectSizeCalculator.getObjectSize(schema);
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.info("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
|
LOG.debug("SizeOfRecord => " + sizeOfRecord + " SizeOfSchema => " + sizeOfSchema);
|
||||||
|
}
|
||||||
return sizeOfRecord;
|
return sizeOfRecord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user