pgRouting / pgrouting

Repository contains pgRouting library. Development branch is "develop", stable branch is "master"
https://pgrouting.org
GNU General Public License v2.0
1.12k stars 364 forks source link

Read postgresql data on C++ #2607

Closed cvvergara closed 5 months ago

cvvergara commented 5 months ago

Moving the input queries from the C code into the C++ code.

Before this change

On the C file:

On the driver C++ file:

The ideal situation:

General steps to reach the ideal situation 1) Be able to read the PostgreSQL data on the C++ code 2) Create the templates 3) Build the boost graphs based on the templates needs

This PR is step 1

In rough terms, moving the reading of the data to C++.

The sketch of the C & C++ driver files for the first step:

On the C file:

On the driver C++ file:

tasks

cvvergara commented 5 months ago

Something happened on the cpplint that is not working anymore on the CI. But locally it is ok

cvvergara commented 5 months ago

Opened an issue here

sanak commented 5 months ago

@cvvergara I encountered the following build error on my M1 MacBook Pro environment.

``` : [ 60%] Built target bellman_ford [ 61%] Building CXX object src/cpp_common/CMakeFiles/cpp_common.dir/Dmatrix.cpp.o [ 61%] Building CXX object src/cpp_common/CMakeFiles/cpp_common.dir/compPaths.cpp.o [ 62%] Building CXX object src/cpp_common/CMakeFiles/cpp_common.dir/rule.cpp.o [ 62%] Building CXX object src/cpp_common/CMakeFiles/cpp_common.dir/bpoint.cpp.o [ 63%] Building CXX object src/cpp_common/CMakeFiles/cpp_common.dir/pgr_messages.cpp.o [ 63%] Building CXX object src/cpp_common/CMakeFiles/cpp_common.dir/combinations.cpp.o In file included from /Users/sanak/Projects/pgRouting/git/pgrouting/src/cpp_common/combinations.cpp:27: In file included from /Users/sanak/Projects/pgRouting/git/pgrouting/include/cpp_common/combinations.hpp:46: In file included from /Users/sanak/Projects/pgRouting/git/pgrouting/include/cpp_common/basePath_SSEC.hpp:44: In file included from /opt/homebrew/include/boost/graph/adjacency_list.hpp:20: In file included from /opt/homebrew/include/boost/unordered_set.hpp:17: In file included from /opt/homebrew/include/boost/unordered/unordered_set.hpp:17: In file included from /opt/homebrew/include/boost/unordered/detail/serialize_fca_container.hpp:12: In file included from /opt/homebrew/include/boost/unordered/detail/serialize_container.hpp:13: In file included from /opt/homebrew/include/boost/throw_exception.hpp:21: In file included from /opt/homebrew/include/boost/exception/exception.hpp:9: /opt/homebrew/include/boost/assert/source_location.hpp:95:9: error: no member named 'snprintf' in namespace 'std'; did you mean simply 'snprintf'? BOOST_ASSERT_SNPRINTF( buffer, ":%lu", ln ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/homebrew/include/boost/assert/source_location.hpp:79:53: note: expanded from macro 'BOOST_ASSERT_SNPRINTF' # define BOOST_ASSERT_SNPRINTF(buffer, format, arg) std::snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), format, arg) ^~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/stdio.h:337:6: note: 'snprintf' declared here int snprintf(char * __restrict __str, size_t __size, const char * __restrict __format, ...) __printflike(3, 4); ^ In file included from /Users/sanak/Projects/pgRouting/git/pgrouting/src/cpp_common/combinations.cpp:27: In file included from /Users/sanak/Projects/pgRouting/git/pgrouting/include/cpp_common/combinations.hpp:46: In file included from /Users/sanak/Projects/pgRouting/git/pgrouting/include/cpp_common/basePath_SSEC.hpp:44: In file included from /opt/homebrew/include/boost/graph/adjacency_list.hpp:20: In file included from /opt/homebrew/include/boost/unordered_set.hpp:17: In file included from /opt/homebrew/include/boost/unordered/unordered_set.hpp:17: In file included from /opt/homebrew/include/boost/unordered/detail/serialize_fca_container.hpp:12: In file included from /opt/homebrew/include/boost/unordered/detail/serialize_container.hpp:13: In file included from /opt/homebrew/include/boost/throw_exception.hpp:21: In file included from /opt/homebrew/include/boost/exception/exception.hpp:9: /opt/homebrew/include/boost/assert/source_location.hpp:102:13: error: no member named 'snprintf' in namespace 'std'; did you mean simply 'snprintf'? BOOST_ASSERT_SNPRINTF( buffer, ":%lu", co ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /opt/homebrew/include/boost/assert/source_location.hpp:79:53: note: expanded from macro 'BOOST_ASSERT_SNPRINTF' # define BOOST_ASSERT_SNPRINTF(buffer, format, arg) std::snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), format, arg) ^~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/stdio.h:337:6: note: 'snprintf' declared here int snprintf(char * __restrict __str, size_t __size, const char * __restrict __format, ...) __printflike(3, 4); ^ 2 errors generated. make[2]: *** [src/cpp_common/CMakeFiles/cpp_common.dir/combinations.cpp.o] Error 1 make[1]: *** [src/cpp_common/CMakeFiles/cpp_common.dir/all] Error 2 make: *** [all] Error 2 ```

And changing the following was necessary to pass the build.

--- a/src/cpp_common/combinations.cpp
+++ b/src/cpp_common/combinations.cpp
@@ -24,12 +24,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

  ********************************************************************PGR-GNU*/

-#include "cpp_common/combinations.hpp"
-
 #include <map>
 #include <set>
 #include <deque>
 #include <vector>
+#include "cpp_common/combinations.hpp"
 #include "cpp_common/pgdata_getters.hpp"
 #include "cpp_common/basePath_SSEC.hpp"

After the build, it seems to be fine, but I will check more at tomorrow.