diff options
Diffstat (limited to 'skate/cmd')
-rw-r--r-- | skate/cmd/skate-map/main.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go index 259e1aa..ee02875 100644 --- a/skate/cmd/skate-map/main.go +++ b/skate/cmd/skate-map/main.go @@ -49,6 +49,7 @@ var ( numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers") batchSize = flag.Int("b", 50000, "batch size") verbose = flag.Bool("verbose", false, "show progress") + keyPrefix = flag.String("p", "", "a key prefix to use") extraValue = flag.String("x", "", "extra value to pass to configurable mappers") ) @@ -60,17 +61,20 @@ func main() { // [ ] maybe wrap jq and parallel for arbitrary nested keys availableMappers := map[string]skate.Mapper{ "id": skate.Identity, - "ff": skate.WithPrefix(skate.CreateFixedMapper(*extraValue), "ff"), - "ti": skate.WithPrefix(skate.MapperTitle, "ti"), - "tn": skate.WithPrefix(skate.MapperTitleNormalized, "tn"), - "ty": skate.WithPrefix(skate.MapperTitleNysiis, "ty"), - "ts": skate.WithPrefix(skate.MapperTitleSandcrawler, "ts"), + "ff": skate.CreateFixedMapper(*extraValue), + "ti": skate.MapperTitle, + "tn": skate.MapperTitleNormalized, + "ty": skate.MapperTitleNysiis, + "ts": skate.MapperTitleSandcrawler, } switch { case *mapperName != "": if f, ok := availableMappers[*mapperName]; !ok { log.Fatalf("unknown mapper name: %v", *mapperName) } else { + if *keyPrefix != "" { + f = skate.WithPrefix(f, *keyPrefix) + } pp := parallel.NewProcessor(os.Stdin, os.Stdout, f.AsTSV) pp.NumWorkers = *numWorkers pp.BatchSize = *batchSize |