Class LongDeltaSerializer

java.lang.Object
com.esotericsoftware.kryo.kryo5.Serializer<Long>
ch.qos.logback.classic.kryo.LongDeltaSerializer

public class LongDeltaSerializer extends com.esotericsoftware.kryo.kryo5.Serializer<Long>
Serializer for long values that stores successive values as deltas.

Each written value is encoded as current - lastWritten via Output.writeVarLong(long, boolean) (zig-zag). On read, the absolute value is reconstructed by adding the delta to the last reconstructed value. Write and read state are independent so the same instance can be used for both directions without interference.

Typical for monotonically increasing timestamps in a log stream, where deltas are small and varint-encode well.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    read(com.esotericsoftware.kryo.kryo5.Kryo kryo, com.esotericsoftware.kryo.kryo5.io.Input input, Class<? extends Long> type)
     
    long
    readLong(com.esotericsoftware.kryo.kryo5.io.Input input)
    void
    write(com.esotericsoftware.kryo.kryo5.Kryo kryo, com.esotericsoftware.kryo.kryo5.io.Output output, Long value)
     
    void
    writeLong(com.esotericsoftware.kryo.kryo5.io.Output output, long value)
    Writes value as a zig-zag varint delta from the previous write.

    Methods inherited from class com.esotericsoftware.kryo.kryo5.Serializer

    copy, getAcceptsNull, isImmutable, setAcceptsNull, setImmutable

    Methods inherited from class Object

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

  • Method Details

    • writeLong

      public void writeLong(com.esotericsoftware.kryo.kryo5.io.Output output, long value)
      Writes value as a zig-zag varint delta from the previous write.
    • readLong

      public long readLong(com.esotericsoftware.kryo.kryo5.io.Input input)
    • write

      public void write(com.esotericsoftware.kryo.kryo5.Kryo kryo, com.esotericsoftware.kryo.kryo5.io.Output output, Long value)
      Specified by:
      write in class com.esotericsoftware.kryo.kryo5.Serializer<Long>
    • read

      public Long read(com.esotericsoftware.kryo.kryo5.Kryo kryo, com.esotericsoftware.kryo.kryo5.io.Input input, Class<? extends Long> type)
      Specified by:
      read in class com.esotericsoftware.kryo.kryo5.Serializer<Long>