diff options
Diffstat (limited to 'vendor/github.com/hamba/avro/v2/reader_skip.go')
| -rw-r--r-- | vendor/github.com/hamba/avro/v2/reader_skip.go | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/vendor/github.com/hamba/avro/v2/reader_skip.go b/vendor/github.com/hamba/avro/v2/reader_skip.go new file mode 100644 index 0000000..94288c8 --- /dev/null +++ b/vendor/github.com/hamba/avro/v2/reader_skip.go @@ -0,0 +1,79 @@ +package avro + +// SkipNBytes skips the given number of bytes in the reader. +func (r *Reader) SkipNBytes(n int) { + read := 0 + for read < n { + if r.head == r.tail { + if !r.loadMore() { + return + } + } + + if read+r.tail-r.head < n { + read += r.tail - r.head + r.head = r.tail + continue + } + + r.head += n - read + read += n - read + } +} + +// SkipBool skips a Bool in the reader. +func (r *Reader) SkipBool() { + _ = r.readByte() +} + +// SkipInt skips an Int in the reader. +func (r *Reader) SkipInt() { + var n int + for r.Error == nil && n < maxIntBufSize { + b := r.readByte() + if b&0x80 == 0 { + break + } + n++ + } +} + +// SkipLong skips a Long in the reader. +func (r *Reader) SkipLong() { + var n int + for r.Error == nil && n < maxLongBufSize { + b := r.readByte() + if b&0x80 == 0 { + break + } + n++ + } +} + +// SkipFloat skips a Float in the reader. +func (r *Reader) SkipFloat() { + r.SkipNBytes(4) +} + +// SkipDouble skips a Double in the reader. +func (r *Reader) SkipDouble() { + r.SkipNBytes(8) +} + +// SkipString skips a String in the reader. +func (r *Reader) SkipString() { + size := r.ReadLong() + if size <= 0 { + return + } + r.SkipNBytes(int(size)) +} + +// SkipBytes skips Bytes in the reader. +func (r *Reader) SkipBytes() { + size := r.ReadLong() + if size <= 0 { + return + } + r.SkipNBytes(int(size)) +} |
