80 size_t *total_matrix_rows,
83 const int column_count,
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());
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);