Skip to content

Commit

Permalink
overfetch param
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Jan 20, 2024
1 parent 869e91d commit befb8d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -202,7 +203,7 @@ func main() {
logger.Fatalf("Failed to makesync archive, %v", err)
}
case "sync <existing> <syncfile>":
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)
}
Expand Down
3 changes: 1 addition & 2 deletions pmtiles/makesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit befb8d3

Please sign in to comment.