Added geom indexing environment options

T38IDXGEOM  -- Point threshold for indexing geometry
T38IDXMULTI -- Child threshold for indexing multi/collection

Default is 64
Using zero will disable indexing

Example:

T38IDXGEOM=0 tile38-server    # disables geometry indexing
T38IDXGEOM=256 tile38-server  # indexing geometries 256+ points
This commit is contained in:
tidwall 2018-10-19 06:29:47 -07:00
parent d64aad9be0
commit 8ee4c10862
2 changed files with 19 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"runtime/debug" "runtime/debug"
"strconv"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -63,6 +64,9 @@ type Controller struct {
config *Config config *Config
epc *endpoint.Manager epc *endpoint.Manager
// env opts
geomParseOpts geojson.ParseOptions
// atomics // atomics
followc aint // counter increases when follow property changes followc aint // counter increases when follow property changes
statsTotalConns aint // counter for total connections statsTotalConns aint // counter for total connections
@ -140,6 +144,7 @@ func ListenAndServeEx(host string, port int, dir string, ln *net.Listener, http
http: http, http: http,
pubsub: newPubsub(), pubsub: newPubsub(),
} }
c.hookex.Expired = func(item expire.Item) { c.hookex.Expired = func(item expire.Item) {
switch v := item.(type) { switch v := item.(type) {
case *Hook: case *Hook:
@ -159,6 +164,19 @@ func ListenAndServeEx(host string, port int, dir string, ln *net.Listener, http
if err != nil { if err != nil {
return err return err
} }
c.geomParseOpts = *geojson.DefaultParseOptions
n, err := strconv.ParseUint(os.Getenv("T38IDXGEOM"), 10, 32)
if err == nil {
c.geomParseOpts.IndexGeometry = int(n)
}
n, err = strconv.ParseUint(os.Getenv("T38IDXMULTI"), 10, 32)
if err == nil {
c.geomParseOpts.IndexChildren = int(n)
}
log.Debugf("geom indexing: %d", c.geomParseOpts.IndexGeometry)
log.Debugf("multi indexing: %d", c.geomParseOpts.IndexChildren)
// load the queue before the aof // load the queue before the aof
qdb, err := buntdb.Open(core.QueueFileName) qdb, err := buntdb.Open(core.QueueFileName)
if err != nil { if err != nil {

View File

@ -689,7 +689,7 @@ func (c *Controller) parseSetArgs(vs []resp.Value) (
err = errInvalidNumberOfArguments err = errInvalidNumberOfArguments
return return
} }
d.obj, err = geojson.Parse(object, nil) d.obj, err = geojson.Parse(object, &c.geomParseOpts)
if err != nil { if err != nil {
return return
} }