Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions include/c_types/pgr_componentV_t.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*PGR-GNU*****************************************************************
File: pgr_componentV_t.h

Copyright (c) 2015 Celia Virginia Vergara Castillo
Mail: vicky_vergara@hotmail.com

------

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/
/*! @file */

#ifndef INCLUDE_C_TYPES_PGR_COMPONENTV_T_H_
#define INCLUDE_C_TYPES_PGR_COMPONENTV_T_H_
#pragma once


#ifdef __cplusplus

#include <cstddef>

#else // __cplusplus

// for bool
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-pedantic"
#endif

#include <postgres.h>

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

// For NULL & size_t
#include <stdlib.h>


#endif // __cplusplus

// For int64_t etc
#include <stdint.h>


typedef struct {
int64_t component;
int n_seq;
int64_t node;
} pgr_componentV_t;

#endif // INCLUDE_C_TYPES_PGR_COMPONENTV_T_H_
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#pragma once

#include "c_types/pgr_edge_t.h"
#include "c_types/general_path_element_t.h"
#include "c_types/pgr_componentV_t.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -49,7 +49,7 @@ extern "C" {
do_pgr_connectedComponentsV(
pgr_edge_t *data_edges,
size_t total_edges,
General_path_element_t **return_tuples,
pgr_componentV_t **return_tuples,
size_t *return_count,
char ** log_msg,
char ** notice_msg,
Expand Down
15 changes: 7 additions & 8 deletions src/connectedComponentsV/src/connectedComponentsV.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ process(
ArrayType *starts,
ArrayType *ends,
#endif
General_path_element_t **result_tuples,
pgr_componentV_t **result_tuples,
size_t *result_count) {
/*
* https://www.postgresql.org/docs/current/static/spi-spi-connect.html
Expand Down Expand Up @@ -173,7 +173,7 @@ PGDLLEXPORT Datum connectedComponentsV(PG_FUNCTION_ARGS) {
/**************************************************************************/
/* MODIFY AS NEEDED */
/* */
General_path_element_t *result_tuples = NULL;
pgr_componentV_t *result_tuples = NULL;
size_t result_count = 0;
/* */
/**************************************************************************/
Expand Down Expand Up @@ -231,7 +231,7 @@ PGDLLEXPORT Datum connectedComponentsV(PG_FUNCTION_ARGS) {

funcctx = SRF_PERCALL_SETUP();
tuple_desc = funcctx->tuple_desc;
result_tuples = (General_path_element_t*) funcctx->user_fctx;
result_tuples = (pgr_componentV_t*) funcctx->user_fctx;

if (funcctx->call_cntr < funcctx->max_calls) {
HeapTuple tuple;
Expand All @@ -258,11 +258,10 @@ PGDLLEXPORT Datum connectedComponentsV(PG_FUNCTION_ARGS) {
}

// postgres starts counting from 1
// TODO(mg) Create a structure with the names & types needed
values[0] = Int32GetDatum(funcctx->call_cntr + 1); // --seq
values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].start_id); // --component
values[3] = Int32GetDatum(result_tuples[funcctx->call_cntr].seq); // --n_seq
values[4] = Int64GetDatum(result_tuples[funcctx->call_cntr].node); // --node
values[0] = Int32GetDatum(funcctx->call_cntr + 1); // seq
values[2] = Int64GetDatum(result_tuples[funcctx->call_cntr].component); // component
values[3] = Int32GetDatum(result_tuples[funcctx->call_cntr].n_seq); // n_seq
values[4] = Int64GetDatum(result_tuples[funcctx->call_cntr].node); // node
/**********************************************************************/

tuple = heap_form_tuple(tuple_desc, values, nulls);
Expand Down
5 changes: 3 additions & 2 deletions src/connectedComponentsV/src/connectedComponentsV_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void
do_pgr_connectedComponentsV(
pgr_edge_t *data_edges,
size_t total_edges,
General_path_element_t **return_tuples,
pgr_componentV_t **return_tuples,
size_t *return_count,
char ** log_msg,
char ** notice_msg,
Expand Down Expand Up @@ -101,7 +101,8 @@ do_pgr_connectedComponentsV(

(*return_tuples) = pgr_alloc(count, (*return_tuples));
size_t sequence = 0;
path.generate_postgres_data(return_tuples, sequence);
// TODO(mg) write a new function that counts the return_tuples
//path.generate_postgres_data(return_tuples, sequence);
(*return_count) = sequence;

pgassert(*err_msg == NULL);
Expand Down