enable deltacoordscache optimizations only for linear imports

master
Oliver Tonnhofer 2013-05-13 08:08:52 +02:00
parent 7a6bedb2e5
commit c3cb785484
2 changed files with 13 additions and 6 deletions

17
cache/delta.go vendored
View File

@ -77,11 +77,12 @@ type CoordsBunch struct {
type DeltaCoordsCache struct {
Cache
lruList *list.List
table map[int64]*CoordsBunch
freeNodes [][]element.Node
capacity int64
mu sync.Mutex
lruList *list.List
table map[int64]*CoordsBunch
freeNodes [][]element.Node
capacity int64
linearImport bool
mu sync.Mutex
}
// bunchSize defines how many coordinates should be stored in a
@ -105,6 +106,10 @@ func NewDeltaCoordsCache(path string) (*DeltaCoordsCache, error) {
return &coordsCache, nil
}
func (self *DeltaCoordsCache) SetLinearImport(v bool) {
self.linearImport = v
}
func (self *DeltaCoordsCache) Close() {
for bunchId, bunch := range self.table {
if bunch.needsWrite {
@ -152,7 +157,7 @@ func (self *DeltaCoordsCache) PutCoords(nodes []element.Node) {
for i, node := range nodes {
bunchId := getBunchId(node.Id)
if bunchId != currentBunchId {
if i > bunchSize && i < totalNodes-bunchSize {
if self.linearImport && i > bunchSize && i < totalNodes-bunchSize {
// no need to handle concurrent updates to the same
// bunch if we are not at the boundary of a bunchSize
self.putCoordsPacked(currentBunchId, nodes[start:i])

View File

@ -191,7 +191,9 @@ func main() {
progress := stats.StatsReporter()
if *read != "" {
osmCache.Coords.SetLinearImport(true)
parse(osmCache, progress, *read)
osmCache.Coords.SetLinearImport(false)
progress.Reset()
}