 |
vrpRouting
0.3
|
Go to the source code of this file.
|
static void | db_get_breaks (char *breaks_sql, Vroom_break_t **breaks, size_t *total_breaks, Column_info_t *info, const int column_count, bool is_plain) |
|
static void | fetch_breaks (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vroom_break_t *vroom_break, bool is_plain) |
|
void | get_vroom_breaks (char *sql, Vroom_break_t **rows, size_t *total_rows, bool is_plain) |
| Reads the VROOM breaks. More...
|
|
◆ db_get_breaks()
static void db_get_breaks |
( |
char * |
breaks_sql, |
|
|
Vroom_break_t ** |
breaks, |
|
|
size_t * |
total_breaks, |
|
|
Column_info_t * |
info, |
|
|
const int |
column_count, |
|
|
bool |
is_plain |
|
) |
| |
|
static |
Definition at line 78 of file breaks_input.c.
87 clock_t start_t = clock();
91 const int tuple_limit = 1000000;
100 bool moredata =
true;
101 (*total_breaks) = total_tuples = 0;
105 while (moredata ==
true) {
106 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
107 if (total_tuples == 0) {
110 size_t ntuples = SPI_processed;
111 total_tuples += ntuples;
113 if ((*breaks) == NULL)
121 if ((*breaks) == NULL) {
122 elog(ERROR,
"Out of memory");
126 SPITupleTable *tuptable = SPI_tuptable;
127 TupleDesc tupdesc = SPI_tuptable->tupdesc;
128 for (t = 0; t < ntuples; t++) {
129 HeapTuple tuple = tuptable->vals[t];
131 &(*breaks)[total_tuples - ntuples + t], is_plain);
133 SPI_freetuptable(tuptable);
139 SPI_cursor_close(SPIportal);
141 if (total_tuples == 0) {
146 (*total_breaks) = total_tuples;
148 time_msg(
"reading breaks", start_t, clock());
References fetch_breaks(), PGR_DBG, pgr_fetch_column_info(), pgr_SPI_cursor_open(), pgr_SPI_prepare(), and time_msg().
Referenced by get_vroom_breaks().
◆ fetch_breaks()
static void fetch_breaks |
( |
HeapTuple * |
tuple, |
|
|
TupleDesc * |
tupdesc, |
|
|
Column_info_t * |
info, |
|
|
Vroom_break_t * |
vroom_break, |
|
|
bool |
is_plain |
|
) |
| |
|
static |
Definition at line 57 of file breaks_input.c.
63 vroom_break->
id =
get_Idx(tuple, tupdesc, info[0], 0);
References column_found(), Vroom_break_t::data, get_Duration(), get_Idx(), get_PositiveTInterval(), Vroom_break_t::id, Vroom_break_t::service, spi_getText(), and Vroom_break_t::vehicle_id.
Referenced by db_get_breaks().
◆ get_vroom_breaks()
void get_vroom_breaks |
( |
char * |
sql, |
|
|
Vroom_break_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
is_plain |
|
) |
| |
Reads the VROOM breaks.
- Parameters
-
[in] | sql | SQL query to execute |
[out] | rows | C Container that holds the data |
[out] | total_rows | Total rows recieved |
Definition at line 160 of file breaks_input.c.
165 int kColumnCount = 4;
168 for (
int i = 0; i < kColumnCount; ++i) {
176 info[1].
name =
"vehicle_id";
177 info[2].
name =
"service";
178 info[3].
name =
"data";
191 db_get_breaks(sql, rows, total_rows, info, kColumnCount, is_plain);
References ANY_INTEGER, Column_info_t::colNumber, db_get_breaks(), Column_info_t::eType, INTEGER, INTERVAL, JSONB, Column_info_t::name, Column_info_t::strict, and Column_info_t::type.
Referenced by process().
SPIPlanPtr pgr_SPI_prepare(char *sql)
char * spi_getText(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
under development
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.
Duration service
Identifier of vehicle.
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
struct Vroom_break_t Vroom_break_t
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] ...
char * data
Duration of break.
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] ...
Vehicle's break attributes.
void time_msg(char *msg, clock_t start_t, clock_t end_t)
Idx vehicle_id
Identifier of break.
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).