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

Method Dict

csup/scode.go:109–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107}
108
109func (p *ScodeEncoder) Dict() (PrimitiveEncoder, []byte, []uint32) {
110 m := make(map[string]byte)
111 var counts []uint32
112 index := make([]byte, p.count)
113 entries := NewScodeEncoder(p.typ)
114 var k uint32
115 it := p.bytes.Iter()
116 for !it.Done() {
117 v := it.Next()
118 tag, ok := m[string(v)]
119 if !ok {
120 tag = byte(len(counts))
121 m[string(v)] = tag
122 counts = append(counts, 0)
123 entries.WriteBytes(v)
124 if len(counts) > math.MaxUint8 {
125 return nil, nil, nil
126 }
127 }
128 index[k] = tag
129 counts[tag]++
130 k++
131 }
132 return entries, index, counts
133}
134
135func (p *ScodeEncoder) ConstValue() super.Value {
136 it := p.bytes.Iter()

Callers

nothing calls this directly

Calls 5

WriteBytesMethod · 0.95
NewScodeEncoderFunction · 0.85
IterMethod · 0.80
DoneMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected