 |
vrpRouting
0.3
|
Go to the source code of this file.
|
static void | db_get_shipments (char *shipments_sql, Vroom_shipment_t **shipments, size_t *total_shipments, Column_info_t *info, const int column_count, bool is_plain) |
|
static void | fetch_shipments (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vroom_shipment_t *shipment, bool is_plain) |
|
void | get_vroom_shipments (char *sql, Vroom_shipment_t **rows, size_t *total_rows, bool is_plain) |
| Reads the VROOM shipments. More...
|
|
◆ db_get_shipments()
static void db_get_shipments |
( |
char * |
shipments_sql, |
|
|
Vroom_shipment_t ** |
shipments, |
|
|
size_t * |
total_shipments, |
|
|
Column_info_t * |
info, |
|
|
const int |
column_count, |
|
|
bool |
is_plain |
|
) |
| |
|
static |
Definition at line 135 of file shipments_input.c.
144 clock_t start_t = clock();
148 const int tuple_limit = 1000000;
157 bool moredata =
true;
158 (*total_shipments) = total_tuples = 0;
162 while (moredata ==
true) {
163 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
164 if (total_tuples == 0) {
167 size_t ntuples = SPI_processed;
168 total_tuples += ntuples;
170 if ((*shipments) == NULL)
178 if ((*shipments) == NULL) {
179 elog(ERROR,
"Out of memory");
183 SPITupleTable *tuptable = SPI_tuptable;
184 TupleDesc tupdesc = SPI_tuptable->tupdesc;
185 for (t = 0; t < ntuples; t++) {
186 HeapTuple tuple = tuptable->vals[t];
188 &(*shipments)[total_tuples - ntuples + t], is_plain);
190 SPI_freetuptable(tuptable);
196 SPI_cursor_close(SPIportal);
198 if (total_tuples == 0) {
199 (*total_shipments) = 0;
203 (*total_shipments) = total_tuples;
205 time_msg(
"reading shipments", start_t, clock());
References fetch_shipments(), PGR_DBG, pgr_fetch_column_info(), pgr_SPI_cursor_open(), pgr_SPI_prepare(), and time_msg().
Referenced by get_vroom_shipments().
◆ fetch_shipments()
Definition at line 86 of file shipments_input.c.
92 shipment->
id =
get_Idx(tuple, tupdesc, info[0], 0);
References Vroom_shipment_t::amount, Vroom_shipment_t::amount_size, column_found(), Vroom_shipment_t::d_data, Vroom_shipment_t::d_location_id, Vroom_shipment_t::d_service, Vroom_shipment_t::d_setup, get_Duration(), get_Idx(), get_MatrixIndex(), get_PositiveTInterval(), get_Priority(), Vroom_shipment_t::id, Vroom_shipment_t::p_data, Vroom_shipment_t::p_location_id, Vroom_shipment_t::p_service, Vroom_shipment_t::p_setup, Vroom_shipment_t::priority, Vroom_shipment_t::skills, Vroom_shipment_t::skills_size, spi_getPositiveBigIntArr_allowEmpty(), spi_getPositiveIntArr_allowEmpty(), and spi_getText().
Referenced by db_get_shipments().
◆ get_vroom_shipments()
void get_vroom_shipments |
( |
char * |
sql, |
|
|
Vroom_shipment_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
is_plain |
|
) |
| |
Reads the VROOM shipments.
- Parameters
-
[in] | sql | SQL query to execute |
[out] | rows | C Container that holds the data |
[out] | total_rows | Total rows recieved |
Definition at line 216 of file shipments_input.c.
221 int kColumnCount = 12;
224 for (
int i = 0; i < kColumnCount; ++i) {
234 info[1].
name =
"p_location_id";
235 info[2].
name =
"p_setup";
236 info[3].
name =
"p_service";
239 info[4].
name =
"d_location_id";
240 info[5].
name =
"d_setup";
241 info[6].
name =
"d_service";
243 info[7].
name =
"amount";
244 info[8].
name =
"skills";
245 info[9].
name =
"priority";
246 info[10].
name =
"p_data";
247 info[11].
name =
"d_data";
References ANY_INTEGER, ANY_INTEGER_ARRAY, Column_info_t::colNumber, db_get_shipments(), Column_info_t::eType, INTEGER, INTEGER_ARRAY, INTERVAL, JSONB, Column_info_t::name, Column_info_t::strict, and Column_info_t::type.
Referenced by process().
Priority priority
Number of skills.
Duration p_service
Pickup setup time.
Duration d_setup
Delivery location index in matrix.
size_t amount_size
Quantities for shipment.
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] ...
Priority get_Priority(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, Priority opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...
char * d_data
Metadata information of pickup shipment.
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.
MatrixIndex p_location_id
Shipment identifier.
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
Skill * skills
Number of quantities.
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] ...
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] ...
Duration d_service
Delivery setup time.
Duration p_setup
Pickup location index in matrix.
char * p_data
Priority level of shipment.
void time_msg(char *msg, clock_t start_t, clock_t end_t)
struct Vroom_shipment_t Vroom_shipment_t
Amount * amount
Delivery service time.
size_t skills_size
Mandatory skills.
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.
MatrixIndex d_location_id
Pickup service time.
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.
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).