MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / Before

Method Before

db/sequence_id.go:187–202  ·  view source on GitHub ↗

The most significant value is TriggeredBy, unless it's zero, in which case use Seq. The tricky part is that "n" sorts after "n:m" for any nonzero m

(s2 SequenceID)

Source from the content-addressed store, hash-verified

185// The most significant value is TriggeredBy, unless it's zero, in which case use Seq.
186// The tricky part is that "n" sorts after "n:m" for any nonzero m
187func (s SequenceID) Before(s2 SequenceID) bool {
188 // using SafeSequence for comparison, which takes the lower of LowSeq and Seq
189 if s.TriggeredBy == s2.TriggeredBy {
190 if s.SafeSequence() == s2.SafeSequence() {
191 // If both are equal, one sequence must be a non-zero LowSeq - sort those after the actual sequence.
192 return s.Seq < s2.Seq
193 }
194 return s.SafeSequence() < s2.SafeSequence() // the simple case: untriggered, or triggered by same sequence
195 } else if s.TriggeredBy == 0 {
196 return s.SafeSequence() < s2.TriggeredBy // s2 triggered but not s
197 } else if s2.TriggeredBy == 0 {
198 return s.TriggeredBy <= s2.SafeSequence() // s triggered but not s2
199 } else {
200 return s.TriggeredBy < s2.TriggeredBy // both triggered, but by different sequences
201 }
202}
203
204// Create a zero'd out since value (eg, initial since value) based on the sequence type
205func CreateZeroSinceValue() SequenceID {

Callers 8

getCheckpointHighSeqMethod · 0.95
VerifyClaimsFunction · 0.80
TestCompareSequenceIDsFunction · 0.80
setLastCheckpointSeqMethod · 0.80
appendUserFeedMethod · 0.80

Calls 1

SafeSequenceMethod · 0.95

Tested by 2

TestCompareSequenceIDsFunction · 0.64