Class FieldByteAccumulator

java.lang.Object
ch.qos.logback.classic.kryo.FieldByteAccumulator

public class FieldByteAccumulator extends Object
Accumulates bytes written to an Output or read from an Input, keyed by field name.

Write accounting uses Output.position() (suitable for a fixed buffer with no flush). Read accounting uses Input.total() so deltas remain correct across buffer refills.

  • Constructor Details

  • Method Details

    • write

      public int write(com.esotericsoftware.kryo.kryo5.io.Output output, String field, Runnable writeAction)
      Runs writeAction and adds the number of bytes written to field.
      Returns:
      bytes written by this call
    • read

      public <T> T read(com.esotericsoftware.kryo.kryo5.io.Input input, String field, FieldByteAccumulator.InputAction<T> readAction)
      Runs readAction and adds the number of bytes read to field.
      Returns:
      the value produced by readAction
    • readLong

      public long readLong(com.esotericsoftware.kryo.kryo5.io.Input input, String field, LongSupplier readAction)
      Like read(Input, String, InputAction) but for a primitive long, so the result is not boxed.
    • snapshot

      public Map<String,Long> snapshot()
      Unmodifiable view of cumulative bytes per field.
    • total

      public long total()
    • reset

      public void reset()
    • merge

      public void merge(FieldByteAccumulator other)
      Adds other's field totals into this instance. Used when Kryo is rebuilt on a CLOSE/HEADER so accounting survives a codec-epoch reset.
    • dump

      public void dump()
      Dumps all accumulated field byte counts and the total to System.out.
    • dump

      public void dump(PrintStream out)
      Dumps all accumulated field byte counts and the total to out.
    • toString

      public String toString()
      Overrides:
      toString in class Object