PGROUTING  3.2
edges_input.c
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: edges_input.c
3 
4 Copyright (c) 2015 Celia Virginia Vergara Castillo
6 
7 ------
8 
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 
23  ********************************************************************PGR-GNU*/
24 
25 #include "c_common/edges_input.h"
26 
27 #include <math.h>
28 #include <float.h>
29 #include <limits.h>
30 /* for size-t */
31 #ifdef __cplusplus
32 # include <cstddef>
33 #else
34 # include <stddef.h>
35 #endif
36 
37 #include "c_types/column_info_t.h"
38 
39 #include "c_common/debug_macro.h"
41 #include "c_common/time_msg.h"
42 
43 static
45  HeapTuple *tuple,
46  TupleDesc *tupdesc,
47  Column_info_t info[5],
48  int64_t *default_id,
50  size_t *valid_edges) {
51  if (column_found(info[0].colNumber)) {
52  edge->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
53  } else {
54  edge->id = *default_id;
55  ++(*default_id);
56  }
57 
58  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
59  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
60  edge->going = pgr_SPI_getFloat8(tuple, tupdesc, info[3]) > 0 ?
61  true : false;
62  edge->coming = (column_found(info[4].colNumber)
63  && pgr_SPI_getFloat8(tuple, tupdesc, info[4]) > 0) ?
64  true : false;
65 
66  (*valid_edges)++;
67 }
68 
69 static
71  HeapTuple *tuple,
72  TupleDesc *tupdesc,
73  Column_info_t info[5],
74  int64_t *default_id,
75  float8 default_rcost,
77  size_t *valid_edges,
78  bool normal) {
79  if (column_found(info[0].colNumber)) {
80  edge->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
81  } else {
82  edge->id = *default_id;
83  ++(*default_id);
84  }
85 
86  if (normal) {
87  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
88  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
89  } else {
90  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
91  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
92  }
93 
94  edge->cost = pgr_SPI_getFloat8(tuple, tupdesc, info[3]);
95 
96  if (column_found(info[4].colNumber)) {
97  edge->reverse_cost = pgr_SPI_getFloat8(tuple, tupdesc, info[4]);
98  } else {
99  edge->reverse_cost = default_rcost;
100  }
101 
102  edge->cost = isinf(edge->cost)?
103  DBL_MAX : edge->cost;
104 
105  edge->reverse_cost = isinf(edge->reverse_cost)?
106  DBL_MAX : edge->reverse_cost;
107 
108  *valid_edges = edge->cost < 0? *valid_edges: *valid_edges + 1;
109  *valid_edges = edge->reverse_cost < 0? *valid_edges: *valid_edges + 1;
110 }
111 
112 static
114  HeapTuple *tuple,
115  TupleDesc *tupdesc,
116  Column_info_t info[7],
117  int64_t *default_id,
118  int64_t default_rcapacity,
119  float8 default_rcost,
121  size_t *valid_edges,
122  bool normal) {
123  if (column_found(info[0].colNumber)) {
124  edge->edge_id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
125  } else {
126  edge->edge_id = *default_id;
127  ++(*default_id);
128  }
129 
130  if (normal) {
131  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
132  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
133  } else {
134  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
135  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
136  }
137 
138  edge->capacity = pgr_SPI_getBigInt(tuple, tupdesc, info[3]);
139  if (column_found(info[4].colNumber)) {
140  edge->reverse_capacity = pgr_SPI_getBigInt(tuple, tupdesc, info[4]);
141  } else {
142  edge->reverse_capacity = default_rcapacity;
143  }
144 
145  edge->cost = pgr_SPI_getFloat8(tuple, tupdesc, info[5]);
146  if (column_found(info[6].colNumber)) {
147  edge->reverse_cost = pgr_SPI_getFloat8(tuple, tupdesc, info[6]);
148  } else {
149  edge->reverse_cost = default_rcost;
150  }
151 
152  *valid_edges = edge->capacity < 0? *valid_edges: *valid_edges + 1;
153  *valid_edges = edge->reverse_capacity < 0? *valid_edges: *valid_edges + 1;
154 }
155 
156 static
158  HeapTuple *tuple,
159  TupleDesc *tupdesc,
160  Column_info_t info[9],
161  int64_t *default_id,
162  float8 default_rcost,
164  size_t *valid_edges,
165  bool normal) {
166  if (column_found(info[0].colNumber)) {
167  edge->id = pgr_SPI_getBigInt(tuple, tupdesc, info[0]);
168  } else {
169  edge->id = *default_id;
170  ++(*default_id);
171  }
172 
173  if (normal) {
174  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
175  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
176  } else {
177  edge->target = pgr_SPI_getBigInt(tuple, tupdesc, info[1]);
178  edge->source = pgr_SPI_getBigInt(tuple, tupdesc, info[2]);
179  }
180  edge->cost = pgr_SPI_getFloat8(tuple, tupdesc, info[3]);
181 
182  if (column_found(info[4].colNumber)) {
183  edge->reverse_cost = pgr_SPI_getFloat8(tuple, tupdesc, info[4]);
184  } else {
185  edge->reverse_cost = default_rcost;
186  }
187 
188  edge->x1 = pgr_SPI_getFloat8(tuple, tupdesc, info[5]);
189  edge->y1 = pgr_SPI_getFloat8(tuple, tupdesc, info[6]);
190  edge->x2 = pgr_SPI_getFloat8(tuple, tupdesc, info[7]);
191  edge->y2 = pgr_SPI_getFloat8(tuple, tupdesc, info[8]);
192 #if 0
193  PGR_DBG("%ld", edge->id);
194  PGR_DBG("x1=%f y1=%.15lf", edge->x1, edge->y1);
195  PGR_DBG("x2=%f y2=%.15lf", edge->x2, edge->y2);
196 #endif
197 
198 
199  *valid_edges = edge->cost < 0? *valid_edges: *valid_edges + 1;
200  *valid_edges = edge->reverse_cost < 0? *valid_edges: *valid_edges + 1;
201 }
202 
203 static
204 void
206  char *sql,
207  Pgr_edge_xy_t **edges,
208  size_t *total_edges,
209  bool normal) {
210  clock_t start_t = clock();
211 
212  const int tuple_limit = 1000000;
213 
214  size_t total_tuples;
215  size_t valid_edges;
216 
217  Column_info_t info[9];
218 
219  info[0].name = "id";
220  info[1].name = "source";
221  info[2].name = "target";
222  info[3].name = "cost";
223  info[4].name = "reverse_cost";
224  info[5].name = "x1";
225  info[6].name = "y1";
226  info[7].name = "x2";
227  info[8].name = "y2";
228 
229  int i;
230  for (i = 0; i < 3; ++i) {
231  info[i].colNumber = -1;
232  info[i].type = 0;
233  info[i].strict = true;
234  info[i].eType = ANY_INTEGER;
235  }
236  for (i = 3; i < 9; ++i) {
237  info[i].colNumber = -1;
238  info[i].type = 0;
239  info[i].strict = true;
240  info[i].eType = ANY_NUMERICAL;
241  }
242  /*
243  * reverse_cost is optional
244  */
245  info[4].strict = false;
246 
247 
248  void *SPIplan;
249  SPIplan = pgr_SPI_prepare(sql);
250 
251  Portal SPIportal;
252  SPIportal = pgr_SPI_cursor_open(SPIplan);
253 
254 
255  bool moredata = true;
256  (*total_edges) = total_tuples = valid_edges = 0;
257 
258 
259  int64_t default_id = 0;
260  while (moredata == true) {
261  SPI_cursor_fetch(SPIportal, true, tuple_limit);
262  if (total_tuples == 0)
263  pgr_fetch_column_info(info, 9);
264 
265  size_t ntuples = SPI_processed;
266  total_tuples += ntuples;
267 
268  if (ntuples > 0) {
269  if ((*edges) == NULL)
270  (*edges) = (Pgr_edge_xy_t *)
271  palloc0(total_tuples * sizeof(Pgr_edge_xy_t));
272  else
273  (*edges) = (Pgr_edge_xy_t *)
274  repalloc((*edges), total_tuples * sizeof(Pgr_edge_xy_t));
275 
276  if ((*edges) == NULL) {
277  elog(ERROR, "Out of memory");
278  }
279 
280  size_t t;
281  SPITupleTable *tuptable = SPI_tuptable;
282  TupleDesc tupdesc = SPI_tuptable->tupdesc;
283  for (t = 0; t < ntuples; t++) {
284  HeapTuple tuple = tuptable->vals[t];
285  fetch_edge_with_xy(&tuple, &tupdesc, info,
286  &default_id, -1,
287  &(*edges)[total_tuples - ntuples + t],
288  &valid_edges, normal);
289  }
290  SPI_freetuptable(tuptable);
291  } else {
292  moredata = false;
293  }
294  }
295 
296  SPI_cursor_close(SPIportal);
297 
298  if (total_tuples == 0 || valid_edges == 0) {
299  PGR_DBG("No edges found");
300  }
301 
302  (*total_edges) = total_tuples;
303  time_msg("reading edges", start_t, clock());
304 }
305 
306 
307 
308 static
309 void
311  char *sql,
312  pgr_edge_t **edges,
313  size_t *totalTuples,
314  bool ignore_id,
315  bool normal) {
316  clock_t start_t = clock();
317 
318  const int tuple_limit = 1000000;
319 
320  size_t total_tuples;
321  size_t valid_edges;
322 
323  Column_info_t info[5];
324 
325  int i;
326  for (i = 0; i < 5; ++i) {
327  info[i].colNumber = -1;
328  info[i].type = 0;
329  info[i].strict = true;
330  info[i].eType = ANY_INTEGER;
331  }
332  info[0].name = "id";
333  info[1].name = "source";
334  info[2].name = "target";
335  info[3].name = "cost";
336  info[4].name = "reverse_cost";
337 
338  info[0].strict = !ignore_id;
339  info[4].strict = false;
340 
341  info[3].eType = ANY_NUMERICAL;
342  info[4].eType = ANY_NUMERICAL;
343 
344 
345  void *SPIplan;
346  SPIplan = pgr_SPI_prepare(sql);
347 
348  Portal SPIportal;
349  SPIportal = pgr_SPI_cursor_open(SPIplan);
350 
351 
352  bool moredata = true;
353  (*totalTuples) = total_tuples = valid_edges = 0;
354 
355 
356  int64_t default_id = 0;
357  while (moredata == true) {
358  SPI_cursor_fetch(SPIportal, true, tuple_limit);
359  if (total_tuples == 0)
360  pgr_fetch_column_info(info, 5);
361 
362  size_t ntuples = SPI_processed;
363  total_tuples += ntuples;
364 
365  if (ntuples > 0) {
366  if ((*edges) == NULL)
367  (*edges) = (pgr_edge_t *)
368  palloc0(total_tuples * sizeof(pgr_edge_t));
369  else
370  (*edges) = (pgr_edge_t *)
371  repalloc((*edges), total_tuples * sizeof(pgr_edge_t));
372 
373  if ((*edges) == NULL) {
374  elog(ERROR, "Out of memory");
375  }
376 
377  size_t t;
378  SPITupleTable *tuptable = SPI_tuptable;
379  TupleDesc tupdesc = SPI_tuptable->tupdesc;
380  for (t = 0; t < ntuples; t++) {
381  HeapTuple tuple = tuptable->vals[t];
382  fetch_edge(&tuple, &tupdesc, info,
383  &default_id, -1,
384  &(*edges)[total_tuples - ntuples + t],
385  &valid_edges,
386  normal);
387  }
388  SPI_freetuptable(tuptable);
389  } else {
390  moredata = false;
391  }
392  }
393 
394  SPI_cursor_close(SPIportal);
395 
396  if (total_tuples == 0 || valid_edges == 0) {
397  PGR_DBG("No edges found");
398  }
399 
400  (*totalTuples) = total_tuples;
401  time_msg("reading edges", start_t, clock());
402 }
403 
404 static
405 void
407  char *sql,
408  pgr_edge_t **edges,
409  size_t *totalTuples,
410  bool ignore_id) {
411  clock_t start_t = clock();
412 
413  const int tuple_limit = 1000000;
414 
415  size_t total_tuples;
416  size_t valid_edges;
417 
418  Column_info_t info[5];
419 
420  int i;
421  for (i = 0; i < 5; ++i) {
422  info[i].colNumber = -1;
423  info[i].type = 0;
424  info[i].strict = true;
425  info[i].eType = ANY_INTEGER;
426  }
427  info[0].name = "id";
428  info[1].name = "source";
429  info[2].name = "target";
430  info[3].name = "capacity";
431  info[4].name = "reverse_capacity";
432 
433  info[0].strict = !ignore_id;
434  info[4].strict = false;
435 
436  void *SPIplan;
437  SPIplan = pgr_SPI_prepare(sql);
438 
439  Portal SPIportal;
440  SPIportal = pgr_SPI_cursor_open(SPIplan);
441 
442 
443  bool moredata = true;
444  (*totalTuples) = total_tuples = valid_edges = 0;
445 
446 
447  int64_t default_id = 0;
448  while (moredata == true) {
449  SPI_cursor_fetch(SPIportal, true, tuple_limit);
450  if (total_tuples == 0)
451  pgr_fetch_column_info(info, 5);
452 
453  size_t ntuples = SPI_processed;
454  total_tuples += ntuples;
455 
456  if (ntuples > 0) {
457  if ((*edges) == NULL)
458  (*edges) = (pgr_edge_t *)
459  palloc0(total_tuples * sizeof(pgr_flow_t));
460  else
461  (*edges) = (pgr_edge_t *)
462  repalloc((*edges), total_tuples * sizeof(pgr_flow_t));
463 
464  if ((*edges) == NULL) {
465  elog(ERROR, "Out of memory");
466  }
467 
468  size_t t;
469  SPITupleTable *tuptable = SPI_tuptable;
470  TupleDesc tupdesc = SPI_tuptable->tupdesc;
471 
472  for (t = 0; t < ntuples; t++) {
473  HeapTuple tuple = tuptable->vals[t];
474  fetch_edge(&tuple, &tupdesc, info,
475  &default_id, -1,
476  &(*edges)[total_tuples - ntuples + t],
477  &valid_edges,
478  true);
479  }
480  SPI_freetuptable(tuptable);
481  } else {
482  moredata = false;
483  }
484  }
485 
486  SPI_cursor_close(SPIportal);
487 
488  if (total_tuples == 0 || valid_edges == 0) {
489  PGR_DBG("No edges found");
490  }
491 
492  (*totalTuples) = total_tuples;
493  time_msg("Reading edges", start_t, clock());
494 }
495 
496 static
497 void
499  char *sql,
500  pgr_costFlow_t **edges,
501  size_t *totalTuples,
502  bool ignore_id) {
503  clock_t start_t = clock();
504 
505  const int tuple_limit = 1000000;
506 
507  size_t total_tuples;
508  size_t valid_edges;
509 
510  Column_info_t info[7];
511 
512  int i;
513  for (i = 0; i < 5; ++i) {
514  info[i].colNumber = -1;
515  info[i].type = 0;
516  info[i].strict = true;
517  info[i].eType = ANY_INTEGER;
518  }
519  info[0].name = "id";
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";
526 
527  info[0].strict = !ignore_id;
528  info[4].strict = false;
529  info[6].strict = false;
530 
531  info[5].eType = ANY_NUMERICAL;
532  info[6].eType = ANY_NUMERICAL;
533 
534  void *SPIplan;
535  SPIplan = pgr_SPI_prepare(sql);
536 
537  Portal SPIportal;
538  SPIportal = pgr_SPI_cursor_open(SPIplan);
539 
540 
541  bool moredata = true;
542  (*totalTuples) = total_tuples = valid_edges = 0;
543 
544 
545  int64_t default_id = 0;
546  while (moredata == true) {
547  SPI_cursor_fetch(SPIportal, true, tuple_limit);
548  if (total_tuples == 0)
549  pgr_fetch_column_info(info, 7);
550 
551  size_t ntuples = SPI_processed;
552  total_tuples += ntuples;
553 
554  if (ntuples > 0) {
555  if ((*edges) == NULL)
556  (*edges) = (pgr_costFlow_t *)
557  palloc0(total_tuples * sizeof(pgr_costFlow_t));
558  else
559  (*edges) = (pgr_costFlow_t *)
560  repalloc((*edges), total_tuples * sizeof(pgr_costFlow_t));
561 
562  if ((*edges) == NULL) {
563  elog(ERROR, "Out of memory");
564  }
565 
566  size_t t;
567  SPITupleTable *tuptable = SPI_tuptable;
568  TupleDesc tupdesc = SPI_tuptable->tupdesc;
569 
570  for (t = 0; t < ntuples; t++) {
571  HeapTuple tuple = tuptable->vals[t];
572  fetch_costFlow_edge(&tuple, &tupdesc, info,
573  &default_id, -1, 0,
574  &(*edges)[total_tuples - ntuples + t],
575  &valid_edges,
576  true);
577  }
578  SPI_freetuptable(tuptable);
579  } else {
580  moredata = false;
581  }
582  }
583 
584  SPI_cursor_close(SPIportal);
585 
586  if (total_tuples == 0 || valid_edges == 0) {
587  PGR_DBG("No edges found");
588  }
589 
590  (*totalTuples) = total_tuples;
591  time_msg("reading edges", start_t, clock());
592 }
593 
594 static
595 void
597  char *sql,
598  pgr_basic_edge_t **edges,
599  size_t *totalTuples,
600  bool ignore_id) {
601  clock_t start_t = clock();
602 
603  const int tuple_limit = 1000000;
604 
605  size_t total_tuples;
606  size_t valid_edges;
607 
608  Column_info_t info[5];
609 
610  int i;
611  for (i = 0; i < 5; ++i) {
612  info[i].colNumber = -1;
613  info[i].type = 0;
614  info[i].strict = true;
615  info[i].eType = ANY_INTEGER;
616  }
617  info[0].name = "id";
618  info[1].name = "source";
619  info[2].name = "target";
620  info[3].name = "going";
621  info[4].name = "coming";
622 
623  info[0].strict = !ignore_id;
624  info[4].strict = false;
625 
626  info[3].eType = ANY_NUMERICAL;
627  info[4].eType = ANY_NUMERICAL;
628 
629 
630  void *SPIplan;
631  SPIplan = pgr_SPI_prepare(sql);
632 
633  Portal SPIportal;
634  SPIportal = pgr_SPI_cursor_open(SPIplan);
635 
636 
637  bool moredata = true;
638  (*totalTuples) = total_tuples = valid_edges = 0;
639 
640 
641  int64_t default_id = 0;
642  while (moredata == true) {
643  SPI_cursor_fetch(SPIportal, true, tuple_limit);
644  if (total_tuples == 0)
645  pgr_fetch_column_info(info, 5);
646 
647  size_t ntuples = SPI_processed;
648  total_tuples += ntuples;
649 
650  if (ntuples > 0) {
651  if ((*edges) == NULL)
652  (*edges) = (pgr_basic_edge_t *)palloc0(
653  total_tuples * sizeof(pgr_basic_edge_t));
654  else
655  (*edges) = (pgr_basic_edge_t *)repalloc(
656  (*edges), total_tuples * sizeof(pgr_basic_edge_t));
657 
658  if ((*edges) == NULL) {
659  elog(ERROR, "Out of memory");
660  }
661 
662  size_t t;
663  SPITupleTable *tuptable = SPI_tuptable;
664  TupleDesc tupdesc = SPI_tuptable->tupdesc;
665 
666  for (t = 0; t < ntuples; t++) {
667  HeapTuple tuple = tuptable->vals[t];
668  fetch_basic_edge(&tuple, &tupdesc, info,
669  &default_id,
670  &(*edges)[total_tuples - ntuples + t],
671  &valid_edges);
672  }
673  SPI_freetuptable(tuptable);
674  } else {
675  moredata = false;
676  }
677  }
678 
679  SPI_cursor_close(SPIportal);
680 
681  if (total_tuples == 0 || valid_edges == 0) {
682  PGR_DBG("No edges found");
683  }
684 
685  (*totalTuples) = total_tuples;
686  time_msg("reading edges", start_t, clock());
687 }
688 
689 /* select id, source, target, capacity, reverse_capacity */
690 void
692  char *sql,
693  pgr_edge_t **edges,
694  size_t *total_edges) {
695  bool ignore_id = false;
696  get_edges_flow(sql, edges, total_edges, ignore_id);
697 }
698 
699 /* select id, source, target, capacity, reverse_capacity, cost, reverse_cost */
700 void
702  char *sql,
703  pgr_costFlow_t **edges,
704  size_t *total_edges) {
705  bool ignore_id = false;
706  get_edges_costFlow(sql, edges, total_edges, ignore_id);
707 }
708 
709 /* select id, source, target, cost, reverse_cost */
710 void
712  char *edges_sql,
713  pgr_edge_t **edges,
714  size_t *total_edges) {
715  bool ignore_id = false;
716  bool normal = true;
717  get_edges_5_columns(edges_sql, edges, total_edges, ignore_id, normal);
718 }
719 
720 /* select id, source AS target, target AS source, cost, reverse_cost */
721 void
723  char *edges_sql,
724  pgr_edge_t **edges,
725  size_t *total_edges) {
726  bool ignore_id = false;
727  bool normal = false;
728  get_edges_5_columns(edges_sql, edges, total_edges, ignore_id, normal);
729 }
730 
731 /* select source, target, cost, reverse_cost */
732 void
734  char *edges_sql,
735  pgr_edge_t **edges,
736  size_t *total_edges) {
737  bool ignore_id = true;
738  bool normal = true;
739  get_edges_5_columns(edges_sql, edges, total_edges, ignore_id, normal);
740 }
741 
742 /* select id, source, target, cost, reverse_cost, x1, y1, x2, y2 */
743 void
745  char *edges_sql,
746  Pgr_edge_xy_t **edges,
747  size_t *total_edges) {
748  get_edges_9_columns(edges_sql, edges, total_edges, true);
749 }
750 
751 /* select id,
752  * source AS target,
753  * target AS source,
754  * cost, reverse_cost,
755  * x1, y1, x2, y2 */
756 void
758  char *edges_sql,
759  Pgr_edge_xy_t **edges,
760  size_t *total_edges) {
761  get_edges_9_columns(edges_sql, edges, total_edges, false);
762 }
763 
764 /* used in flow algorithms */
765 void
767  char *sql,
768  pgr_basic_edge_t **edges,
769  size_t *total_edges) {
770  bool ignore_id = false;
771  get_edges_basic(sql, edges, total_edges, ignore_id);
772 }
Column_info_t::colNumber
int colNumber
Definition: column_info_t.h:51
edge::reverse_cost
float8 reverse_cost
Definition: trsp.h:46
time_msg.h
fetch_basic_edge
static void fetch_basic_edge(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info[5], int64_t *default_id, pgr_basic_edge_t *edge, size_t *valid_edges)
Definition: edges_input.c:44
edge::cost
float8 cost
Definition: trsp.h:45
edge::target
int64 target
Definition: trsp.h:44
pgr_edge_t
Definition: pgr_edge_t.h:37
pgr_get_edges_xy
void pgr_get_edges_xy(char *edges_sql, Pgr_edge_xy_t **edges, size_t *total_edges)
Edges with x, y vertices values.
Definition: edges_input.c:744
Column_info_t::strict
bool strict
Definition: column_info_t.h:53
pgr_SPI_prepare
SPIPlanPtr pgr_SPI_prepare(char *sql)
Definition: postgres_connection.c:94
get_edges_costFlow
static void get_edges_costFlow(char *sql, pgr_costFlow_t **edges, size_t *totalTuples, bool ignore_id)
Definition: edges_input.c:498
pgr_get_edges_no_id
void pgr_get_edges_no_id(char *edges_sql, pgr_edge_t **edges, size_t *total_edges)
edges_sql without id parameter
Definition: edges_input.c:733
pgr_flow_t
Definition: pgr_flow_t.h:37
pgr_get_edges_reversed
void pgr_get_edges_reversed(char *edges_sql, pgr_edge_t **edges, size_t *total_edges)
Definition: edges_input.c:722
get_edges_9_columns
static void get_edges_9_columns(char *sql, Pgr_edge_xy_t **edges, size_t *total_edges, bool normal)
Definition: edges_input.c:205
pgr_get_flow_edges
void pgr_get_flow_edges(char *sql, pgr_edge_t **edges, size_t *total_edges)
read edges for flow
Definition: edges_input.c:691
get_edges_5_columns
static void get_edges_5_columns(char *sql, pgr_edge_t **edges, size_t *totalTuples, bool ignore_id, bool normal)
Definition: edges_input.c:310
edge
Definition: trsp.h:41
pgr_SPI_getBigInt
int64_t pgr_SPI_getBigInt(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
Function returns the value of specified column in integer type.
Definition: get_check_data.c:216
pgr_fetch_column_info
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.
Definition: get_check_data.c:78
debug_macro.h
fetch_edge_with_xy
static void fetch_edge_with_xy(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info[9], int64_t *default_id, float8 default_rcost, Pgr_edge_xy_t *edge, size_t *valid_edges, bool normal)
Definition: edges_input.c:157
pgr_get_edges_xy_reversed
void pgr_get_edges_xy_reversed(char *edges_sql, Pgr_edge_xy_t **edges, size_t *total_edges)
for many to 1 on aStar
Definition: edges_input.c:757
Column_info_t::name
char * name
Definition: column_info_t.h:54
pgr_SPI_cursor_open
Portal pgr_SPI_cursor_open(SPIPlanPtr SPIplan)
Definition: postgres_connection.c:107
get_edges_basic
static void get_edges_basic(char *sql, pgr_basic_edge_t **edges, size_t *totalTuples, bool ignore_id)
Definition: edges_input.c:596
PGR_DBG
#define PGR_DBG(...)
Definition: debug_macro.h:34
pgr_get_basic_edges
void pgr_get_basic_edges(char *sql, pgr_basic_edge_t **edges, size_t *total_edges)
read basic edges
Definition: edges_input.c:766
edge::source
int64 source
Definition: trsp.h:43
pgr_get_edges
void pgr_get_edges(char *edges_sql, pgr_edge_t **edges, size_t *total_edges)
basic edge_sql
Definition: edges_input.c:711
pgr_basic_edge_t
Definition: pgr_basic_edge_t.h:38
pgr_SPI_getFloat8
double pgr_SPI_getFloat8(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info)
Function returns the value of specified column in double type.
Definition: get_check_data.c:246
Column_info_t::eType
expectType eType
Definition: column_info_t.h:55
pgr_get_costFlow_edges
void pgr_get_costFlow_edges(char *sql, pgr_costFlow_t **edges, size_t *total_edges)
read edges for cost flow
Definition: edges_input.c:701
time_msg
void time_msg(char *msg, clock_t start_t, clock_t end_t)
Definition: time_msg.c:32
ANY_INTEGER
@ ANY_INTEGER
Definition: column_info_t.h:41
pgr_costFlow_t
Definition: pgr_costFlow_t.h:38
edge::id
int64 id
Definition: trsp.h:42
column_info_t.h
fetch_costFlow_edge
static void fetch_costFlow_edge(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info[7], int64_t *default_id, int64_t default_rcapacity, float8 default_rcost, pgr_costFlow_t *edge, size_t *valid_edges, bool normal)
Definition: edges_input.c:113
ANY_NUMERICAL
@ ANY_NUMERICAL
Definition: column_info_t.h:42
column_found
bool column_found(int colNumber)
Function will check whether the colNumber represent any specific column or NULL (SPI_ERROR_NOATTRIBUT...
Definition: get_check_data.c:36
edges_input.h
get_check_data.h
Column_info_t::type
uint64_t type
Definition: column_info_t.h:52
Column_info_t
Definition: column_info_t.h:49
fetch_edge
static void fetch_edge(HeapTuple *tuple, TupleDesc *tupdesc, Column_info_t info[5], int64_t *default_id, float8 default_rcost, pgr_edge_t *edge, size_t *valid_edges, bool normal)
Definition: edges_input.c:70
Pgr_edge_xy_t
Definition: pgr_edge_xy_t.h:38
get_edges_flow
static void get_edges_flow(char *sql, pgr_edge_t **edges, size_t *totalTuples, bool ignore_id)
Definition: edges_input.c:406