MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / calBufferSize

Function calBufferSize

recovery_reader.go:126–136  ·  view source on GitHub ↗

calBufferSize calculates the buffer size of bufio.Reader if the size < 4 * KB, use 4 * KB as the size of buffer in bufio.Reader if the size > 4 * KB, use the nearly blockSize buffer as the size of buffer in bufio.Reader

(size int)

Source from the content-addressed store, hash-verified

124// if the size < 4 * KB, use 4 * KB as the size of buffer in bufio.Reader
125// if the size > 4 * KB, use the nearly blockSize buffer as the size of buffer in bufio.Reader
126func calBufferSize(size int) int {
127 blockSize := 4 * KB
128 if size < blockSize {
129 return blockSize
130 }
131 hasRest := (size%blockSize == 0)
132 if hasRest {
133 return (size/blockSize + 1) * blockSize
134 }
135 return size
136}
137
138func (fr *fileRecovery) release() error {
139 if fr.closed {

Callers 1

newFileRecoveryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected