MCPcopy
hub / github.com/NVIDIA/aistore / Write

Method Write

memsys/iosgl.go:151–169  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

149}
150
151func (z *SGL) Write(p []byte) (n int, err error) {
152 wlen := len(p)
153 if needtot := z.woff + int64(wlen); needtot > z.Cap() {
154 z.grow(needtot)
155 }
156 idx, off, poff := z.woff/z.slab.Size(), z.woff%z.slab.Size(), 0
157 for wlen > 0 {
158 size := cos.MinI64(z.slab.Size()-off, int64(wlen))
159 buf := z.sgl[idx]
160 src := p[poff : poff+int(size)]
161 copy(buf[off:], src)
162 z.woff += size
163 idx++
164 off = 0
165 wlen -= int(size)
166 poff += int(size)
167 }
168 return len(p), nil
169}
170
171func (z *SGL) WriteByte(c byte) error {
172 if needtot := z.woff + 1; needtot > z.Cap() {

Callers 8

sendTextFunction · 0.95
Test_DryRunFunction · 0.95
wrfFunction · 0.95
benchWriteFunction · 0.95
benchWRFFunction · 0.95
WriteAtMethod · 0.95
benchFileFunction · 0.45
WriteToMethod · 0.45

Calls 4

CapMethod · 0.95
growMethod · 0.95
MinI64Function · 0.92
SizeMethod · 0.65

Tested by 6

sendTextFunction · 0.76
Test_DryRunFunction · 0.76
wrfFunction · 0.76
benchWriteFunction · 0.76
benchWRFFunction · 0.76
benchFileFunction · 0.36