From 5e7543c3f4612dacd7f1d4e04c75cd48ecb67b0c Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Thu, 29 Apr 2021 15:28:38 +0200 Subject: no default prefix --- skate/cmd/skate-map/main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'skate') 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 -- cgit v1.2.3