diff --git a/CHANGELOG.md b/CHANGELOG.md index 290c80d2..c0355d03 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,10 @@ Types of changes ## [1.27.0] -- `Added` parameter `maxstrlen` to `sha3` and `haqhInCSV` masks -- `Fixed` type casting issues when using `add`, `add-transient`, `choice` or `hash` to create complex structures +- `Added` parameter `maxstrlen` to `sha3` and `hashInCSV` masks +- `Fixed` type casting issues when using `add`, `add-transient`, `choice`, `weightedChoice` or `hash` to create complex structures +- `Fixed` performance issue with `pipe` mask +- `Fixed` performance issue with selectors ## [1.26.2] diff --git a/pkg/pipe/pipe.go b/pkg/pipe/pipe.go index db591117..7fc07520 100644 --- a/pkg/pipe/pipe.go +++ b/pkg/pipe/pipe.go @@ -55,26 +55,22 @@ func NewMask(seed int64, injectParent string, injectRoot string, caches map[stri return MaskEngine{"", pipeline, injectParent, injectRoot}, err } -func (me MaskEngine) MaskContext(e model.Dictionary, key string, context ...model.Dictionary) (model.Dictionary, error) { +func (me MaskEngine) MaskContext(entry model.Dictionary, key string, context ...model.Dictionary) (model.Dictionary, error) { log.Info().Msg("Mask pipe") var result []model.Entry input := []model.Dictionary{} - // copy := model.CopyDictionary(e) - copy := e - - value, ok := e.GetValue(key) + value, ok := entry.GetValue(key) if !ok || value == nil { - return copy, nil + return entry, nil } - for _, elemInput := range model.CleanDictionarySlice(e.Get(key)) { + for _, elemInput := range model.CleanDictionarySlice(entry.Get(key)) { if len(me.injectParent) > 0 { - elemInput.Set(me.injectParent, copy) + elemInput.Set(me.injectParent, entry) } if len(me.injectRoot) > 0 { - rootcopy := model.CopyDictionary(context[0]) - elemInput.Set(me.injectRoot, rootcopy) + elemInput.Set(me.injectRoot, model.CopyDictionary(context[0])) } input = append(input, elemInput) } @@ -85,7 +81,7 @@ func (me MaskEngine) MaskContext(e model.Dictionary, key string, context ...mode if len(me.source) > 0 { over.MDC().Set("config", me.source) } - // TODO: possible refactoring + // possible refactoring // model.NewSourceFromSlice(input). // Process(model.NewCounterProcessWithCallback("input-line", 1, updateContext)). // Process(me.pipeline). @@ -100,7 +96,7 @@ func (me MaskEngine) MaskContext(e model.Dictionary, key string, context ...mode over.MDC().Set("path", savePath) over.MDC().Set("context", saveContext) if err != nil { - return copy, err + return entry, err } for _, dict := range result { if len(me.injectParent) > 0 { @@ -110,8 +106,8 @@ func (me MaskEngine) MaskContext(e model.Dictionary, key string, context ...mode dict.(model.Dictionary).Delete(me.injectRoot) } } - copy.Set(key, result) - return copy, nil + entry.Set(key, result) + return entry, nil } // Factory create a mask from a configuration