From 28191109a80f7290ae6f680733c9856b53dd05b0 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 23 Nov 2023 18:17:45 +0000 Subject: [PATCH] Labels: add fake versions of SymbolTable apis So we can use them where necessary for internlabels implementation. Signed-off-by: Bryan Boreham --- model/labels/labels.go | 21 +++++++++++++++++++++ model/labels/labels_stringlabels.go | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/model/labels/labels.go b/model/labels/labels.go index 9e74b3d31b..f145dfc5f8 100644 --- a/model/labels/labels.go +++ b/model/labels/labels.go @@ -420,11 +420,32 @@ type ScratchBuilder struct { add Labels } +// Symbol-table is no-op, just for api parity with dedupelabels. +type SymbolTable struct{} + +func NewSymbolTable() *SymbolTable { return nil } + +func (t *SymbolTable) Len() int { return 0 } + // NewScratchBuilder creates a ScratchBuilder initialized for Labels with n entries. func NewScratchBuilder(n int) ScratchBuilder { return ScratchBuilder{add: make([]Label, 0, n)} } +// NewBuilderWithSymbolTable creates a Builder, for api parity with dedupelabels. +func NewBuilderWithSymbolTable(_ *SymbolTable) *Builder { + return NewBuilder(EmptyLabels()) +} + +// NewScratchBuilderWithSymbolTable creates a ScratchBuilder, for api parity with dedupelabels. +func NewScratchBuilderWithSymbolTable(_ *SymbolTable, n int) ScratchBuilder { + return NewScratchBuilder(n) +} + +func (b *ScratchBuilder) SetSymbolTable(_ *SymbolTable) { + // no-op +} + func (b *ScratchBuilder) Reset() { b.add = b.add[:0] } diff --git a/model/labels/labels_stringlabels.go b/model/labels/labels_stringlabels.go index b84964776c..9ac4e46503 100644 --- a/model/labels/labels_stringlabels.go +++ b/model/labels/labels_stringlabels.go @@ -681,3 +681,24 @@ func (b *ScratchBuilder) Overwrite(ls *Labels) { marshalLabelsToSizedBuffer(b.add, b.overwriteBuffer) ls.data = yoloString(b.overwriteBuffer) } + +// Symbol-table is no-op, just for api parity with dedupelabels. +type SymbolTable struct{} + +func NewSymbolTable() *SymbolTable { return nil } + +func (t *SymbolTable) Len() int { return 0 } + +// NewBuilderWithSymbolTable creates a Builder, for api parity with dedupelabels. +func NewBuilderWithSymbolTable(_ *SymbolTable) *Builder { + return NewBuilder(EmptyLabels()) +} + +// NewScratchBuilderWithSymbolTable creates a ScratchBuilder, for api parity with dedupelabels. +func NewScratchBuilderWithSymbolTable(_ *SymbolTable, n int) ScratchBuilder { + return NewScratchBuilder(n) +} + +func (b *ScratchBuilder) SetSymbolTable(_ *SymbolTable) { + // no-op +}