MCPcopy
hub / github.com/perkeep/perkeep / approxSerializedSize

Method approxSerializedSize

pkg/blobserver/blobpacked/blobpacked.go:1694–1702  ·  view source on GitHub ↗

approxSerializedSize reports how big this Manifest will be (approximately), once encoded as JSON. This is used as a hint by the packer to decide when to keep trying to add blobs. If this number is too low, the packer backs up (at a slight performance cost) but is still correct. If this approximation

()

Source from the content-addressed store, hash-verified

1692// of a number, it just causes multiple zip files to be created when
1693// the original blobs might've just barely fit.
1694func (mf *Manifest) approxSerializedSize() int {
1695 // Empirically (for sha1-* blobrefs) it's 204 bytes fixed
1696 // encoding overhead (pre-compression), and 119 bytes per
1697 // encoded DataBlob.
1698 // And empirically, it compresses down to 30% of its size with flate.
1699 // So use the sha1 numbers but conseratively assume only 50% compression,
1700 // to make up for longer sha-3 blobrefs.
1701 return (204 + len(mf.DataBlobs)*119) / 2
1702}
1703
1704type countWriter struct {
1705 w io.Writer

Callers 1

writeAZipMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected