incremental job uses settings

This commit is contained in:
NatureFreshMilk 2019-02-07 08:35:57 +01:00
parent 1ee78ee106
commit 1d72b124d1
2 changed files with 23 additions and 5 deletions

View File

@ -7,6 +7,14 @@ import (
"github.com/sirupsen/logrus"
)
const (
SETTING_LAST_MTIME = "last_mtime"
SETTING_LASTX = "last_x"
SETTING_LASTY = "last_y"
SETTING_LASTZ = "last_z"
SETTING_INITIAL_RUN = "initial_run"
)
/*
sqlite perf: https://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite?rq=1
PRAGMA synchronous = OFF

View File

@ -3,7 +3,9 @@ package tilerendererjob
import (
"mapserver/app"
"mapserver/coords"
"mapserver/mapobjectdb"
"time"
"strconv"
"github.com/sirupsen/logrus"
)
@ -14,17 +16,25 @@ type IncrementalRenderEvent struct {
func incrementalRender(ctx *app.App, jobs chan *coords.TileCoords) {
rstate := ctx.Config.RenderState
str, err := ctx.Objectdb.GetSetting(mapobjectdb.SETTING_LAST_MTIME, "0")
if err != nil {
panic(err)
}
lastMtime, err := strconv.ParseInt(str, 10, 64)
if err != nil {
panic(err)
}
fields := logrus.Fields{
"LastMtime": rstate.LastMtime,
"LastMtime": lastMtime,
}
logrus.WithFields(fields).Info("Starting incremental rendering job")
for true {
start := time.Now()
result, err := ctx.BlockAccessor.FindMapBlocksByMtime(rstate.LastMtime, ctx.Config.RenderingFetchLimit, ctx.Config.Layers)
result, err := ctx.BlockAccessor.FindMapBlocksByMtime(lastMtime, ctx.Config.RenderingFetchLimit, ctx.Config.Layers)
if err != nil {
panic(err)
@ -35,8 +45,8 @@ func incrementalRender(ctx *app.App, jobs chan *coords.TileCoords) {
continue
}
rstate.LastMtime = result.LastMtime
ctx.Config.Save()
lastMtime = result.LastMtime
ctx.Objectdb.SetSetting(mapobjectdb.SETTING_LAST_MTIME, strconv.FormatInt(lastMtime, 10))
tiles := renderMapblocks(ctx, jobs, result.List)