// skate-from-unstructured tries to parse various pieces of information from // the unstructured field in refs. package main import ( "flag" "log" "os" "runtime" "git.archive.org/martin/cgraph/skate" "git.archive.org/martin/cgraph/skate/parallel" "github.com/segmentio/encoding/json" ) var ( numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers") batchSize = flag.Int("b", 100000, "batch size") ) func main() { pp := parallel.NewProcessor(os.Stdin, os.Stdout, func(p []byte) ([]byte, error) { var ( ref skate.Ref err error ) if err = json.Unmarshal(p, &ref); err != nil { return nil, err } if err = skate.ParseUnstructured(&ref); err != nil { return nil, err } return skate.JsonMarshalNewline(&ref) }) pp.NumWorkers = *numWorkers pp.BatchSize = *batchSize if err := pp.Run(); err != nil { log.Fatal(err) } }