Class BarrierCutDecoder

java.lang.Object
io.krabka.streams.columnar.barrier.BarrierCutDecoder

public final class BarrierCutDecoder extends Object
Decodes the cut records of the internal __barrier_state topic.

The topic carries three record kinds and the key discriminates them: a group definition, an injection start, and a cut. Only the cut kind matters to a client, so the decoder returns an empty result for the other two and for a tombstone. Every integer is big-endian and a string is an i16 byte length and then UTF-8 bytes, exactly as the barrier design freezes the format for all three krabka streams libraries.

Malformed bytes raise ColumnarException. The decoder never returns a partly filled cut.

Example

for (var record : consumer.poll(Duration.ofSeconds(1))) {
    BarrierCutDecoder.decode(record.key(), record.value())
        .filter(BarrierCut::complete)
        .ifPresent(cut -> System.out.println(cut.epoch() + " " + cut.offsets()));
}
  • Field Details

    • TOPIC

      public static final String TOPIC
      The internal topic the coordinator publishes barrier state to.
      See Also:
  • Method Details

    • decode

      public static Optional<BarrierCut> decode(byte[] key, byte[] value)
      Decodes one __barrier_state record into a cut.
      Parameters:
      key - the record key bytes
      value - the record value bytes, or null for a tombstone
      Returns:
      the cut, or empty when the record is not a cut
      Throws:
      ColumnarException - if the key or the value is malformed