diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-04-15 21:32:40 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-04-19 20:29:17 +0200 |
commit | a7d306b3a6847dad846ea10357589995fbc9af16 (patch) | |
tree | b1edb0c0cc1348ce4fddc6140fb8ae2730e5b6e7 | |
parent | ac1e5735e19595f5a03154ba059ff5132547c643 (diff) | |
download | refcat-a7d306b3a6847dad846ea10357589995fbc9af16.tar.gz refcat-a7d306b3a6847dad846ea10357589995fbc9af16.zip |
tweak fixed field
-rw-r--r-- | skate/cmd/skate-derive-key/main.go | 17 |
1 files changed, 11 insertions, 6 deletions
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)) } |