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

Method Dict

csup/bytes.go:113–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111}
112
113func (b *BytesEncoder) Dict() (PrimitiveEncoder, []byte, []uint32) {
114 if len(b.bytes) == 0 {
115 return nil, nil, nil
116 }
117 m := make(map[string]byte)
118 var counts []uint32
119 index := make([]byte, len(b.offsets.vals)-1)
120 table := vector.NewBytesTableEmpty(256)
121 for k := range uint32(len(index)) {
122 tag, ok := m[string(b.value(k))]
123 if !ok {
124 tag = byte(len(counts))
125 v := b.value(k)
126 m[string(v)] = tag
127 table.Append(v)
128 counts = append(counts, 0)
129 if len(counts) > math.MaxUint8 {
130 return nil, nil, nil
131 }
132 }
133 index[k] = tag
134 counts[tag]++
135 }
136 encoder := NewBytesEncoder(b.typ)
137 encoder.Write(vector.NewBytes(table))
138 return encoder, index, counts
139}
140
141func (b *BytesEncoder) ConstValue() super.Value {
142 return super.NewValue(b.typ, b.value(0))

Callers

nothing calls this directly

Calls 6

valueMethod · 0.95
WriteMethod · 0.95
NewBytesTableEmptyFunction · 0.92
NewBytesFunction · 0.92
NewBytesEncoderFunction · 0.85
AppendMethod · 0.45

Tested by

no test coverage detected