()
| 111 | } |
| 112 | |
| 113 | func (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 | |
| 141 | func (b *BytesEncoder) ConstValue() super.Value { |
| 142 | return super.NewValue(b.typ, b.value(0)) |
nothing calls this directly
no test coverage detected