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

Function encodeRevisions

db/revtree.go:832–845  ·  view source on GitHub ↗

Standard CouchDB encoding of a revision list: digests without numeric generation prefixes go in the "ids" property, and the first (largest) generation number in the "start" property. The docID parameter is informational only - and used when logging edge cases.

(ctx context.Context, docID string, revs []string)

Source from the content-addressed store, hash-verified

830// the "ids" property, and the first (largest) generation number in the "start" property.
831// The docID parameter is informational only - and used when logging edge cases.
832func encodeRevisions(ctx context.Context, docID string, revs []string) Revisions {
833 ids := make([]string, len(revs))
834 var start int
835 for i, revid := range revs {
836 gen, id := ParseRevID(ctx, revid)
837 ids[i] = id
838 if i == 0 {
839 start = gen
840 } else if gen != start-i {
841 base.DebugfCtx(ctx, base.KeyCRUD, "Found gap in revision list for doc %q. Expecting gen %v but got %v in %v", base.UD(docID), start-i, gen, revs)
842 }
843 }
844 return Revisions{RevisionsStart: start, RevisionsIds: ids}
845}
846
847// Given a revision history encoded by encodeRevisions() and a list of possible ancestor revIDs,
848// trim the history to stop at the first ancestor revID. If no ancestors are found, trim to

Callers 11

IsChannelRemovalMethod · 0.85
BenchmarkEncodeRevisionsFunction · 0.85
TestEncodeRevisionsFunction · 0.85
TestEncodeRevisionsGapFunction · 0.85
TestEncodeRevisionsZeroFunction · 0.85
GetDeltaMethod · 0.85
get1xRevFromDocMethod · 0.85
updateAndReturnDocMethod · 0.85

Calls 3

DebugfCtxFunction · 0.92
UDFunction · 0.92
ParseRevIDFunction · 0.85

Tested by 5

BenchmarkEncodeRevisionsFunction · 0.68
TestEncodeRevisionsFunction · 0.68
TestEncodeRevisionsGapFunction · 0.68
TestEncodeRevisionsZeroFunction · 0.68