 |
vrpRouting
0.3
|
Go to the source code of this file.
|
static void | db_get_matrix (char *matrix_sql, Vroom_matrix_t **matrix, size_t *total_matrix_rows, Column_info_t *info, const int column_count, bool is_plain) |
|
static void | fetch_matrix (HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t *info, Vroom_matrix_t *matrix, bool is_plain) |
|
void | get_vroom_matrix (char *sql, Vroom_matrix_t **rows, size_t *total_rows, bool is_plain) |
| Reads the VROOM matrix. More...
|
|
◆ db_get_matrix()
static void db_get_matrix |
( |
char * |
matrix_sql, |
|
|
Vroom_matrix_t ** |
matrix, |
|
|
size_t * |
total_matrix_rows, |
|
|
Column_info_t * |
info, |
|
|
const int |
column_count, |
|
|
bool |
is_plain |
|
) |
| |
|
static |
Definition at line 77 of file matrix_input.c.
86 clock_t start_t = clock();
90 const int tuple_limit = 1000000;
100 (*total_matrix_rows) = total_tuples = 0;
104 while (moredata ==
true) {
105 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
106 if (total_tuples == 0) {
109 size_t ntuples = SPI_processed;
110 total_tuples += ntuples;
112 if ((*matrix) == NULL)
120 if ((*matrix) == NULL) {
121 elog(ERROR,
"Out of memory");
125 SPITupleTable *tuptable = SPI_tuptable;
126 TupleDesc tupdesc = SPI_tuptable->tupdesc;
127 for (t = 0; t < ntuples; t++) {
128 HeapTuple tuple = tuptable->vals[t];
130 &(*matrix)[total_tuples - ntuples + t], is_plain);
132 SPI_freetuptable(tuptable);
138 SPI_cursor_close(SPIportal);
140 if (total_tuples == 0) {
141 (*total_matrix_rows) = 0;
145 (*total_matrix_rows) = total_tuples;
147 time_msg(
"reading matrix", start_t, clock());
References fetch_matrix(), PGR_DBG, pgr_fetch_column_info(), pgr_SPI_cursor_open(), pgr_SPI_prepare(), and time_msg().
Referenced by get_vroom_matrix().
◆ fetch_matrix()
◆ get_vroom_matrix()
void get_vroom_matrix |
( |
char * |
sql, |
|
|
Vroom_matrix_t ** |
rows, |
|
|
size_t * |
total_rows, |
|
|
bool |
is_plain |
|
) |
| |
Reads the VROOM matrix.
- Parameters
-
[in] | sql | SQL query that has the following columns: start_id, end_id, duration, cost |
[in] | is_plain | Whether the plain or timestamp function is used |
[out] | rows | C Container that holds all the matrix rows |
[out] | total_rows | Total rows recieved |
cost is not mandatory
Definition at line 159 of file matrix_input.c.
164 int kColumnCount = 4;
167 for (
int i = 0; i < kColumnCount; ++i) {
173 info[0].
name =
"start_id";
174 info[1].
name =
"end_id";
175 info[2].
name =
"duration";
176 info[3].
name =
"cost";
190 db_get_matrix(sql, rows, total_rows, info, kColumnCount, is_plain);
References ANY_INTEGER, Column_info_t::colNumber, db_get_matrix(), Column_info_t::eType, INTEGER, INTERVAL, Column_info_t::name, Column_info_t::strict, and Column_info_t::type.
Referenced by process().
SPIPlanPtr pgr_SPI_prepare(char *sql)
struct Vroom_matrix_t Vroom_matrix_t
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] ...
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 end_id
Start node identifier.
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
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] ...
TravelCost cost
Duration to travel from start to end.
void time_msg(char *msg, clock_t start_t, clock_t end_t)
Duration duration
End node identifier.
TravelCost get_Cost(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info, TravelCost opt_value)
@params [in] tuple @params [in] tupdesc @params [in] info about the column been fetched @params [in] ...