[Tile-serving] [osm2pgsql] Reduce memory usage of node cache (#360)
Paul Norman
notifications at github.com
Sat Jun 27 21:43:22 UTC 2015
How does this look for coverage of possible cases?
```python
#!/usr/bin/env python
# This script generates an OSM XML file for testing node storage.
from lxml import etree
from sys import stdout
# Constants from node-ram-cache
BLOCK_SHIFT = 10
PER_BLOCK = 1 << BLOCK_SHIFT
def node(id, lat=None):
if lat is None:
lat=1+1e-6*id
return etree.Element("node", {'id':('%d' % id), 'visible':'true', 'version':'1',
'changeset':'1', 'timestamp':'2010-01-01T00:00:00Z',
'lon':'0.0', 'lat':('%f' % lat)})
root = etree.Element("osm", {'version':'0.6', 'generator':'generate_storage_xml.py'})
root.append(etree.Comment("This file contains nodes arranged to test both dense and sparse node storage in the optimized storage"))
root.append(etree.Comment("2 dense blocks, the second partially filled at the start"))
for id in xrange(1, PER_BLOCK+(PER_BLOCK >> 1) +1):
root.append(node(id))
# 1 dense block, 75% filled
root.append(etree.Comment("1 dense block, partially filled"))
for id in xrange(PER_BLOCK*2+1, PER_BLOCK*3, 4):
root.append(node(id))
root.append(node(id+1))
root.append(node(id+3))
root.append(etree.Comment("1 dense block worth of sparse nodes"))
for id in xrange(PER_BLOCK*3, PER_BLOCK*4, 4):
root.append(node(id))
#skip a bit, and a lone node
root.append(etree.Comment("A lone sparse node"))
root.append(node(PER_BLOCK*5))
# A dense block of alternating positions of zero/non-zero
root.append(etree.Comment("A dense block to check 0,0 is stored correctly"))
for id in xrange(PER_BLOCK*6, PER_BLOCK*7, 2):
root.append(node(id, 0))
root.append(node(id+1))
root.append(etree.Comment("Sparse nodes to check 0,0 is stored correctly"))
root.append(node(PER_BLOCK*7, 0))
root.append(node(PER_BLOCK*7+1))
stdout.write(etree.tostring(root, pretty_print=True))
stdout.write('\n')
```
---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/360#issuecomment-116149307
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20150627/ab62ca42/attachment.html>
More information about the Tile-serving
mailing list