forked from MTSR/mapserver
initial render pushdown stub
This commit is contained in:
parent
26c3663287
commit
58261615a7
@ -10,11 +10,16 @@ type Block struct {
|
|||||||
Mtime int64
|
Mtime int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InitialBlocksResult struct {
|
||||||
|
List []*Block
|
||||||
|
HasMore bool
|
||||||
|
}
|
||||||
|
|
||||||
type DBAccessor interface {
|
type DBAccessor interface {
|
||||||
Migrate() error
|
Migrate() error
|
||||||
|
|
||||||
FindBlocksByMtime(gtmtime int64, limit int) ([]*Block, error)
|
FindBlocksByMtime(gtmtime int64, limit int) ([]*Block, error)
|
||||||
FindLegacyBlocksByPos(lastpos *coords.MapBlockCoords, limit int) ([]*Block, error)
|
FindNextInitialBlocks(lastpos *coords.MapBlockCoords, limit int) (*InitialBlocksResult, error)
|
||||||
|
|
||||||
CountBlocks(frommtime, tomtime int64) (int, error)
|
CountBlocks(frommtime, tomtime int64) (int, error)
|
||||||
GetBlock(pos *coords.MapBlockCoords) (*Block, error)
|
GetBlock(pos *coords.MapBlockCoords) (*Block, error)
|
||||||
|
@ -68,31 +68,8 @@ func (this *PostgresAccessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db
|
|||||||
return blocks, nil
|
return blocks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PostgresAccessor) FindLegacyBlocksByPos(lastpos *coords.MapBlockCoords, limit int) ([]*db.Block, error) {
|
func (this *PostgresAccessor) FindNextInitialBlocks(lastpos *coords.MapBlockCoords, limit int) (*db.InitialBlocksResult, error) {
|
||||||
blocks := make([]*db.Block, 0)
|
return nil, nil
|
||||||
|
|
||||||
rows, err := this.db.Query(getLastBlockQuery, lastpos.X, lastpos.Y, lastpos.Z, limit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
var pos int64
|
|
||||||
var data []byte
|
|
||||||
var mtime int64
|
|
||||||
|
|
||||||
err = rows.Scan(&pos, &data, &mtime)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mb := convertRows(pos, data, mtime)
|
|
||||||
blocks = append(blocks, mb)
|
|
||||||
}
|
|
||||||
|
|
||||||
return blocks, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *PostgresAccessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
func (this *PostgresAccessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
||||||
|
40
server/db/sqlite/initialblocks.go
Normal file
40
server/db/sqlite/initialblocks.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package sqlite
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"mapserver/coords"
|
||||||
|
"mapserver/db"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (this *Sqlite3Accessor) FindNextInitialBlocks(lastpos *coords.MapBlockCoords, limit int) (*db.InitialBlocksResult, error) {
|
||||||
|
|
||||||
|
result := &db.InitialBlocksResult{}
|
||||||
|
|
||||||
|
blocks := make([]*db.Block, 0)
|
||||||
|
pc := coords.CoordToPlain(lastpos)
|
||||||
|
|
||||||
|
rows, err := this.db.Query(getLastBlockQuery, pc, limit)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
for rows.Next() {
|
||||||
|
var pos int64
|
||||||
|
var data []byte
|
||||||
|
var mtime int64
|
||||||
|
|
||||||
|
err = rows.Scan(&pos, &data, &mtime)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
mb := convertRows(pos, data, mtime)
|
||||||
|
blocks = append(blocks, mb)
|
||||||
|
}
|
||||||
|
|
||||||
|
result.List = blocks
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
@ -82,34 +82,6 @@ func (this *Sqlite3Accessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db.
|
|||||||
return blocks, nil
|
return blocks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Sqlite3Accessor) FindLegacyBlocksByPos(lastpos *coords.MapBlockCoords, limit int) ([]*db.Block, error) {
|
|
||||||
blocks := make([]*db.Block, 0)
|
|
||||||
pc := coords.CoordToPlain(lastpos)
|
|
||||||
|
|
||||||
rows, err := this.db.Query(getLastBlockQuery, pc, limit)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
var pos int64
|
|
||||||
var data []byte
|
|
||||||
var mtime int64
|
|
||||||
|
|
||||||
err = rows.Scan(&pos, &data, &mtime)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mb := convertRows(pos, data, mtime)
|
|
||||||
blocks = append(blocks, mb)
|
|
||||||
}
|
|
||||||
|
|
||||||
return blocks, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *Sqlite3Accessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
func (db *Sqlite3Accessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
||||||
rows, err := db.db.Query(countBlocksQuery, frommtime, tomtime)
|
rows, err := db.db.Query(countBlocksQuery, frommtime, tomtime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -28,7 +28,8 @@ func (a *MapBlockAccessor) FindNextLegacyBlocks(lastpos *coords.MapBlockCoords,
|
|||||||
}
|
}
|
||||||
logrus.WithFields(fields).Debug("FindMapBlocksByPos")
|
logrus.WithFields(fields).Debug("FindMapBlocksByPos")
|
||||||
|
|
||||||
blocks, err := a.accessor.FindLegacyBlocksByPos(lastpos, limit)
|
nextResult, err := a.accessor.FindNextInitialBlocks(lastpos, limit)
|
||||||
|
blocks := nextResult.List
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user