Class BarrierCutDecoder
java.lang.Object
io.krabka.streams.columnar.barrier.BarrierCutDecoder
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<BarrierCut> decode(byte[] key, byte[] value) Decodes one__barrier_staterecord into a cut.
-
Field Details
-
TOPIC
The internal topic the coordinator publishes barrier state to.- See Also:
-
-
Method Details
-
decode
Decodes one__barrier_staterecord into a cut.- Parameters:
key- the record key bytesvalue- 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
-