Touch is called for each offset at which a value occurs. From this, we derive the runs of values and nones interleaved beginning with the first run of nones (which may be 0). Whenever there is a gap in values, we record the gap size as a run. When touch is called consecutively, we wait for for a gap
(off uint32)
| 105 | // When touch is called consecutively, we wait for for a gap before |
| 106 | // recording the none run immediately followed by the gap. |
| 107 | func (r *RLE) Touch(off uint32) { |
| 108 | if r.prediction == r.last { |
| 109 | // This happens only on first call. |
| 110 | // Emit length of none run. |
| 111 | r.emit(off) |
| 112 | r.last = off |
| 113 | } else if r.prediction != off { |
| 114 | // emit length of value run |
| 115 | r.emit(r.prediction - r.last) |
| 116 | // emit length of none run |
| 117 | r.emit(off - r.prediction) |
| 118 | r.last = off |
| 119 | } |
| 120 | r.prediction = off + 1 |
| 121 | } |
| 122 | |
| 123 | func (r *RLE) End(off uint32) []uint32 { |
| 124 | if r.prediction == r.last { |