 |
vrpRouting
0.3
|
Go to the source code of this file.
|
static void | check_pairs (Column_info_t lhs, Column_info_t rhs) |
|
static void | db_get_vehicles (char *vehicles_sql, Vehicle_t **vehicles, size_t *total_vehicles, Column_info_t *info, const int column_count, int kind, bool with_stops) |
|
static void | fetch_euclidean (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vehicle_t *vehicle, bool with_stops) |
|
static void | fetch_raw (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vehicle_t *vehicle, bool with_stops) |
|
static void | fetch_timestamps (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vehicle_t *vehicle, bool with_stops) |
|
void | get_vehicles (char *sql, Vehicle_t **rows, size_t *total_rows, bool with_stops) |
| Reads the vehicles information. More...
|
|
void | get_vehicles_euclidean (char *sql, Vehicle_t **rows, size_t *total_rows, bool with_stops) |
| Reads the vehicles information. More...
|
|
void | get_vehicles_raw (char *sql, Vehicle_t **rows, size_t *total_rows, bool with_stops) |
| Reads the vehicles information. More...
|
|
◆ check_pairs()
◆ db_get_vehicles()
static void db_get_vehicles |
( |
char * |
vehicles_sql, |
|
|
Vehicle_t ** |
vehicles, |
|
|
size_t * |
total_vehicles, |
|
|
Column_info_t * |
info, |
|
|
const int |
column_count, |
|
|
int |
kind, |
|
|
bool |
with_stops |
|
) |
| |
|
static |
Definition at line 377 of file vehicles_input.c.
388 clock_t start_t = clock();
392 const int tuple_limit = 1000000;
401 bool moredata =
true;
402 (*total_vehicles) = total_tuples = 0;
406 while (moredata ==
true) {
407 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
408 if (total_tuples == 0) {
411 size_t ntuples = SPI_processed;
412 total_tuples += ntuples;
414 if ((*vehicles) == NULL)
422 if ((*vehicles) == NULL) {
423 elog(ERROR,
"Out of memory");
427 SPITupleTable *tuptable = SPI_tuptable;
428 TupleDesc tupdesc = SPI_tuptable->tupdesc;
429 for (t = 0; t < ntuples; t++) {
430 HeapTuple tuple = tuptable->vals[t];
433 &(*vehicles)[total_tuples - ntuples + t], with_stops);
435 case 1 :
fetch_raw(&tuple, &tupdesc, info,
436 &(*vehicles)[total_tuples - ntuples + t], with_stops);
439 &(*vehicles)[total_tuples - ntuples + t], with_stops);
443 SPI_freetuptable(tuptable);
449 SPI_cursor_close(SPIportal);
451 if (total_tuples == 0) {
452 (*total_vehicles) = 0;
456 (*total_vehicles) = total_tuples;
458 time_msg(
"reading vehicles", start_t, clock());
References fetch_euclidean(), fetch_raw(), fetch_timestamps(), PGR_DBG, pgr_fetch_column_info(), pgr_SPI_cursor_open(), pgr_SPI_prepare(), and time_msg().
Referenced by get_vehicles(), get_vehicles_euclidean(), and get_vehicles_raw().
◆ fetch_euclidean()
static void fetch_euclidean |
( |
HeapTuple * |
tuple, |
|
|
TupleDesc * |
tupdesc, |
|
|
Column_info_t * |
info, |
|
|
Vehicle_t * |
vehicle, |
|
|
bool |
with_stops |
|
) |
| |
|
static |
Definition at line 204 of file vehicles_input.c.
210 bool with_id =
false;
228 vehicle->
id =
get_Id(tuple, tupdesc, info[0], -1);
254 vehicle->
stops = NULL;
References Vehicle_t::cant_v, Vehicle_t::capacity, check_pairs(), column_found(), Vehicle_t::end_close_t, Vehicle_t::end_open_t, Vehicle_t::end_service_t, Vehicle_t::end_x, Vehicle_t::end_y, get_Id(), get_PositiveAmount(), get_PositiveTInterval_plain(), get_TTimestamp_plain(), Vehicle_t::id, Vehicle_t::speed, spi_getBigIntArr_allowEmpty(), spi_getCoordinate(), spi_getFloat8(), Vehicle_t::start_close_t, Vehicle_t::start_open_t, Vehicle_t::start_service_t, Vehicle_t::start_x, Vehicle_t::start_y, Vehicle_t::stops, and Vehicle_t::stops_size.
Referenced by db_get_vehicles().
◆ fetch_raw()
static void fetch_raw |
( |
HeapTuple * |
tuple, |
|
|
TupleDesc * |
tupdesc, |
|
|
Column_info_t * |
info, |
|
|
Vehicle_t * |
vehicle, |
|
|
bool |
with_stops |
|
) |
| |
|
static |
Definition at line 270 of file vehicles_input.c.
287 vehicle->
id =
get_Id(tuple, tupdesc, info[0], -1);
291 vehicle->
stops = NULL;
References Vehicle_t::cant_v, Vehicle_t::capacity, check_pairs(), column_found(), Vehicle_t::end_close_t, Vehicle_t::end_node_id, Vehicle_t::end_open_t, Vehicle_t::end_service_t, Vehicle_t::end_x, Vehicle_t::end_y, get_Id(), get_PositiveAmount(), get_PositiveTInterval_plain(), get_TTimestamp_plain(), Vehicle_t::id, Vehicle_t::speed, spi_getBigIntArr_allowEmpty(), spi_getFloat8(), Vehicle_t::start_close_t, Vehicle_t::start_node_id, Vehicle_t::start_open_t, Vehicle_t::start_service_t, Vehicle_t::start_x, Vehicle_t::start_y, Vehicle_t::stops, and Vehicle_t::stops_size.
Referenced by db_get_vehicles().
◆ fetch_timestamps()
static void fetch_timestamps |
( |
HeapTuple * |
tuple, |
|
|
TupleDesc * |
tupdesc, |
|
|
Column_info_t * |
info, |
|
|
Vehicle_t * |
vehicle, |
|
|
bool |
with_stops |
|
) |
| |
|
static |
Definition at line 323 of file vehicles_input.c.
340 vehicle->
id =
get_Id(tuple, tupdesc, info[0], -1);
344 vehicle->
stops = NULL;
References Vehicle_t::cant_v, Vehicle_t::capacity, check_pairs(), column_found(), Vehicle_t::end_close_t, Vehicle_t::end_node_id, Vehicle_t::end_open_t, Vehicle_t::end_service_t, Vehicle_t::end_x, Vehicle_t::end_y, get_Id(), get_PositiveAmount(), get_PositiveTInterval(), get_TTimestamp(), Vehicle_t::id, Vehicle_t::speed, spi_getBigIntArr_allowEmpty(), spi_getFloat8(), Vehicle_t::start_close_t, Vehicle_t::start_node_id, Vehicle_t::start_open_t, Vehicle_t::start_service_t, Vehicle_t::start_x, Vehicle_t::start_y, Vehicle_t::stops, and Vehicle_t::stops_size.
Referenced by db_get_vehicles().
◆ get_vehicles()
void get_vehicles |
( |
char * |
sql, |
|
|
Vehicle_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
with_stops |
|
) |
| |
Reads the vehicles information.
- Parameters
-
[in] | sql | SQL query to execute |
[in] | with_stops | do not ignore stops column |
[out] | rows | C Container that holds the data |
[out] | total_rows | Total rows recieved |
Definition at line 469 of file vehicles_input.c.
474 const int column_count = 13;
477 for (
int i = 0; i < column_count; ++i) {
485 info[1].
name =
"capacity";
486 info[2].
name =
"number";
487 info[3].
name =
"speed";
488 info[4].
name =
"stops";
489 info[5].
name =
"s_id";
490 info[6].
name =
"s_tw_open";
491 info[7].
name =
"s_tw_close";
492 info[8].
name =
"s_t_service";
493 info[9].
name =
"e_id";
494 info[10].
name =
"e_tw_open";
495 info[11].
name =
"e_tw_close";
496 info[12].
name =
"e_t_service";
512 db_get_vehicles(sql, rows, total_rows, info, column_count, 0, with_stops);
References ANY_INTEGER, ANY_INTEGER_ARRAY, ANY_NUMERICAL, Column_info_t::colNumber, db_get_vehicles(), Column_info_t::eType, INTERVAL, Column_info_t::name, Column_info_t::strict, TIMESTAMP, and Column_info_t::type.
Referenced by process().
◆ get_vehicles_euclidean()
void get_vehicles_euclidean |
( |
char * |
sql, |
|
|
Vehicle_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
with_stops |
|
) |
| |
Reads the vehicles information.
- Parameters
-
[in] | sql | SQL query to execute |
[in] | with_stops | do not ignore stops column |
[out] | rows | C Container that holds the data |
[out] | total_rows | Total rows recieved |
Definition at line 569 of file vehicles_input.c.
574 const int column_count = 15;
577 for (
int i = 0; i < column_count; ++i) {
585 info[1].
name =
"capacity";
586 info[2].
name =
"number";
587 info[3].
name =
"speed";
588 info[4].
name =
"s_open";
589 info[5].
name =
"s_close";
590 info[6].
name =
"e_open";
591 info[7].
name =
"e_close";
592 info[8].
name =
"stops";
593 info[9].
name =
"s_service";
594 info[10].
name =
"e_service";
595 info[11].
name =
"s_x";
596 info[12].
name =
"s_y";
597 info[13].
name =
"e_x";
598 info[14].
name =
"e_y";
612 db_get_vehicles(sql, rows, total_rows, info, column_count, 2, with_stops);
References ANY_INTEGER, ANY_INTEGER_ARRAY, ANY_NUMERICAL, Column_info_t::colNumber, db_get_vehicles(), Column_info_t::eType, Column_info_t::name, Column_info_t::strict, and Column_info_t::type.
Referenced by process().
◆ get_vehicles_raw()
void get_vehicles_raw |
( |
char * |
sql, |
|
|
Vehicle_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
with_stops |
|
) |
| |
Reads the vehicles information.
- Parameters
-
[in] | sql | SQL query to execute |
[in] | with_stops | do not ignore stops column |
[out] | rows | C Container that holds the data |
[out] | total_rows | Total rows recieved |
Definition at line 522 of file vehicles_input.c.
527 const int column_count = 13;
530 for (
int i = 0; i < column_count; ++i) {
538 info[1].
name =
"capacity";
539 info[2].
name =
"number";
540 info[3].
name =
"speed";
541 info[4].
name =
"stops";
542 info[5].
name =
"s_id";
543 info[6].
name =
"s_open";
544 info[7].
name =
"s_close";
545 info[8].
name =
"s_service";
546 info[9].
name =
"e_id";
547 info[10].
name =
"e_open";
548 info[11].
name =
"e_close";
549 info[12].
name =
"e_service";
559 db_get_vehicles(sql, rows, total_rows, info, column_count, 1, with_stops);
References ANY_INTEGER, ANY_INTEGER_ARRAY, ANY_NUMERICAL, Column_info_t::colNumber, db_get_vehicles(), Column_info_t::eType, Column_info_t::name, Column_info_t::strict, and Column_info_t::type.
Referenced by process().
Id start_node_id
Stops size.
Id * stops
Number of vehicles with same description.
SPIPlanPtr pgr_SPI_prepare(char *sql)
TTimestamp get_TTimestamp(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
Id get_Id(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Id opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
int64_t * spi_getBigIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
TTimestamp start_open_t
Start node's identifier.
void pgr_fetch_column_info(Column_info_t info[], int info_size)
Function tells expected type of each column and then check the correspondence type of each column.
TTimestamp end_open_t
End node's identifier.
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
Coordinate start_x
Start service duration.
TInterval get_PositiveTInterval(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
TTimestamp start_close_t
Start open time.
Speed speed
Vehicle's capacity.
Coordinate spi_getCoordinate(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Coordinate opt_value)
get a coordinate value
void time_msg(char *msg, clock_t start_t, clock_t end_t)
TTimestamp end_close_t
End open time.
TInterval get_PositiveTInterval_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TInterval opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
PAmount capacity
Vehicle's identifier.
PAmount get_PositiveAmount(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, PAmount opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
bool column_found(int colNumber)
Check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUTE).
Coordinate end_x
End service time.
TInterval end_service_t
End close time.
TTimestamp get_TTimestamp_plain(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TTimestamp opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
TInterval start_service_t
Start close time.
double spi_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
gets value of specified column in double type.