Skip to content

Commit

Permalink
Memory optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMcCauley committed Mar 12, 2018
1 parent bcf5817 commit 88a4a4a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.git
osm/**/*
osm/**/*
osm_1/**/*
osm_2/**/*
35 changes: 27 additions & 8 deletions openpoiservice/server/db_import/parse_osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
from timeit import Timer
from bisect import bisect_left
from collections import deque

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -267,6 +268,7 @@ def parse_coords_for_ways(self, coords):

# two ways could have the same ref as current osmid
start_time = time.time()

while len(self.process_ways) != 0:

# if the first osm id matches
Expand Down Expand Up @@ -306,15 +308,32 @@ def parse_coords_for_ways(self, coords):

# start_time = time.time()
# reorder process_ways
# self.ways_temp.sort(key=lambda x: x.refs[0])
# elapsed_time = time.time() - start_time
# print('way temps sort...', elapsed_time*1000)

#start_time = time.time()
for t_way in self.ways_temp:
self.insert_temp_way(t_way)
# elapsed_time = time.time() - start_time
#print('finding index and inserting to process way...', elapsed_time * 1000)
if len(self.process_ways) == 0:

self.ways_temp.sort(key=lambda x: x.refs[0])
self.process_ways = deque(self.ways_temp)

else:

self.ways_temp.sort(key=lambda x: x.refs[0], reverse=True)
# elapsed_time = time.time() - start_time
# print('way temps sort...', elapsed_time*1000)

# start_time = time.time()

for t_way in self.ways_temp:

if t_way.refs[0] <= self.process_ways[0].refs[0]:

self.process_ways.insert(0, t_way)

else:

self.insert_temp_way(t_way)

# elapsed_time = time.time() - start_time
# print('finding index and inserting to process way...', elapsed_time * 1000)

self.ways_temp = []

Expand Down

0 comments on commit 88a4a4a

Please sign in to comment.