Package dev.vortex.api.proto
Class EndianUtils
java.lang.Object
dev.vortex.api.proto.EndianUtils
Utility class for handling endianness conversions in Vortex protocol buffers.
Provides methods for converting between big-endian and little-endian byte representations,
particularly for decimal values that need to be serialized to the Vortex format.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
littleEndianDecimal
(BigDecimal decimal) Converts a BigDecimal to a little-endian byte array representation suitable for Vortex decimals.static byte[]
reverse
(com.google.protobuf.ByteString src) Reverses the byte order of a ByteString, converting from one endianness to another.
-
Constructor Details
-
EndianUtils
public EndianUtils()
-
-
Method Details
-
reverse
public static byte[] reverse(com.google.protobuf.ByteString src) Reverses the byte order of a ByteString, converting from one endianness to another.- Parameters:
src
- the source ByteString to reverse- Returns:
- a new byte array with bytes in reverse order
-
littleEndianDecimal
Converts a BigDecimal to a little-endian byte array representation suitable for Vortex decimals. The method extracts the unscaled value of the decimal, converts it from big-endian to little-endian, and pads to a standard size (1, 2, 4, 8, 16, or 32 bytes) with proper sign extension for negative values.- Parameters:
decimal
- the BigDecimal value to convert- Returns:
- a little-endian byte array representation of the decimal's unscaled value
- Throws:
RuntimeException
- if the BigDecimal is too large for Arrow
-