-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
438f551
commit bf457f1
Showing
5 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
LOAD 'age'; | ||
SET search_path TO ag_catalog; | ||
SELECT create_graph('meta_test_graph'); | ||
NOTICE: graph "meta_test_graph" has been created | ||
create_graph | ||
-------------- | ||
|
||
(1 row) | ||
|
||
SELECT list_graphs(); | ||
list_graphs | ||
----------------- | ||
meta_test_graph | ||
(1 row) | ||
|
||
SELECT list_vertex_labels('meta_test_graph'); | ||
list_vertex_labels | ||
-------------------- | ||
_ag_label_vertex | ||
(1 row) | ||
|
||
SELECT count_vertex_labels('meta_test_graph'); | ||
count_vertex_labels | ||
--------------------- | ||
1 | ||
(1 row) | ||
|
||
SELECT create_vlabel('meta_test_graph','vertex_a'); | ||
NOTICE: VLabel "vertex_a" has been created | ||
create_vlabel | ||
--------------- | ||
|
||
(1 row) | ||
|
||
SELECT list_vertex_labels('meta_test_graph'); | ||
list_vertex_labels | ||
-------------------- | ||
_ag_label_vertex | ||
vertex_a | ||
(2 rows) | ||
|
||
SELECT count_vertex_labels('meta_test_graph'); | ||
count_vertex_labels | ||
--------------------- | ||
2 | ||
(1 row) | ||
|
||
SELECT list_edge_labels('meta_test_graph'); | ||
list_edge_labels | ||
------------------ | ||
_ag_label_edge | ||
(1 row) | ||
|
||
SELECT count_edge_labels('meta_test_graph'); | ||
count_edge_labels | ||
------------------- | ||
1 | ||
(1 row) | ||
|
||
SELECT create_elabel('meta_test_graph','edge_a'); | ||
NOTICE: ELabel "edge_a" has been created | ||
create_elabel | ||
--------------- | ||
|
||
(1 row) | ||
|
||
SELECT list_edge_labels('meta_test_graph'); | ||
list_edge_labels | ||
------------------ | ||
_ag_label_edge | ||
edge_a | ||
(2 rows) | ||
|
||
SELECT count_edge_labels('meta_test_graph'); | ||
count_edge_labels | ||
------------------- | ||
2 | ||
(1 row) | ||
|
||
SELECT drop_graph('meta_test_graph', true); | ||
NOTICE: drop cascades to 4 other objects | ||
DETAIL: drop cascades to table meta_test_graph._ag_label_vertex | ||
drop cascades to table meta_test_graph._ag_label_edge | ||
drop cascades to table meta_test_graph.vertex_a | ||
drop cascades to table meta_test_graph.edge_a | ||
NOTICE: graph "meta_test_graph" has been dropped | ||
drop_graph | ||
------------ | ||
|
||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
LOAD 'age'; | ||
SET search_path TO ag_catalog; | ||
|
||
SELECT create_graph('meta_test_graph'); | ||
|
||
SELECT list_graphs(); | ||
|
||
SELECT list_vertex_labels('meta_test_graph'); | ||
SELECT count_vertex_labels('meta_test_graph'); | ||
SELECT create_vlabel('meta_test_graph','vertex_a'); | ||
SELECT list_vertex_labels('meta_test_graph'); | ||
SELECT count_vertex_labels('meta_test_graph'); | ||
|
||
SELECT list_edge_labels('meta_test_graph'); | ||
SELECT count_edge_labels('meta_test_graph'); | ||
SELECT create_elabel('meta_test_graph','edge_a'); | ||
SELECT list_edge_labels('meta_test_graph'); | ||
SELECT count_edge_labels('meta_test_graph'); | ||
|
||
SELECT drop_graph('meta_test_graph', true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
DROP FUNCTION IF EXISTS ag_catalog.list_graphs; | ||
|
||
CREATE OR REPLACE FUNCTION ag_catalog.list_graphs() | ||
RETURNS TABLE (graph_name name) | ||
LANGUAGE plpgsql | ||
IMMUTABLE | ||
RETURNS NULL ON NULL INPUT | ||
AS $$ | ||
BEGIN | ||
RETURN QUERY EXECUTE 'SELECT name FROM ag_catalog.ag_graph'; | ||
END $$; | ||
|
||
DROP FUNCTION IF EXISTS ag_catalog.list_vertex_labels; | ||
|
||
CREATE OR REPLACE FUNCTION ag_catalog.list_vertex_labels(graph_name name) | ||
RETURNS TABLE (label_name name) | ||
LANGUAGE plpgsql | ||
IMMUTABLE | ||
RETURNS NULL ON NULL INPUT | ||
AS $$ | ||
DECLARE | ||
stmt TEXT; | ||
BEGIN | ||
stmt = FORMAT('SELECT ag_catalog.ag_label.name FROM ag_catalog.ag_label ' || | ||
'INNER JOIN ag_catalog.ag_graph ' || | ||
'ON ag_catalog.ag_label.graph = ag_catalog.ag_graph.graphid ' || | ||
'WHERE kind = ''v'' AND ag_catalog.ag_graph.name = %L', graph_name); | ||
RETURN QUERY EXECUTE stmt; | ||
|
||
END $$; | ||
|
||
DROP FUNCTION IF EXISTS ag_catalog.count_vertex_labels; | ||
|
||
CREATE OR REPLACE FUNCTION ag_catalog.count_vertex_labels(graph_name name) | ||
RETURNS TABLE (total_vertex_labels bigint) | ||
LANGUAGE plpgsql | ||
IMMUTABLE | ||
RETURNS NULL ON NULL INPUT | ||
AS $$ | ||
DECLARE | ||
stmt TEXT; | ||
BEGIN | ||
stmt = FORMAT('SELECT COUNT(ag_catalog.ag_label.name) AS total_vertex_labels ' || | ||
'FROM ag_catalog.ag_label INNER JOIN ag_catalog.ag_graph ' || | ||
'ON ag_catalog.ag_label.graph = ag_catalog.ag_graph.graphid ' || | ||
'WHERE kind = ''v'' AND ag_catalog.ag_graph.name = %L', graph_name); | ||
RETURN QUERY EXECUTE stmt; | ||
|
||
END $$; | ||
|
||
|
||
DROP FUNCTION IF EXISTS ag_catalog.list_edge_labels; | ||
|
||
CREATE OR REPLACE FUNCTION ag_catalog.list_edge_labels(graph_name name) | ||
RETURNS TABLE (label_name name) | ||
LANGUAGE plpgsql | ||
IMMUTABLE | ||
RETURNS NULL ON NULL INPUT | ||
AS $$ | ||
DECLARE | ||
stmt TEXT; | ||
BEGIN | ||
|
||
stmt = FORMAT('SELECT ag_catalog.ag_label.name FROM ag_catalog.ag_label ' || | ||
'INNER JOIN ag_catalog.ag_graph ' || | ||
'ON ag_catalog.ag_label.graph = ag_catalog.ag_graph.graphid ' || | ||
'WHERE kind = ''e'' AND ag_catalog.ag_graph.name = %L', graph_name); | ||
RETURN QUERY EXECUTE stmt; | ||
|
||
END $$; | ||
|
||
DROP FUNCTION IF EXISTS ag_catalog.count_edge_labels; | ||
|
||
CREATE OR REPLACE FUNCTION ag_catalog.count_edge_labels(graph_name name) | ||
RETURNS TABLE (total_edges_labels bigint) | ||
LANGUAGE plpgsql | ||
IMMUTABLE | ||
RETURNS NULL ON NULL INPUT | ||
AS $$ | ||
DECLARE | ||
stmt TEXT; | ||
BEGIN | ||
|
||
stmt = FORMAT('SELECT COUNT(ag_catalog.ag_label.name) AS total_edges_labels ' || | ||
'FROM ag_catalog.ag_label INNER JOIN ag_catalog.ag_graph ' || | ||
'ON ag_catalog.ag_label.graph = ag_catalog.ag_graph.graphid ' || | ||
'WHERE kind = ''e'' AND ag_catalog.ag_graph.name = %L', graph_name); | ||
RETURN QUERY EXECUTE stmt; | ||
|
||
END $$; | ||
|
||
CREATE FUNCTION mul(numeric, numeric) RETURNS numeric | ||
AS 'select $1*$2;' | ||
LANGUAGE SQL | ||
IMMUTABLE | ||
RETURNS NULL ON NULL INPUT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ age_string | |
age_trig | ||
age_aggregate | ||
agtype_typecast | ||
age_meta |