50 size_t *valid_edges) {
108 *valid_edges =
edge->
cost < 0? *valid_edges: *valid_edges + 1;
118 int64_t default_rcapacity,
119 float8 default_rcost,
126 edge->edge_id = *default_id;
142 edge->reverse_capacity = default_rcapacity;
152 *valid_edges =
edge->capacity < 0? *valid_edges: *valid_edges + 1;
153 *valid_edges =
edge->reverse_capacity < 0? *valid_edges: *valid_edges + 1;
162 float8 default_rcost,
199 *valid_edges =
edge->
cost < 0? *valid_edges: *valid_edges + 1;
210 clock_t start_t = clock();
212 const int tuple_limit = 1000000;
220 info[1].
name =
"source";
221 info[2].
name =
"target";
222 info[3].
name =
"cost";
223 info[4].
name =
"reverse_cost";
230 for (i = 0; i < 3; ++i) {
236 for (i = 3; i < 9; ++i) {
255 bool moredata =
true;
256 (*total_edges) = total_tuples = valid_edges = 0;
259 int64_t default_id = 0;
260 while (moredata ==
true) {
261 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
262 if (total_tuples == 0)
265 size_t ntuples = SPI_processed;
266 total_tuples += ntuples;
269 if ((*edges) == NULL)
276 if ((*edges) == NULL) {
277 elog(ERROR,
"Out of memory");
281 SPITupleTable *tuptable = SPI_tuptable;
282 TupleDesc tupdesc = SPI_tuptable->tupdesc;
283 for (t = 0; t < ntuples; t++) {
284 HeapTuple tuple = tuptable->vals[t];
287 &(*edges)[total_tuples - ntuples + t],
288 &valid_edges, normal);
290 SPI_freetuptable(tuptable);
296 SPI_cursor_close(SPIportal);
298 if (total_tuples == 0 || valid_edges == 0) {
302 (*total_edges) = total_tuples;
303 time_msg(
"reading edges", start_t, clock());
316 clock_t start_t = clock();
318 const int tuple_limit = 1000000;
326 for (i = 0; i < 5; ++i) {
333 info[1].
name =
"source";
334 info[2].
name =
"target";
335 info[3].
name =
"cost";
336 info[4].
name =
"reverse_cost";
338 info[0].
strict = !ignore_id;
352 bool moredata =
true;
353 (*totalTuples) = total_tuples = valid_edges = 0;
356 int64_t default_id = 0;
357 while (moredata ==
true) {
358 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
359 if (total_tuples == 0)
362 size_t ntuples = SPI_processed;
363 total_tuples += ntuples;
366 if ((*edges) == NULL)
371 repalloc((*edges), total_tuples *
sizeof(
pgr_edge_t));
373 if ((*edges) == NULL) {
374 elog(ERROR,
"Out of memory");
378 SPITupleTable *tuptable = SPI_tuptable;
379 TupleDesc tupdesc = SPI_tuptable->tupdesc;
380 for (t = 0; t < ntuples; t++) {
381 HeapTuple tuple = tuptable->vals[t];
384 &(*edges)[total_tuples - ntuples + t],
388 SPI_freetuptable(tuptable);
394 SPI_cursor_close(SPIportal);
396 if (total_tuples == 0 || valid_edges == 0) {
400 (*totalTuples) = total_tuples;
401 time_msg(
"reading edges", start_t, clock());
411 clock_t start_t = clock();
413 const int tuple_limit = 1000000;
421 for (i = 0; i < 5; ++i) {
428 info[1].
name =
"source";
429 info[2].
name =
"target";
430 info[3].
name =
"capacity";
431 info[4].
name =
"reverse_capacity";
433 info[0].
strict = !ignore_id;
443 bool moredata =
true;
444 (*totalTuples) = total_tuples = valid_edges = 0;
447 int64_t default_id = 0;
448 while (moredata ==
true) {
449 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
450 if (total_tuples == 0)
453 size_t ntuples = SPI_processed;
454 total_tuples += ntuples;
457 if ((*edges) == NULL)
462 repalloc((*edges), total_tuples *
sizeof(
pgr_flow_t));
464 if ((*edges) == NULL) {
465 elog(ERROR,
"Out of memory");
469 SPITupleTable *tuptable = SPI_tuptable;
470 TupleDesc tupdesc = SPI_tuptable->tupdesc;
472 for (t = 0; t < ntuples; t++) {
473 HeapTuple tuple = tuptable->vals[t];
476 &(*edges)[total_tuples - ntuples + t],
480 SPI_freetuptable(tuptable);
486 SPI_cursor_close(SPIportal);
488 if (total_tuples == 0 || valid_edges == 0) {
492 (*totalTuples) = total_tuples;
493 time_msg(
"Reading edges", start_t, clock());
503 clock_t start_t = clock();
505 const int tuple_limit = 1000000;
513 for (i = 0; i < 5; ++i) {
520 info[1].
name =
"source";
521 info[2].
name =
"target";
522 info[3].
name =
"capacity";
523 info[4].
name =
"reverse_capacity";
524 info[5].
name =
"cost";
525 info[6].
name =
"reverse_cost";
527 info[0].
strict = !ignore_id;
541 bool moredata =
true;
542 (*totalTuples) = total_tuples = valid_edges = 0;
545 int64_t default_id = 0;
546 while (moredata ==
true) {
547 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
548 if (total_tuples == 0)
551 size_t ntuples = SPI_processed;
552 total_tuples += ntuples;
555 if ((*edges) == NULL)
562 if ((*edges) == NULL) {
563 elog(ERROR,
"Out of memory");
567 SPITupleTable *tuptable = SPI_tuptable;
568 TupleDesc tupdesc = SPI_tuptable->tupdesc;
570 for (t = 0; t < ntuples; t++) {
571 HeapTuple tuple = tuptable->vals[t];
574 &(*edges)[total_tuples - ntuples + t],
578 SPI_freetuptable(tuptable);
584 SPI_cursor_close(SPIportal);
586 if (total_tuples == 0 || valid_edges == 0) {
590 (*totalTuples) = total_tuples;
591 time_msg(
"reading edges", start_t, clock());
601 clock_t start_t = clock();
603 const int tuple_limit = 1000000;
611 for (i = 0; i < 5; ++i) {
618 info[1].
name =
"source";
619 info[2].
name =
"target";
620 info[3].
name =
"going";
621 info[4].
name =
"coming";
623 info[0].
strict = !ignore_id;
637 bool moredata =
true;
638 (*totalTuples) = total_tuples = valid_edges = 0;
641 int64_t default_id = 0;
642 while (moredata ==
true) {
643 SPI_cursor_fetch(SPIportal,
true, tuple_limit);
644 if (total_tuples == 0)
647 size_t ntuples = SPI_processed;
648 total_tuples += ntuples;
651 if ((*edges) == NULL)
658 if ((*edges) == NULL) {
659 elog(ERROR,
"Out of memory");
663 SPITupleTable *tuptable = SPI_tuptable;
664 TupleDesc tupdesc = SPI_tuptable->tupdesc;
666 for (t = 0; t < ntuples; t++) {
667 HeapTuple tuple = tuptable->vals[t];
670 &(*edges)[total_tuples - ntuples + t],
673 SPI_freetuptable(tuptable);
679 SPI_cursor_close(SPIportal);
681 if (total_tuples == 0 || valid_edges == 0) {
685 (*totalTuples) = total_tuples;
686 time_msg(
"reading edges", start_t, clock());
694 size_t *total_edges) {
695 bool ignore_id =
false;
704 size_t *total_edges) {
705 bool ignore_id =
false;
714 size_t *total_edges) {
715 bool ignore_id =
false;
725 size_t *total_edges) {
726 bool ignore_id =
false;
736 size_t *total_edges) {
737 bool ignore_id =
true;
747 size_t *total_edges) {
760 size_t *total_edges) {
769 size_t *total_edges) {
770 bool ignore_id =
false;