Class 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.
    • Field Summary

      • Fields inherited from class org.apache.avro.reflect.CustomEncoding

        schema
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.google.cloud.Timestamp read​(java.lang.Object reuse, org.apache.avro.io.Decoder in)
      Deserializes a Timestamp from the given Decoder.
      protected void write​(java.lang.Object datum, org.apache.avro.io.Encoder out)
      Serializes a Timestamp received as datum to the output encoder out.
      • Methods inherited from class org.apache.avro.reflect.CustomEncoding

        getSchema
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TimestampEncoding

        public TimestampEncoding()
    • Method Detail

      • write

        protected void write​(java.lang.Object datum,
                             org.apache.avro.io.Encoder out)
                      throws java.io.IOException
        Serializes a Timestamp received as datum to the output encoder out. A null timestamp is serialized with negative fields (seconds and nanos).
        Specified by:
        write in class org.apache.avro.reflect.CustomEncoding<com.google.cloud.Timestamp>
        Parameters:
        datum - the Timestamp to be encoded
        out - the Encoder where 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.IOException
        Deserializes a Timestamp from the given Decoder.
        Specified by:
        read in class org.apache.avro.reflect.CustomEncoding<com.google.cloud.Timestamp>
        Parameters:
        reuse - ignored
        in - the Decoder to read the timestamp fields from
        Returns:
        null if the fields are negative or an instance of a Timestamp instead.
        Throws:
        java.io.IOException - if it was not possible to read the timestamp from the provided decoder