]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/index.c
adapt CONTRIBUTING.md to new test locations and tools
[nominatim.git] / nominatim / index.c
index ca301f45b305ea5826f214fb90f5504b7ae00ed1..9aa3fb86c31ce0999d5aa22e6f0f83afa83dda53 100644 (file)
@@ -140,13 +140,7 @@ struct index_thread_data * thread_data, const char *structuredoutputfile)
 
             // Get all the place_id's for this sector
             paramRank = PGint32(rank);
-            paramValues[0] = (char *)&paramRank;
-            paramLengths[0] = sizeof(paramRank);
-            paramFormats[0] = 1;
             paramSector = PGint32(sector);
-            paramValues[1] = (char *)&paramSector;
-            paramLengths[1] = sizeof(paramSector);
-            paramFormats[1] = 1;
             if (rankTotalTuples-rankCountTuples < num_threads*1000)
             {
                 // no sectors
@@ -156,6 +150,9 @@ struct index_thread_data * thread_data, const char *structuredoutputfile)
                 }
                 else
                 {
+                    paramValues[0] = (char *)&paramRank;
+                    paramLengths[0] = sizeof(paramRank);
+                    paramFormats[0] = 1;
                     iResult = PQsendQueryPrepared(conn, "index_nosector_places", 1, paramValues, paramLengths, paramFormats, 1);
                 }
             }
@@ -163,11 +160,19 @@ struct index_thread_data * thread_data, const char *structuredoutputfile)
             {
                 if (interpolation)
                 {
-                                       iResult = PQsendQueryPrepared(conn, "index_sector_places_osmline", 1, paramValues, paramLengths, paramFormats, 1);
-
+                    iResult = PQsendQueryPrepared(conn, "index_sector_places_osmline", 1, paramValues, paramLengths, paramFormats, 1);
+                    paramValues[0] = (char *)&paramSector;
+                    paramLengths[0] = sizeof(paramSector);
+                    paramFormats[0] = 1;
                 }
                 else
                 {
+                    paramValues[0] = (char *)&paramRank;
+                    paramLengths[0] = sizeof(paramRank);
+                    paramFormats[0] = 1;
+                    paramValues[1] = (char *)&paramSector;
+                    paramLengths[1] = sizeof(paramSector);
+                    paramFormats[1] = 1;
                     iResult = PQsendQueryPrepared(conn, "index_sector_places", 2, paramValues, paramLengths, paramFormats, 1);
                 }
             }
@@ -216,7 +221,15 @@ struct index_thread_data * thread_data, const char *structuredoutputfile)
                     if (sleepcount++ > 500)
                     {
                         rankPerSecond = ((float)rankCountTuples + (float)count) / MAX(difftime(time(0), rankStartTime),1);
-                        fprintf(stderr, "  Done %i in %i @ %f per second - Rank %i ETA (seconds): %f\n", (rankCountTuples + count), (int)(difftime(time(0), rankStartTime)), rankPerSecond, rank, ((float)(rankTotalTuples - (rankCountTuples + count)))/rankPerSecond);
+                        if(interpolation)
+                        {
+                            fprintf(stderr, "  Done %i in %i @ %f per second - Interpolation lines ETA (seconds): %f\n", (rankCountTuples + count), (int)(difftime(time(0), rankStartTime)), rankPerSecond, ((float)(rankTotalTuples - (rankCountTuples + count)))/rankPerSecond);
+                        }
+                        else
+                        {
+                            fprintf(stderr, "  Done %i in %i @ %f per second - Rank %i ETA (seconds): %f\n", (rankCountTuples + count), (int)(difftime(time(0), rankStartTime)), rankPerSecond, rank, ((float)(rankTotalTuples - (rankCountTuples + count)))/rankPerSecond);
+                        }
+                        
                         sleepcount = 0;
                     }
                 }
@@ -363,7 +376,7 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
                         1, pg_prepare_params);
         if (PQresultStatus(res) != PGRES_COMMAND_OK)
         {
-            fprintf(stderr, "Failed preparing index_placex: %s\n", PQerrorMessage(conn));
+            fprintf(stderr, "Failed preparing index_placex: %s\n", PQerrorMessage(thread_data[i].conn));
             exit(EXIT_FAILURE);
         }
         PQclear(res);
@@ -374,18 +387,19 @@ void nominatim_index(int rank_min, int rank_max, int num_threads, const char *co
                         1, pg_prepare_params);
         if (PQresultStatus(res) != PGRES_COMMAND_OK)
         {
-            fprintf(stderr, "Failed preparing index_osmline: %s\n", PQerrorMessage(conn));
+            fprintf(stderr, "Failed preparing index_osmline: %s\n", PQerrorMessage(thread_data[i].conn));
             exit(EXIT_FAILURE);
         }
         PQclear(res);
 
-        /*res = PQexec(thread_data[i].conn, "set enable_seqscan = false");
+        // Make sure the error message is not localized as we parse it later.
+        res = PQexec(thread_data[i].conn, "SET lc_messages TO 'C'");
         if (PQresultStatus(res) != PGRES_COMMAND_OK)
         {
-            fprintf(stderr, "Failed disabling sequential scan: %s\n", PQerrorMessage(conn));
+            fprintf(stderr, "Failed to set langauge: %s\n", PQerrorMessage(thread_data[i].conn));
             exit(EXIT_FAILURE);
         }
-        PQclear(res);*/
+        PQclear(res);
 
         nominatim_exportCreatePreparedQueries(thread_data[i].conn);
     }