Package dev.vortex.api.proto
Class TemporalMetadatas
java.lang.Object
dev.vortex.api.proto.TemporalMetadatas
Utility class for creating and parsing temporal metadata in Vortex protocol buffers.
Provides constants for time units and methods for serializing/deserializing timestamp
metadata including time zone information. This class handles the binary format used
to encode temporal type information in the Vortex data format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.google.common.base.Supplier<byte[]>
Supplier for date metadata with days precision.static final com.google.common.base.Supplier<byte[]>
Supplier for date metadata with milliseconds precision.static final com.google.common.base.Supplier<byte[]>
Supplier for time metadata with microseconds precision.static final com.google.common.base.Supplier<byte[]>
Supplier for time metadata with milliseconds precision.static final com.google.common.base.Supplier<byte[]>
Supplier for time metadata with nanoseconds precision.static final com.google.common.base.Supplier<byte[]>
Supplier for time metadata with seconds precision.static byte
Time unit constant representing days precision.static byte
Time unit constant representing microseconds precision.static byte
Time unit constant representing milliseconds precision.static byte
Time unit constant representing nanoseconds precision.static byte
Time unit constant representing seconds precision. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte
getTimeUnit
(byte[] serializedMetadata) Extract the time unit byte from the serialized metadata.getTimeZone
(byte[] serializedMetadata) Read from a serialized metadata representation into a time zone string.static byte[]
Creates serialized timestamp metadata with the specified time unit and optional time zone.
-
Field Details
-
TIME_UNIT_NANOS
public static byte TIME_UNIT_NANOSTime unit constant representing nanoseconds precision. -
TIME_UNIT_MICROS
public static byte TIME_UNIT_MICROSTime unit constant representing microseconds precision. -
TIME_UNIT_MILLIS
public static byte TIME_UNIT_MILLISTime unit constant representing milliseconds precision. -
TIME_UNIT_SECONDS
public static byte TIME_UNIT_SECONDSTime unit constant representing seconds precision. -
TIME_UNIT_DAYS
public static byte TIME_UNIT_DAYSTime unit constant representing days precision. -
DATE_DAYS
public static final com.google.common.base.Supplier<byte[]> DATE_DAYSSupplier for date metadata with days precision. -
DATE_MILLIS
public static final com.google.common.base.Supplier<byte[]> DATE_MILLISSupplier for date metadata with milliseconds precision. -
TIME_SECONDS
public static final com.google.common.base.Supplier<byte[]> TIME_SECONDSSupplier for time metadata with seconds precision. -
TIME_MILLIS
public static final com.google.common.base.Supplier<byte[]> TIME_MILLISSupplier for time metadata with milliseconds precision. -
TIME_MICROS
public static final com.google.common.base.Supplier<byte[]> TIME_MICROSSupplier for time metadata with microseconds precision. -
TIME_NANOS
public static final com.google.common.base.Supplier<byte[]> TIME_NANOSSupplier for time metadata with nanoseconds precision.
-
-
Method Details
-
timestamp
Creates serialized timestamp metadata with the specified time unit and optional time zone. The resulting byte array contains the time unit as the first byte, followed by a little-endian uint16 length field, and then the UTF-8 encoded time zone string (if present).- Parameters:
timeUnit
- the time unit for the timestamp, must be between TIME_UNIT_NANOS and TIME_UNIT_SECONDS (exclusive of TIME_UNIT_DAYS)timeZone
- optional time zone identifier string- Returns:
- serialized timestamp metadata as a byte array
- Throws:
RuntimeException
- if timeUnit is invalid for timestamps
-
getTimeUnit
public static byte getTimeUnit(byte[] serializedMetadata) Extract the time unit byte from the serialized metadata.- Parameters:
serializedMetadata
- the serialized temporal metadata byte array- Returns:
- the time unit byte from the first position of the metadata
- Throws:
RuntimeException
- if the time unit byte is invalid
-
getTimeZone
Read from a serialized metadata representation into a time zone string. Parses the time zone information from the serialized metadata, reading the length as a little-endian uint16 and then decoding the UTF-8 time zone string.- Parameters:
serializedMetadata
- the serialized temporal metadata byte array- Returns:
- Optional containing the time zone string, or empty if no time zone was specified
-