Class TimestampEncoding
java.lang.Object
org.apache.avro.reflect.CustomEncoding<com.google.cloud.Timestamp>
org.apache.beam.sdk.io.gcp.spanner.changestreams.encoder.TimestampEncoding
This encoder/decoder writes a com.google.cloud.Timestamp object as a pair of long and int to avro
and reads a Timestamp object from the same pair. The long stores the number of seconds since
January 1, 1970, 00:00:00 UTC. A negative value is the number of seconds before January 1, 1970,
00:00:00 UTC. The int stores the fractional seconds components, in the range 0..999999999.
-
Field Summary
Fields inherited from class org.apache.avro.reflect.CustomEncoding
schema -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.avro.reflect.CustomEncoding
getSchema
-
Constructor Details
-
TimestampEncoding
public TimestampEncoding()
-
-
Method Details
-
write
Serializes aTimestampreceived as datum to the output encoder out. A null timestamp is serialized with negative fields (seconds and nanos).- Specified by:
writein classCustomEncoding<com.google.cloud.Timestamp>- Parameters:
datum- theTimestampto be encodedout- theEncoderwhere the timestamp should be serialized to- Throws:
IOException- if it was not possible to write the timestamp into the provided encoder
-
read
Deserializes aTimestampfrom the givenDecoder.- Specified by:
readin classCustomEncoding<com.google.cloud.Timestamp>- Parameters:
reuse- ignoredin- theDecoderto read the timestamp fields from- Returns:
- null if the fields are negative or an instance of a
Timestampinstead. - Throws:
IOException- if it was not possible to read the timestamp from the provided decoder
-