From befb8d36c08bc42e5c4307dc1d7c6ed0104507ad Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Sat, 20 Jan 2024 13:29:33 +0800 Subject: [PATCH] overfetch param --- main.go | 3 ++- pmtiles/makesync.go | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index eb39417..13b42f0 100644 --- a/main.go +++ b/main.go @@ -74,6 +74,7 @@ var cli struct { Sync struct { Existing string `arg:"" type:"existingfile"` Syncfile string `arg:"" type:"existingfile"` + Overfetch float32 `default:0.05 help:"What ratio of extra data to download to minimize # requests; 0.2 is 20%"` } `cmd:"" hidden:""` Serve struct { @@ -202,7 +203,7 @@ func main() { logger.Fatalf("Failed to makesync archive, %v", err) } case "sync ": - err := pmtiles.Sync(logger, cli.Sync.Existing, cli.Sync.Syncfile) + err := pmtiles.Sync(logger, cli.Sync.Existing, cli.Sync.Syncfile, cli.Sync.Overfetch) if err != nil { logger.Fatalf("Failed to sync archive, %v", err) } diff --git a/pmtiles/makesync.go b/pmtiles/makesync.go index e93f210..f2ebc2c 100644 --- a/pmtiles/makesync.go +++ b/pmtiles/makesync.go @@ -255,7 +255,7 @@ func Makesync(logger *log.Logger, cli_version string, file string, block_size_kb return nil } -func Sync(logger *log.Logger, file string, syncfilename string) error { +func Sync(logger *log.Logger, file string, syncfilename string, overfetch float32) error { start := time.Now() syncfile, err := os.Open(syncfilename) @@ -421,7 +421,6 @@ func Sync(logger *log.Logger, file string, syncfilename string) error { ranges = append(ranges,SrcDstRange{SrcOffset:v.Offset,DstOffset:v.Offset,Length:v.Length}) } - overfetch := float32(0.05) requests, _ := MergeRanges(ranges, overfetch) fmt.Printf("need %d requests with overfetch=%f.\n", requests.Len(), overfetch)