You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by zhou zhengke <zh...@outlook.com> on 2024/11/22 15:36:15 UTC

[DISCUSS] Refactor Hardcoded Byte Calculations Using SizeUnit Enum

Hi all,

I have observed numerous hardcoded byte calculation expressions, such as `1024L * 1024L * 1`: https://github.com/apache/pulsar/blob/d33cc20761b97d103d52ce7e24638edcd43a2a1e/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L854 for byte calculations.

And the `SizeUnit`enum :https://github.com/apache/pulsar/blob/master/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/SizeUnit.java in the pulsar-client-api module offers a more readable alternative; we can use SizeUnit.MEGA_BYTES.toBytes(1) and similar methods.

I propose refactoring similar patterns in several locations to utilize SizeUnit methods for improved clarity and consistency.

Thanks,
ZhengKe Zhou