aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--skate/cmd/skate-derive-key/main.go17
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))
}