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

Method CalculateBytes

db/revision_cache_lru.go:848–863  ·  view source on GitHub ↗

CalculateBytes will calculate the bytes from revisions in the document, body and channels on the document

()

Source from the content-addressed store, hash-verified

846
847// CalculateBytes will calculate the bytes from revisions in the document, body and channels on the document
848func (rev *DocumentRevision) CalculateBytes() {
849 var totalBytes int
850 for v := range rev.Channels {
851 bytes := len([]byte(v))
852 totalBytes += bytes
853 }
854 // calculate history
855 digests, _ := GetStringArrayProperty(rev.History, RevisionsIds)
856 historyBytes := 32 * len(digests)
857 totalBytes += historyBytes
858 // add body bytes into calculation
859 totalBytes += len(rev.BodyBytes)
860
861 // convert the int to int64 type and assign to document revision
862 rev.MemoryBytes = int64(totalBytes)
863}
864
865// CalculateDeltaBytes will calculate bytes from delta channels, delta revisions and delta body
866func (delta *RevisionDelta) CalculateDeltaBytes() {

Callers 5

PutMethod · 0.80
UpsertMethod · 0.80
loadMethod · 0.80
loadForDocMethod · 0.80

Calls 1

GetStringArrayPropertyFunction · 0.85

Tested by 1