You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by GitBox <gi...@apache.org> on 2022/10/26 22:16:20 UTC

[GitHub] [age] susano0 opened a new pull request, #342: create complete graph function

susano0 opened a new pull request, #342:
URL: https://github.com/apache/age/pull/342

   The query works as follows: 
   ![image](https://user-images.githubusercontent.com/25738879/198148849-f8095fa8-1a60-413a-b8b9-cc8409298b9b.png)
   ![image](https://user-images.githubusercontent.com/25738879/198148875-014c32ec-d192-4de3-bc1d-51314b28ac96.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] JoshInnis commented on pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
JoshInnis commented on PR #342:
URL: https://github.com/apache/age/pull/342#issuecomment-1325792272

   Please add regression tests to this and fix the age--1.1.0.sql file


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] JoshInnis commented on a diff in pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
JoshInnis commented on code in PR #342:
URL: https://github.com/apache/age/pull/342#discussion_r1030956066


##########
src/backend/utils/graph_generation.c:
##########
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "postgres.h"
+
+#include "access/xact.h"
+#include "access/genam.h"
+#include "access/heapam.h"
+#include "catalog/dependency.h"
+#include "catalog/objectaddress.h"
+#include "commands/defrem.h"
+#include "commands/schemacmds.h"
+#include "commands/tablecmds.h"
+#include "fmgr.h"
+#include "miscadmin.h"
+#include "nodes/makefuncs.h"
+#include "nodes/nodes.h"
+#include "nodes/parsenodes.h"
+#include "nodes/pg_list.h"
+#include "nodes/value.h"
+#include "parser/parser.h"
+#include "utils/fmgroids.h"
+#include "utils/relcache.h"
+#include "utils/rel.h"
+
+#include "catalog/ag_graph.h"
+#include "catalog/ag_label.h"
+#include "commands/label_commands.h"
+#include "utils/graphid.h"
+#include "commands/graph_commands.h"
+#include "utils/load/age_load.h"
+#include "utils/load/ag_load_edges.h"
+#include "utils/load/ag_load_labels.h"
+
+
+PG_FUNCTION_INFO_V1(create_complete_graph);
+
+/*
+* SELECT * FROM ag_catalog.create_complete_graph('graph_name',no_of_nodes, 'edge_label', 'node_label'=NULL);
+*/
+
+Datum create_complete_graph(PG_FUNCTION_ARGS)
+{   
+    Oid graph_id;
+    Name graph_name;
+
+    int64 no_vertices;
+    int64 i,j,vid = 1, eid, start_vid, end_vid;
+
+    Name vtx_label_name = NULL;
+    Name edge_label_name;
+    int32 vtx_label_id;
+    int32 edge_label_id;
+
+    agtype *props = NULL;
+    graphid object_graph_id;
+    graphid start_vertex_graph_id;
+    graphid end_vertex_graph_id;
+
+    Oid vtx_seq_id;
+    Oid edge_seq_id;
+
+    char* graph_name_str;
+    char* vtx_name_str;
+    char* edge_name_str;
+
+    graph_cache_data *graph_cache;
+    label_cache_data *vertex_cache;
+    label_cache_data *edge_cache;
+
+    Oid nsp_id;
+    Name vtx_seq_name;
+    char *vtx_seq_name_str;
+
+    Name edge_seq_name;
+    char *edge_seq_name_str;
+
+    int64 lid; 
+
+    if (PG_ARGISNULL(0))
+    {
+        ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                        errmsg("graph name can not be NULL")));
+    }
+
+    if (PG_ARGISNULL(1))
+    {
+        ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("number of nodes can not be NULL")));
+    }
+    
+    if (PG_ARGISNULL(2))
+    {
+        ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                errmsg("edge label can not be NULL")));
+    }
+
+
+    graph_name = PG_GETARG_NAME(0);
+    no_vertices = (int64) PG_GETARG_INT64(1);
+    edge_label_name = PG_GETARG_NAME(2);
+    namestrcpy(vtx_label_name, AG_DEFAULT_LABEL_VERTEX);
+
+    graph_name_str = NameStr(*graph_name);
+    vtx_name_str = AG_DEFAULT_LABEL_VERTEX;
+    edge_name_str = NameStr(*edge_label_name);
+
+
+    if (!graph_exists(graph_name_str))
+    {
+        DirectFunctionCall1(create_graph, CStringGetDatum(graph_name));
+

Review Comment:
   extra newline



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] susano0 commented on pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
susano0 commented on PR #342:
URL: https://github.com/apache/age/pull/342#issuecomment-1293059210

   test expr                         ... FAILED
   
   Need to fix the regression test in expr (issue already exists #306) 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] JoshInnis commented on pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
JoshInnis commented on PR #342:
URL: https://github.com/apache/age/pull/342#issuecomment-1293309570

   You need to research why the regression tests are failing. A change you made is not compatible with the system 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] aked21 merged pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
aked21 merged PR #342:
URL: https://github.com/apache/age/pull/342


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] susano0 closed pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
susano0 closed pull request #342: create complete graph function
URL: https://github.com/apache/age/pull/342


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [age] susano0 commented on pull request #342: create complete graph function

Posted by GitBox <gi...@apache.org>.
susano0 commented on PR #342:
URL: https://github.com/apache/age/pull/342#issuecomment-1293351825

   Fixed the issue


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@age.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org