Skip to content

Commit

Permalink
Merge pull request #53 from hendrik-cliqz/mac-fixes
Browse files Browse the repository at this point in the history
some mmap options are not available on mac
  • Loading branch information
Hendrik Muhs committed Nov 10, 2015
2 parents 0717c92 + 97315e8 commit cec5750
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 7 additions & 1 deletion keyvi/src/cpp/dictionary/fsa/automata.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@ final {
throw std::invalid_argument("file is corrupt(truncated)");
}

boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options | MAP_HUGETLB;
boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options;

#ifdef MAP_HUGETLB
map_options |= MAP_HUGETLB;
#endif

if (!load_lazy) {
#ifdef MAP_POPULATE
map_options |= MAP_POPULATE;
#endif
}

TRACE("labels start offset: %d", offset);
Expand Down
9 changes: 7 additions & 2 deletions keyvi/src/cpp/dictionary/fsa/internal/json_value_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,16 @@ class JsonValueStoreReader final: public IValueStoreReader {
}
}

boost::interprocess::map_options_t map_options =
boost::interprocess::default_map_options | MAP_HUGETLB;
boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options;

#ifdef MAP_HUGETLB
map_options |= MAP_HUGETLB;
#endif

if (!load_lazy) {
#ifdef MAP_POPULATE
map_options |= MAP_POPULATE;
#endif
}

strings_region_ = new boost::interprocess::mapped_region(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,16 @@ class JsonValueStoreDeprecated final : public IValueStoreWriter {
}
}

boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options | MAP_HUGETLB;
boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options;

#ifdef MAP_HUGETLB
map_options |= MAP_HUGETLB;
#endif

if (!load_lazy) {
#ifdef MAP_POPULATE
map_options |= MAP_POPULATE;
#endif
}

strings_region_ = new boost::interprocess::mapped_region(
Expand Down
8 changes: 7 additions & 1 deletion keyvi/src/cpp/dictionary/fsa/internal/string_value_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,16 @@ class StringValueStore final : public IValueStoreWriter {
}
}

boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options | MAP_HUGETLB;
boost::interprocess::map_options_t map_options = boost::interprocess::default_map_options;

#ifdef MAP_HUGETLB
map_options |= MAP_HUGETLB;
#endif

if (!load_lazy) {
#ifdef MAP_POPULATE
map_options |= MAP_POPULATE;
#endif
}

strings_region_ = new boost::interprocess::mapped_region(
Expand Down

0 comments on commit cec5750

Please sign in to comment.