Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions node-ram-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB)
cacheSize((int64_t)cacheSizeMB * 1024 * 1024), storedNodes(0), totalNodes(0),
nodesCacheHits(0), nodesCacheLookups(0), warn_node_order(0)
{
if (cacheSize == 0)
return;

blockCache = 0;
blockCachePos = 0;
/* How much we can fit, and make sure it's odd */
Expand Down Expand Up @@ -388,6 +391,9 @@ node_ram_cache::node_ram_cache(int strategy, int cacheSizeMB)

node_ram_cache::~node_ram_cache()
{
if (cacheSize == 0)
return;

fprintf(stderr, "node cache: stored: %" PRIdOSMID
"(%.2f%%), storage efficiency: %.2f%% (dense blocks: %i, "
"sparse nodes: %" PRId64 "), hit rate: %.2f%%\n",
Expand Down Expand Up @@ -417,6 +423,9 @@ node_ram_cache::~node_ram_cache()

void node_ram_cache::set(osmid_t id, const osmium::Location &coord)
{
if (cacheSize == 0)
return;

if ((id > 0 && id >> BLOCK_SHIFT >> 32) ||
(id < 0 && ~id >> BLOCK_SHIFT >> 32)) {
fprintf(stderr, "\nAbsolute node IDs must not be larger than %" PRId64
Expand Down Expand Up @@ -448,6 +457,9 @@ osmium::Location node_ram_cache::get(osmid_t id)
{
osmium::Location coord;

if (cacheSize == 0)
return coord;

if (allocStrategy & ALLOC_DENSE) {
coord = get_dense(id);
}
Expand Down
9 changes: 8 additions & 1 deletion options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,14 @@ void options_t::check_options()
}

if (cache == 0) {
fprintf(stderr, "WARNING: ram cache is disabled. This will likely slow down processing a lot.\n\n");
if (!slim) {
throw std::runtime_error(
"Ram node cache can only be disable in slim mode.\n");
}
if (!flat_node_cache_enabled) {
fprintf(stderr, "WARNING: ram cache is disabled. This will likely "
"slow down processing a lot.\n\n");
}
}

if (num_procs < 1) {
Expand Down