MCPcopy Create free account
hub / github.com/apache/fory / discardFromReader

Method discardFromReader

go/fory/buffer.go:138–159  ·  view source on GitHub ↗
(length int, errOut *Error)

Source from the content-addressed store, hash-verified

136}
137
138func (b *ByteBuffer) discardFromReader(length int, errOut *Error) bool {
139 var scratch [8192]byte
140 for length > 0 {
141 n := length
142 if n > len(scratch) {
143 n = len(scratch)
144 }
145 readBytes, err := io.ReadFull(b.reader, scratch[:n])
146 length -= readBytes
147 if err != nil {
148 if errOut != nil {
149 if err == io.EOF || err == io.ErrUnexpectedEOF {
150 *errOut = BufferOutOfBoundError(b.readerIndex, n, readBytes)
151 } else {
152 *errOut = DeserializationError(fmt.Sprintf("stream read error: %v", err))
153 }
154 }
155 return false
156 }
157 }
158 return true
159}
160
161// grow ensures there's space for n more bytes. Hot path is inlined.
162func (b *ByteBuffer) grow(n int) {

Callers 1

SkipMethod · 0.95

Calls 2

BufferOutOfBoundErrorFunction · 0.85
DeserializationErrorFunction · 0.85

Tested by

no test coverage detected