| 59 | } |
| 60 | |
| 61 | func (d *DictEncoder) Metadata(cctx *Context, off uint64) (uint64, ID) { |
| 62 | if d.const_ != nil { |
| 63 | return off, cctx.enter(d.const_) |
| 64 | } |
| 65 | if d.counts == nil { |
| 66 | return d.PrimitiveEncoder.Metadata(cctx, off) |
| 67 | } |
| 68 | meta := &Dict{Length: uint32(len(d.index))} |
| 69 | off, meta.Values = d.PrimitiveEncoder.Metadata(cctx, off) |
| 70 | off, meta.Counts = d.counts.Segment(off) |
| 71 | len := uint64(len(d.index)) |
| 72 | meta.Index = Segment{ |
| 73 | Offset: off, |
| 74 | Length: len, |
| 75 | MemLength: len, |
| 76 | } |
| 77 | return off + len, cctx.enter(meta) |
| 78 | } |
| 79 | |
| 80 | func (d *DictEncoder) Emit(w io.Writer) error { |
| 81 | if d.const_ != nil { |