Class TimestampEncoding
- java.lang.Object
-
- org.apache.avro.reflect.CustomEncoding<com.google.cloud.Timestamp>
-
- org.apache.beam.sdk.io.gcp.spanner.changestreams.encoder.TimestampEncoding
-
public class TimestampEncoding extends org.apache.avro.reflect.CustomEncoding<com.google.cloud.Timestamp>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.
-
-
Constructor Summary
Constructors Constructor Description TimestampEncoding()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.google.cloud.Timestampread(java.lang.Object reuse, org.apache.avro.io.Decoder in)Deserializes aTimestampfrom the givenDecoder.protected voidwrite(java.lang.Object datum, org.apache.avro.io.Encoder out)Serializes aTimestampreceived as datum to the output encoder out.
-
-
-
Method Detail
-
write
protected void write(java.lang.Object datum, org.apache.avro.io.Encoder out) throws java.io.IOExceptionSerializes aTimestampreceived as datum to the output encoder out. A null timestamp is serialized with negative fields (seconds and nanos).- Specified by:
writein classorg.apache.avro.reflect.CustomEncoding<com.google.cloud.Timestamp>- Parameters:
datum- theTimestampto be encodedout- theEncoderwhere the timestamp should be serialized to- Throws:
java.io.IOException- if it was not possible to write the timestamp into the provided encoder
-
read
protected com.google.cloud.Timestamp read(java.lang.Object reuse, org.apache.avro.io.Decoder in) throws java.io.IOExceptionDeserializes aTimestampfrom the givenDecoder.- Specified by:
readin classorg.apache.avro.reflect.CustomEncoding<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:
java.io.IOException- if it was not possible to read the timestamp from the provided decoder
-
-