From 8813e73cfccc5f5339296a81512590aa828c7716 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 16 Oct 2015 13:34:53 -0700 Subject: [PATCH] rename SHAPE_MEMORY_MAPPED_FILE to MAPNIK_MEMORY_MAPPED_FILE --- CHANGELOG.md | 11 +++++++++++ SConstruct | 6 +++--- plugins/input/csv/csv_datasource.cpp | 4 ++-- plugins/input/csv/csv_featureset.cpp | 6 +++--- plugins/input/csv/csv_featureset.hpp | 4 ++-- plugins/input/csv/csv_index_featureset.cpp | 6 +++--- plugins/input/csv/csv_index_featureset.hpp | 4 ++-- plugins/input/csv/csv_utils.hpp | 4 ---- plugins/input/geojson/geojson_datasource.cpp | 4 ++-- plugins/input/geojson/geojson_index_featureset.cpp | 6 +++--- plugins/input/geojson/geojson_index_featureset.hpp | 6 ++---- plugins/input/ogr/ogr_index_featureset.cpp | 4 ++-- plugins/input/shape/dbfile.cpp | 8 ++++---- plugins/input/shape/dbfile.hpp | 4 ++-- plugins/input/shape/shape_index_featureset.cpp | 4 ++-- plugins/input/shape/shapefile.hpp | 12 ++++++------ src/mapped_memory_cache.cpp | 2 +- 17 files changed, 50 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbeea03f3..905c7cf8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ Developers: Please commit along with changes. For a complete change history, see the git log. +## 3.0.8 + +Released: ... + +(Packaged from ) + +#### Summary + + - Renamed `SHAPE_MEMORY_MAPPED_FILE` define to `MAPNIK_MEMORY_MAPPED_FILE`. Pass `./configure MEMORY_MAPPED_FILE=True|False` to request + support for memory mapped files across Mapnik plugins. + ## 3.0.7 Released: October 12, 2015 diff --git a/SConstruct b/SConstruct index 59faf048b..642ea1d96 100644 --- a/SConstruct +++ b/SConstruct @@ -389,7 +389,7 @@ opts.AddVariables( EnumVariable('PLUGIN_LINKING', "Set plugin linking with libmapnik", 'shared', ['shared','static']), # Other variables - BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'), + BoolVariable('MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'), ('SYSTEM_FONTS','Provide location for python bindings to register fonts (if provided then the bundled DejaVu fonts are not installed)',''), ('LIB_DIR_NAME','Name to use for the subfolder beside libmapnik where fonts and plugins are installed','mapnik'), PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable), @@ -1209,8 +1209,8 @@ if not preconfigured: thread_suffix = '' env.Append(LIBS = 'pthread') - if env['SHAPE_MEMORY_MAPPED_FILE']: - env.Append(CPPDEFINES = '-DSHAPE_MEMORY_MAPPED_FILE') + if env['MEMORY_MAPPED_FILE']: + env.Append(CPPDEFINES = '-DMAPNIK_MEMORY_MAPPED_FILE') # allow for mac osx /usr/lib/libicucore.dylib compatibility # requires custom supplied headers since Apple does not include them diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 8da469101..f690f67d5 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -41,7 +41,7 @@ #include #include #include -#ifdef CSV_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -125,7 +125,7 @@ csv_datasource::csv_datasource(parameters const& params) } else { -#if defined (CSV_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) using file_source_type = boost::interprocess::ibufferstream; file_source_type in; mapnik::mapped_region_ptr mapped_region; diff --git a/plugins/input/csv/csv_featureset.cpp b/plugins/input/csv/csv_featureset.cpp index 8a9487573..5017c825e 100644 --- a/plugins/input/csv/csv_featureset.cpp +++ b/plugins/input/csv/csv_featureset.cpp @@ -34,7 +34,7 @@ csv_featureset::csv_featureset(std::string const& filename, detail::geometry_column_locator const& locator, char separator, char quote, std::vector const& headers, mapnik::context_ptr const& ctx, array_type && index_array) : -#if defined(CSV_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) // #elif defined( _WINDOWS) file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), @@ -51,7 +51,7 @@ csv_featureset::csv_featureset(std::string const& filename, detail::geometry_col locator_(locator), tr_("utf8") { -#if defined (CSV_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); if (memory) @@ -90,7 +90,7 @@ mapnik::feature_ptr csv_featureset::next() csv_datasource::item_type const& item = *index_itr_++; std::size_t file_offset = item.second.first; std::size_t size = item.second.second; -#if defined(CSV_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) char const* start = (char const*)mapped_region_->get_address() + file_offset; char const* end = start + size; #else diff --git a/plugins/input/csv/csv_featureset.hpp b/plugins/input/csv/csv_featureset.hpp index 3f05c08b0..e09bd4c60 100644 --- a/plugins/input/csv/csv_featureset.hpp +++ b/plugins/input/csv/csv_featureset.hpp @@ -30,7 +30,7 @@ #include #include -#ifdef CSV_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -56,7 +56,7 @@ public: mapnik::feature_ptr next(); private: mapnik::feature_ptr parse_feature(char const* beg, char const* end); -#if defined (CSV_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) using file_source_type = boost::interprocess::ibufferstream; mapnik::mapped_region_ptr mapped_region_; #else diff --git a/plugins/input/csv/csv_index_featureset.cpp b/plugins/input/csv/csv_index_featureset.cpp index 4a135515f..c064579fc 100644 --- a/plugins/input/csv/csv_index_featureset.cpp +++ b/plugins/input/csv/csv_index_featureset.cpp @@ -48,7 +48,7 @@ csv_index_featureset::csv_index_featureset(std::string const& filename, ctx_(ctx), locator_(locator), tr_("utf8") -#if defined(CSV_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) // #elif defined( _WINDOWS) ,file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose) @@ -57,7 +57,7 @@ csv_index_featureset::csv_index_featureset(std::string const& filename, #endif { -#if defined (CSV_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); if (memory) @@ -112,7 +112,7 @@ mapnik::feature_ptr csv_index_featureset::next() while( itr_ != positions_.end()) { auto pos = *itr_++; -#if defined(CSV_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) char const* start = (char const*)mapped_region_->get_address() + pos.first; char const* end = start + pos.second; #else diff --git a/plugins/input/csv/csv_index_featureset.hpp b/plugins/input/csv/csv_index_featureset.hpp index 5980afb9c..a17da5997 100644 --- a/plugins/input/csv/csv_index_featureset.hpp +++ b/plugins/input/csv/csv_index_featureset.hpp @@ -29,7 +29,7 @@ #include "csv_utils.hpp" #include "csv_datasource.hpp" -#ifdef CSV_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -63,7 +63,7 @@ private: mapnik::value_integer feature_id_ = 0; detail::geometry_column_locator const& locator_; mapnik::transcoder tr_; -#if defined (CSV_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) using file_source_type = boost::interprocess::ibufferstream; mapnik::mapped_region_ptr mapped_region_; #else diff --git a/plugins/input/csv/csv_utils.hpp b/plugins/input/csv/csv_utils.hpp index 2d3cb46f5..daf361eb2 100644 --- a/plugins/input/csv/csv_utils.hpp +++ b/plugins/input/csv/csv_utils.hpp @@ -44,10 +44,6 @@ #include #include -#ifndef _WINDOWS -#define CSV_MEMORY_MAPPED_FILE -#endif - namespace csv_utils { diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index b9e6dfe65..aebf44903 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -62,7 +62,7 @@ #include #include -#if defined(SHAPE_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -156,7 +156,7 @@ geojson_datasource::geojson_datasource(parameters const& params) else { cache_features_ = *params.get("cache_features", true); -#if !defined(SHAPE_MEMORY_MAPPED_FILE) +#if !defined(MAPNIK_MEMORY_MAPPED_FILE) mapnik::util::file file(filename_); if (!file.open()) { diff --git a/plugins/input/geojson/geojson_index_featureset.cpp b/plugins/input/geojson/geojson_index_featureset.cpp index 733da76bf..f5d4249fb 100644 --- a/plugins/input/geojson/geojson_index_featureset.cpp +++ b/plugins/input/geojson/geojson_index_featureset.cpp @@ -35,7 +35,7 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename, mapnik::filter_in_box const& filter) : -#if defined(GEOJSON_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) // #elif defined _WINDOWS file_(_wfopen(mapnik::utf8_to_utf16(filename).c_str(), L"rb"), std::fclose), @@ -45,7 +45,7 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename, ctx_(std::make_shared()) { -#if defined (GEOJSON_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) boost::optional memory = mapnik::mapped_memory_cache::instance().find(filename, true); if (memory) @@ -78,7 +78,7 @@ mapnik::feature_ptr geojson_index_featureset::next() while( itr_ != positions_.end()) { auto pos = *itr_++; -#if defined(GEOJSON_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) char const* start = (char const*)mapped_region_->get_address() + pos.first; char const* end = start + pos.second; #else diff --git a/plugins/input/geojson/geojson_index_featureset.hpp b/plugins/input/geojson/geojson_index_featureset.hpp index 87b3f38a0..e683df28d 100644 --- a/plugins/input/geojson/geojson_index_featureset.hpp +++ b/plugins/input/geojson/geojson_index_featureset.hpp @@ -23,13 +23,11 @@ #ifndef GEOJSON_INDEX_FEATURESET_HPP #define GEOJSON_INDEX_FEATURESET_HPP -#define GEOJSON_MEMORY_MAPPED_FILE - #include "geojson_datasource.hpp" #include #include -#ifdef GEOJSON_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -51,7 +49,7 @@ public: mapnik::feature_ptr next(); private: -#if defined (GEOJSON_MEMORY_MAPPED_FILE) +#if defined (MAPNIK_MEMORY_MAPPED_FILE) using file_source_type = boost::interprocess::ibufferstream; mapnik::mapped_region_ptr mapped_region_; #else diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index 9338f954d..348c618f8 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -33,7 +33,7 @@ #include // boost -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" @@ -72,7 +72,7 @@ ogr_index_featureset::ogr_index_featureset(mapnik::context_ptr const & feature_envelope_() { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) boost::optional memory = mapnik::mapped_memory_cache::instance().find(index_file, true); if (memory) { diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index 921165757..c26a11730 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -36,7 +36,7 @@ #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wsign-conversion" #include -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #include #include #endif @@ -58,7 +58,7 @@ dbf_file::dbf_file(std::string const& file_name) :num_records_(0), num_fields_(0), record_length_(0), -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) file_(), #elif defined(_WINDOWS) file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary), @@ -68,7 +68,7 @@ dbf_file::dbf_file(std::string const& file_name) record_(0) { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) boost::optional memory = mapnik::mapped_memory_cache::instance().find(file_name,true); if (memory) { @@ -95,7 +95,7 @@ dbf_file::~dbf_file() bool dbf_file::is_open() { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) return (file_.buffer().second > 0); #else return file_.is_open(); diff --git a/plugins/input/shape/dbfile.hpp b/plugins/input/shape/dbfile.hpp index 358d737f7..6812e5460 100644 --- a/plugins/input/shape/dbfile.hpp +++ b/plugins/input/shape/dbfile.hpp @@ -27,7 +27,7 @@ #include #include #include -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" @@ -59,7 +59,7 @@ private: int num_fields_; std::size_t record_length_; std::vector fields_; -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) boost::interprocess::ibufferstream file_; mapnik::mapped_region_ptr mapped_region_; #else diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 1fa6f0bbf..32f261979 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -32,7 +32,7 @@ #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-local-typedef" #include -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #include #endif #pragma GCC diagnostic pop @@ -63,7 +63,7 @@ shape_index_featureset::shape_index_featureset(filterT const& filter, auto index = shape_ptr_->index(); if (index) { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) mapnik::util::spatial_index::query(filter, index->file(), offsets_); #else mapnik::util::spatial_index::query(filter, index->file(), offsets_); diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 3f70e3a7f..270ef939f 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -33,7 +33,7 @@ #include #include #include -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -141,7 +141,7 @@ class shape_file : mapnik::util::noncopyable { public: -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) using file_source_type = boost::interprocess::ibufferstream; using record_type = shape_record; mapnik::mapped_region_ptr mapped_region_; @@ -155,7 +155,7 @@ public: shape_file() {} shape_file(std::string const& file_name) : -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) file_() #elif defined (_WINDOWS) file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary) @@ -163,7 +163,7 @@ public: file_(file_name.c_str(), std::ios::in | std::ios::binary) #endif { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) boost::optional memory = mapnik::mapped_memory_cache::instance().find(file_name,true); @@ -188,7 +188,7 @@ public: inline bool is_open() const { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) return (file_.buffer().second > 0); #else return file_.is_open(); @@ -197,7 +197,7 @@ public: inline void read_record(record_type& rec) { -#ifdef SHAPE_MEMORY_MAPPED_FILE +#if defined(MAPNIK_MEMORY_MAPPED_FILE) rec.set_data(file_.buffer().first + file_.tellg()); file_.seekg(rec.size, std::ios::cur); #else diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp index abe08d1b9..00ad96333 100644 --- a/src/mapped_memory_cache.cpp +++ b/src/mapped_memory_cache.cpp @@ -20,7 +20,7 @@ * *****************************************************************************/ -#if defined(SHAPE_MEMORY_MAPPED_FILE) +#if defined(MAPNIK_MEMORY_MAPPED_FILE) // mapnik #include