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 aTimestamp
received as datum to the output encoder out. A null timestamp is serialized with negative fields (seconds and nanos).- Specified by:
write
in classCustomEncoding<com.google.cloud.Timestamp>
- Parameters:
datum
- theTimestamp
to be encodedout
- theEncoder
where the timestamp should be serialized to- Throws:
IOException
- if it was not possible to write the timestamp into the provided encoder
-
read
Deserializes aTimestamp
from the givenDecoder
.- Specified by:
read
in classCustomEncoding<com.google.cloud.Timestamp>
- Parameters:
reuse
- ignoredin
- theDecoder
to read the timestamp fields from- Returns:
- null if the fields are negative or an instance of a
Timestamp
instead. - Throws:
IOException
- if it was not possible to read the timestamp from the provided decoder
-