From a7d306b3a6847dad846ea10357589995fbc9af16 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Thu, 15 Apr 2021 21:32:40 +0200 Subject: tweak fixed field --- skate/cmd/skate-derive-key/main.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'skate/cmd') diff --git a/skate/cmd/skate-derive-key/main.go b/skate/cmd/skate-derive-key/main.go index b5b13f2..25f6b8a 100644 --- a/skate/cmd/skate-derive-key/main.go +++ b/skate/cmd/skate-derive-key/main.go @@ -35,7 +35,7 @@ import ( var ( keyFuncName = flag.String("f", "tsand", "key function name, other: title, tnorm, tnysi, tsand") - fixedField = flag.String("F", "", "extract value from a fixed top level field, e.g. source_release_ident, ...") + fixedField = flag.String("F", "", "extract string value from a fixed top level field, e.g. source_release_ident, ...") numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers") batchSize = flag.Int("b", 50000, "batch size") verbose = flag.Bool("verbose", false, "show progress") @@ -69,11 +69,14 @@ func main() { if !ok { return "", "", nil } - s, ok := v.(string) - if !ok { + switch t := v.(type) { + case string: + return "", t, nil + case int, int64, float32, float64: + return "", fmt.Sprintf("%v", t), nil + default: return "", "", nil } - return "", s, nil } } else { if keyFunc, ok = keyOpts[*keyFuncName]; !ok { @@ -88,7 +91,10 @@ func main() { defer f.Close() log.SetOutput(f) } - started := time.Now() + if *verbose { + started := time.Now() + defer log.Printf("took: %s", time.Since(started)) + } pp := parallel.NewProcessor(os.Stdin, os.Stdout, func(p []byte) ([]byte, error) { ident, key, err := keyFunc(p) if err != nil { @@ -111,5 +117,4 @@ func main() { if err := pp.Run(); err != nil { log.Fatal(err) } - log.Printf("took: %s", time.Since(started)) } -- cgit v1.2.3