-
Notifications
You must be signed in to change notification settings - Fork 98
/
reader_skip.go
79 lines (69 loc) · 1.27 KB
/
reader_skip.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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))
}