1
0

[HUDI-605] Avoid calculating the size of schema redundantly (#1317)

This commit is contained in:
lamber-ken
2020-02-12 19:40:52 +08:00
committed by GitHub
parent e5a69ed6af
commit d2c872ede4

View File

@@ -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;
} }
} }