diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -16,12 +16,12 @@ import ( func main() { dbconnection := flag.String("dbconnection", "mongodb://localhost:27017", "Mongo database name") dbname := flag.String("dbname", "map", "Mongo database name") - osmfile := flag.String("osmfile", "", "OSM file") - initial := flag.Bool("initial", false, "Is initial import") + osmfile := flag.String("osmfile", "./RU.osm.pbf", "Path to OSM file (PBF format only)") + initial := flag.Bool("initial", false, "Is initial import?") indexes := flag.Bool("indexes", false, "Create indexes") layersString := flag.String("layers", "nodes,ways,relations", "Layers to import") blockSize := flag.Int("block", 1000, "Block size to bulk write") - concurrency := flag.Int("concurrency", 32, "Concurrency read and write") + concurrency := flag.Int("concurrency", 32, "Workers count") flag.Parse() layers := strings.Split(*layersString, ",") r := rutina.New() @@ -34,26 +34,25 @@ func main() { db := client.Database(*dbname) if *indexes { + log.Println("Creating indexes...") if err := createIndexes(db); err != nil { log.Fatal(err) } - log.Println("Indexes created") + log.Println("Done!") } - log.Printf("Started import file %s to db %s", *osmfile, *dbname) - nodesCh := make(chan Node, 1) - waysCh := make(chan Way, 1) - relationsCh := make(chan Relation, 1) + log.Printf("Started import file %s to db %s (%d workers)", *osmfile, *dbname, *concurrency) + insertCh := make(chan Object, 1) for i := 0; i < *concurrency; i++ { worker := i r.Go(func(ctx context.Context) error { - return write(ctx, db, nodesCh, waysCh, relationsCh, *initial, *blockSize, worker) + return write(ctx, db, insertCh, *initial, *blockSize, worker) }) } r.Go(func(ctx context.Context) error { - return read(ctx, *osmfile, nodesCh, waysCh, relationsCh, *concurrency, layers) + return read(ctx, *osmfile, insertCh, *concurrency, layers) }) if err := r.Wait(); err != nil { log.Fatal(err) |