CalculateBytes will calculate the bytes from revisions in the document, body and channels on the document
()
| 846 | |
| 847 | // CalculateBytes will calculate the bytes from revisions in the document, body and channels on the document |
| 848 | func (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 |
| 866 | func (delta *RevisionDelta) CalculateDeltaBytes() { |