Offset Commit Advancement

easy · distributed-systems, streaming, logs

Offset Commit Advancement

A consumer has already committed offset committed. It has processed a set of additional offsets (unordered). It can only advance the commit to the highest contiguous offset starting from committed + 1.

Given the current committed offset and the set of processed offsets, compute the new committed offset.

Function signature

func AdvanceCommitOffset(committed int, processed []int) int

Example

committed = 4
processed = [6,5,8]
output = 6

Constraints

  • committed >= 0
  • 0 <= len(processed) <= 200000
  • processed may include duplicates
Run tests to see results
No issues detected