From 52fcca1dffa4e9dd5a2656e352f1a1e1d7a331a0 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 15 Sep 2020 16:43:07 -0400 Subject: [PATCH] mlr rename --- go/src/miller/types/mlrmap_accessors.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/go/src/miller/types/mlrmap_accessors.go b/go/src/miller/types/mlrmap_accessors.go index 1da20103f..f72773924 100644 --- a/go/src/miller/types/mlrmap_accessors.go +++ b/go/src/miller/types/mlrmap_accessors.go @@ -328,6 +328,24 @@ func (this *Mlrmap) GetSelectedValuesJoined(selectedFieldNames []string) (string return buffer.String(), true } +// ---------------------------------------------------------------- +func (this *Mlrmap) Rename(oldKey *string, newKey *string) bool { + entry := this.findEntry(oldKey) + if entry == nil { + return false + } + + copy := *oldKey + entry.Key = © + + if this.keysToEntries != nil { + delete(this.keysToEntries, *oldKey) + this.keysToEntries[*newKey] = entry + } + + return true +} + // ================================================================ // TO BE PORTED // ================================================================