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

Method asDocumentRevision

db/revision_cache_lru.go:732–754  ·  view source on GitHub ↗

asDocumentRevision copies the rev cache value into a DocumentRevision. Should only be called for non-empty revCacheValues - copies all immutable revCacheValue properties, and adds the provided body/delta.

(delta *RevisionDelta)

Source from the content-addressed store, hash-verified

730// asDocumentRevision copies the rev cache value into a DocumentRevision. Should only be called for non-empty
731// revCacheValues - copies all immutable revCacheValue properties, and adds the provided body/delta.
732func (value *revCacheValue) asDocumentRevision(delta *RevisionDelta) (DocumentRevision, error) {
733
734 docRev := DocumentRevision{
735 DocID: value.id,
736 RevID: value.revID,
737 BodyBytes: value.bodyBytes,
738 History: value.history,
739 Channels: value.channels,
740 Expiry: value.expiry,
741 Attachments: value.attachments.ShallowCopy(), // Avoid caller mutating the stored attachments
742 Delta: delta,
743 Deleted: value.deleted,
744 Removed: value.removed,
745 HlvHistory: value.hlvHistory,
746 RevCacheValueDeltaLock: &value.deltaLock,
747 }
748 // only populate CV if we have a value
749 if !value.cv.IsEmpty() {
750 docRev.CV = &value.cv
751 }
752
753 return docRev, value.err
754}
755
756// Retrieves the body etc. out of a revCacheValue. If they aren't already present, loads into the cache value using
757// the provided document.

Callers 2

loadMethod · 0.95
loadForDocMethod · 0.95

Calls 2

ShallowCopyMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected