 |
vrpRouting
0.3
|
Go to the source code of this file.
|
static void | db_get_vehicles (char *vehicles_sql, Vroom_vehicle_t **vehicles, size_t *total_vehicles, Column_info_t *info, const int column_count, bool is_plain) |
|
static void | fetch_vehicles (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vroom_vehicle_t *vehicle, bool is_plain) |
|
void | get_vroom_vehicles (char *sql, Vroom_vehicle_t **rows, size_t *total_rows, bool is_plain) |
| Reads the VROOM vehicles. More...
|
|
◆ db_get_vehicles()
static void db_get_vehicles |
( |
char * |
vehicles_sql, |
|
|
Vroom_vehicle_t ** |
vehicles, |
|
|
size_t * |
total_vehicles, |
|
|
Column_info_t * |
info, |
|
|
const int |
column_count, |
|
|
bool |
is_plain |
|
) |
| |
|
static |
Definition at line 150 of file vroom/vehicles_input.c.
159 clock_t start_t = clock();
163 const int tuple_limit = 1000000;
172 bool moredata =
true;
173 (*total_vehicles) = total_tuples = 0;
177 while (moredata ==
true) {
178 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
179 if (total_tuples == 0) {
181 info[1].
colNumber = SPI_fnumber(SPI_tuptable->tupdesc,
"start_id");
182 info[2].
colNumber = SPI_fnumber(SPI_tuptable->tupdesc,
"end_id");
184 elog(ERROR,
"At least one out of start_id or end_id must be present");
188 size_t ntuples = SPI_processed;
189 total_tuples += ntuples;
191 if ((*vehicles) == NULL)
199 if ((*vehicles) == NULL) {
200 elog(ERROR,
"Out of memory");
204 SPITupleTable *tuptable = SPI_tuptable;
205 TupleDesc tupdesc = SPI_tuptable->tupdesc;
206 for (t = 0; t < ntuples; t++) {
207 HeapTuple tuple = tuptable->vals[t];
209 &(*vehicles)[total_tuples - ntuples + t], is_plain);
211 SPI_freetuptable(tuptable);
217 SPI_cursor_close(SPIportal);
219 if (total_tuples == 0) {
220 (*total_vehicles) = 0;
224 (*total_vehicles) = total_tuples;
226 time_msg(
"reading vehicles", start_t, clock());
References Column_info_t::colNumber, column_found(), fetch_vehicles(), PGR_DBG, pgr_fetch_column_info(), pgr_SPI_cursor_open(), pgr_SPI_prepare(), and time_msg().
Referenced by get_vroom_vehicles().
◆ fetch_vehicles()
Definition at line 91 of file vroom/vehicles_input.c.
97 vehicle->
id =
get_Idx(tuple, tupdesc, info[0], 0);
123 (errmsg(
"Invalid time window (%d, %d)",
125 errhint(
"Time window start time %d must be "
126 "less than or equal to time window end time %d",
135 ereport(ERROR, (errmsg(
"Invalid speed_factor %lf", vehicle->
speed_factor),
136 errhint(
"Speed factor must be greater than 0")));
References Vroom_vehicle_t::capacity, Vroom_vehicle_t::capacity_size, column_found(), Vroom_vehicle_t::data, Vroom_vehicle_t::end_id, get_Duration(), get_Idx(), get_MatrixIndex(), get_PositiveTTimestamp(), Vroom_vehicle_t::id, Vroom_vehicle_t::max_tasks, Vroom_vehicle_t::skills, Vroom_vehicle_t::skills_size, Vroom_vehicle_t::speed_factor, spi_getFloat8(), spi_getMaxTasks(), spi_getPositiveBigIntArr_allowEmpty(), spi_getPositiveIntArr_allowEmpty(), spi_getText(), Vroom_vehicle_t::start_id, Vroom_vehicle_t::tw_close, and Vroom_vehicle_t::tw_open.
Referenced by db_get_vehicles().
◆ get_vroom_vehicles()
void get_vroom_vehicles |
( |
char * |
sql, |
|
|
Vroom_vehicle_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
is_plain |
|
) |
| |
Reads the VROOM vehicles.
- Parameters
-
[in] | sql | SQL query to execute |
[out] | rows | C Container that holds the data |
[out] | total_rows | Total rows recieved |
id is mandatory. At least one out of start_id or end_id must be present, but that is checked later.
Definition at line 237 of file vroom/vehicles_input.c.
242 int kColumnCount = 10;
245 for (
int i = 0; i < kColumnCount; ++i) {
253 info[1].
name =
"start_id";
254 info[2].
name =
"end_id";
255 info[3].
name =
"capacity";
256 info[4].
name =
"skills";
257 info[5].
name =
"tw_open";
258 info[6].
name =
"tw_close";
259 info[7].
name =
"speed_factor";
260 info[8].
name =
"max_tasks";
261 info[9].
name =
"data";
References ANY_INTEGER, ANY_INTEGER_ARRAY, ANY_NUMERICAL, Column_info_t::colNumber, db_get_vehicles(), Column_info_t::eType, INTEGER, INTEGER_ARRAY, JSONB, Column_info_t::name, Column_info_t::strict, TIMESTAMP, and Column_info_t::type.
Referenced by process().
MatrixIndex end_id
Start location index in matrix.
Duration tw_open
Number of vehicle's skills.
SPIPlanPtr pgr_SPI_prepare(char *sql)
char * spi_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
under development
MatrixIndex get_MatrixIndex(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, MatrixIndex opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
size_t capacity_size
Vehicle's capacity array.
double speed_factor
Time window end time.
Skill * skills
Vehicle's capacity array size.
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.
struct Vroom_vehicle_t Vroom_vehicle_t
TTimestamp get_PositiveTTimestamp(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] ...
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
int32_t max_tasks
Vehicle travel time multiplier.
Duration get_Duration(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Duration opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
void time_msg(char *msg, clock_t start_t, clock_t end_t)
int32_t spi_getMaxTasks(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
gets the vehicle max tasks value
char * data
Max number of tasks in a route for the vehicle.
int64_t * spi_getPositiveBigIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
uint32_t * spi_getPositiveIntArr_allowEmpty(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, size_t *the_size)
Function returns the values of specified columns in array.
Duration tw_close
Time window start time.
size_t skills_size
Vehicle's skills.
Idx get_Idx(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Idx 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).
MatrixIndex start_id
The vehicle's identifier.
Amount * capacity
End location index in matrix.
double spi_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
gets value of specified column in double type.