MCPcopy Create free account
hub / github.com/brimdata/super / EndContainerWithNones

Method EndContainerWithNones

scode/builder.go:66–110  ·  view source on GitHub ↗
(nopts int, nones []int)

Source from the content-addressed store, hash-verified

64}
65
66func (b *Builder) EndContainerWithNones(nopts int, nones []int) {
67 if nopts == 0 {
68 b.EndContainer()
69 return
70 }
71 // Pop the container body offset off the stack.
72 bodyOff := b.containers[len(b.containers)-1]
73 b.containers = b.containers[:len(b.containers)-1]
74 bitLen := (nopts + 7) >> 3
75 bitSize := SizeOfUvarint(uint64(bitLen))
76 bitTag := toTag(bitLen)
77 bodyLen := len(b.bytes) - bodyOff
78 tag := toTag(bodyLen + bitSize + bitLen)
79 tagSize := SizeOfUvarint(tag)
80 // BeginContainer allocated one byte for the container tag.
81 tagOff := bodyOff - 1
82 if tagSize+bitSize+bitLen <= 1 {
83 panic("bad tag/bit")
84 }
85 for range bitSize + bitLen {
86 // Always add bytes at the end to pad for the none bits so when we
87 // do the overlapping copy it works if the container body is smaller
88 // than the nones elem.
89 b.bytes = append(b.bytes, 0)
90 }
91 // Always need additional space for the tag and bits, so move body over.
92 b.bytes = append(b.bytes[:tagOff+tagSize+bitSize+bitLen], b.bytes[bodyOff:len(b.bytes)-(bitSize+bitLen)]...)
93 if binary.PutUvarint(b.bytes[tagOff:], tag) != tagSize {
94 panic("bad container tag size")
95 }
96 if binary.PutUvarint(b.bytes[tagOff+tagSize:], bitTag) != bitSize {
97 panic("bad container bits tag size")
98 }
99 bitsOff := tagOff + tagSize + bitSize
100 bits := b.bytes[bitsOff : bitsOff+bitLen]
101 for k := range bits {
102 bits[k] = 0
103 }
104 for _, k := range nones {
105 if k>>3 >= bitLen {
106 panic(k)
107 }
108 bits[k>>3] |= 1 << (k & 7)
109 }
110}
111
112// TransformContainer calls transform, passing it the body of the most recently
113// opened container and replacing the original body with the return value. It

Callers 10

evalMethod · 0.95
toRecordMethod · 0.95
SerializeMethod · 0.80
recMethod · 0.80
EvalMethod · 0.80
EvalMethod · 0.80
recodeMethod · 0.80
toRecordMethod · 0.80
toRecordMethod · 0.80
decodeRecordMethod · 0.80

Implementers 15

DynamicBuildervector/builder.go
recordBuildervector/builder.go
arraySetBuildervector/builder.go
mapBuildervector/builder.go
unionBuildervector/builder.go
fusionBuildervector/builder.go
enumBuildervector/builder.go
intBuildervector/builder.go
uintBuildervector/builder.go
floatBuildervector/builder.go
boolBuildervector/builder.go
bytesStringTypeBuildervector/builder.go

Calls 3

EndContainerMethod · 0.95
SizeOfUvarintFunction · 0.85
toTagFunction · 0.85

Tested by

no test coverage detected