├── .gitignore
├── LICENSE
├── README.md
├── docs
├── .nojekyll
├── Makefile
├── index.html
├── make.bat
└── source
│ ├── .DS_Store
│ ├── api
│ ├── 1.topology_api.rst
│ ├── 2.property_api.rst
│ ├── 3.partition_api.rst
│ ├── 4.index_api.rst
│ ├── 5.common_api.rst
│ └── 6.extension_api.rst
│ ├── conf.py
│ ├── get_started.rst
│ ├── guide
│ ├── storage.rst
│ └── user.rst
│ └── index.rst
├── extension
├── handle.h
├── include
│ ├── indexed_adjacent_list.h
│ ├── list_chain.h
│ └── static_message.h
└── src
│ ├── indexed_adjacent_list.cc
│ ├── list_chain.cc
│ └── static_message.cc
├── include
├── common
│ ├── enum_types.h
│ ├── error.h
│ └── message.h
├── index
│ ├── external_id.h
│ ├── internal_id.h
│ ├── label.h
│ ├── order.h
│ └── pk.h
├── partition
│ ├── partition.h
│ ├── reference.h
│ └── topology.h
├── property
│ ├── label.h
│ ├── primarykey.h
│ ├── property.h
│ ├── propertylist.h
│ ├── row.h
│ ├── topology.h
│ ├── type.h
│ └── value.h
└── topology
│ ├── adjacentlist.h
│ ├── edgelist.h
│ ├── structure.h
│ └── vertexlist.h
├── proto
├── gie_data_model
│ ├── data_type.proto
│ ├── graph.proto
│ ├── partition.proto
│ ├── schema.proto
│ └── statistics.proto
├── grin_schema
│ ├── data_type.proto
│ ├── graph.proto
│ ├── partition.proto
│ └── schema.proto
└── storage.proto
├── rust
├── Cargo.toml
├── README.md
├── codegen.py
├── grin.rs
├── grin_GraphAr.h
├── grin_GraphAr.rs
├── grin_all.h
├── grin_all.rs
├── grin_gart.h
├── grin_gart.rs
├── grin_v6d.h
└── grin_v6d.rs
├── scripts
├── check_predefine.py
└── enabled_apis.py
├── storage
├── GART
│ └── predefine.h
├── GraphAr
│ └── predefine.h
└── v6d
│ └── predefine.h
├── template
├── features.h
└── predefine.h
├── test
├── ext_test.c
├── test.c
└── wcc.c
└── yaml
└── schema.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/
2 | docs/html/
3 | docs/build/
4 | docs/.*
5 | .DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GRIN
2 | GRIN is a proposed standard graph retrieval interface in GraphScope. The goal of GRIN is to provide a common way for the graph computing engines to retrieve graph data stored in different storage systems in GraphScope, and to simplify the integration of these engines with each other.
3 |
4 | GRIN is defined in C, which makes it portable to systems written in different programming languages, such as C++, Rust and Java. It provides a set of common operations and data structure handles that can be used to access graph data, regardless of the underlying storage system.
5 |
6 | These operations include:
7 | * Traversal: navigating the graph structure to explore relationships between vertices
8 | * Retrieval: retrieving the data and properties of vertices and edges
9 | * Filter: filtering data structures with partitioning or property conditions
10 |
11 | GRIN is designed to be read-only, meaning that it does not provide operations for modifying the graph data. This decision was made to simplify the implementation of GRIN and ensure that it can be used safely with any storage system.
12 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GraphScope/GRIN/0bc55865dc2d2d394df6900e4e5c5e56a08e3501/docs/.nojekyll
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docs/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 |
13 | %SPHINXBUILD% >NUL 2>NUL
14 | if errorlevel 9009 (
15 | echo.
16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17 | echo.installed, then set the SPHINXBUILD environment variable to point
18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
19 | echo.may add the Sphinx directory to PATH.
20 | echo.
21 | echo.If you don't have Sphinx installed, grab it from
22 | echo.https://www.sphinx-doc.org/
23 | exit /b 1
24 | )
25 |
26 | if "%1" == "" goto help
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/docs/source/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GraphScope/GRIN/0bc55865dc2d2d394df6900e4e5c5e56a08e3501/docs/source/.DS_Store
--------------------------------------------------------------------------------
/docs/source/api/1.topology_api.rst:
--------------------------------------------------------------------------------
1 | Graph Topology and APIs
2 | -----------------------
3 | To retrieve graph data, accessing the topology of the graph is essential.
4 | This involves accessing the vertices and edges of the graph.
5 | In GRIN, the vertices are arranged in a vertex list,
6 | and there are several vertex list APIs available for accessing them.
7 | As for the representation of graph edges, commonly used sparse matrix representations include CSR, CSC, and COO.
8 | In GRIN, the adjacent list is used for CSR and CSC representations,
9 | while the edge list is used for COO.
10 |
11 |
12 | Vertex List
13 | ^^^^^^^^^^^
14 | The API to get the vertex list of a graph is as follows:
15 |
16 | .. code-block:: c
17 |
18 | GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH);
19 |
20 | Here the input parameter is the graph handle, and the return value is the vertex list handle.
21 | From the vertex list handle, GRIN provides two ways to access the vertices,
22 | namely the iterator and array-like access.
23 |
24 | To iterate the vertices in the vertex list, the following APIs are provided:
25 |
26 | .. code-block:: c
27 |
28 | GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH, GRIN_VERTEX_LIST);
29 |
30 | void grin_get_next_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
31 |
32 | bool grin_is_vertex_list_end(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
33 |
34 | GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
35 |
36 |
37 | The first API returns the iterator pointing to the first vertex in the vertex list,
38 | and the second API "moves" the iterator to the next vertex in the vertex list.
39 | The third API checks whether the iterator has reached the end of the vertex list.
40 | The last API returns the vertex pointed by the iterator.
41 |
42 | The array-like access to the vertex list is provided by the following APIs:
43 |
44 | .. code-block:: c
45 |
46 | size_t grin_get_vertex_list_size(GRIN_GRAPH, GRIN_VERTEX_LIST);
47 |
48 | GRIN_VERTEX grin_get_vertex_from_list(GRIN_GRAPH, GRIN_VERTEX_LIST, size_t);
49 |
50 | The first API returns the number of vertices in the vertex list,
51 | and the second API returns the vertex at the given position of the list.
52 |
53 | Storages may implement either ways or both for the vertex list, based on their own characteristics.
54 | In general, a storage that supports random access to the vertex list
55 | is recommended to implement both ways, while a storage that does not support
56 | random access may only implement the iterator way.
57 |
58 |
59 | Adjacent List
60 | ^^^^^^^^^^^^^^
61 | The API to get the adjacent list of a vertex is as follows:
62 |
63 | .. code-block:: c
64 |
65 | GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
66 |
67 | The second input parameter of ``GRIN_DIRECTION`` in the function refers to the direction of the adjacent list.
68 | When the value is set to ``OUT``, it represents the outgoing adjacent list,
69 | while ``IN`` represents the incoming adjacent list.
70 | These directions are related to the CSR and CSC representations, respectively.
71 |
72 | Similar to the vertex list, GRIN provides two ways to access the adjacent list,
73 | namely the iterator and array-like access.
74 | Thus, the APIs for the adjacent list are very similar to those for the vertex list.
75 |
76 |
77 | Edge List
78 | ^^^^^^^^^^
79 | The API to get the edge list of a graph is as follows:
80 |
81 | .. code-block:: c
82 |
83 | GRIN_EDGE_LIST grin_get_edge_list(GRIN_GRAPH);
84 |
85 | The input parameter is the graph handle, and the return value is the edge list handle.
86 | The edge list feature is related to the COO representation.
87 | Most storages does not support the edge list feature, because COO is considered
88 | as a less efficient representation for graph traversal.
89 |
90 | The APIs for the edge list are similar to those for the vertex list and adjacent list.
91 | We don't repeat them here.
--------------------------------------------------------------------------------
/docs/source/api/4.index_api.rst:
--------------------------------------------------------------------------------
1 | Graph Index and APIs
2 | =====================
3 | The main purpose of a graph index is to enhance data retrieval efficiency. Users can efficiently
4 | identify a vertex or an edge using primary keys, labels, or internal/external IDs, where indices are built.
5 |
6 |
7 | External ID
8 | -------------
9 | The concept of external ID in graph storage is derived from the
10 | Internationalized Resource Identifier (IRI) used in the Resource
11 | Description Framework (RDF). In a graph, the external ID of a vertex is a
12 | unique identifier that is neither assigned by the storage nor the users,
13 | but existing in the raw data of the graph.
14 | GRIN allows storages to expose two types of external IDs: string and integer.
15 | The string external ID is a sequence of characters, while the integer
16 | external ID is a 64-bit integer.
17 |
18 | Using the string case as an example, we list the related APIs as follows:
19 |
20 | .. code-block:: c
21 |
22 | GRIN_VERTEX grin_get_vertex_by_external_id_of_string(GRIN_GRAPH, const char* id);
23 |
24 | const char* grin_get_vertex_external_id_of_string(GRIN_GRAPH, GRIN_VERTEX);
25 |
26 | Note that the returned external ID should be destroyed by the user after use:
27 |
28 | .. code-block:: c
29 |
30 | void grin_destroy_vertex_external_id_of_string(GRIN_GRAPH, const char*);
31 |
32 |
33 |
34 | Internal ID
35 | -------------
36 | When storing graphs, it is common to assign internal IDs to vertices. These
37 | internal IDs help in representing the vertices within the storage. However,
38 | different storage systems may adopt different strategies for assigning these
39 | internal IDs.
40 |
41 | GRIN allows storage systems to expose their specific internal ID assignments
42 | through a range constraint. This constraint requires the storage system to
43 | provide both a lower bound (closed) and an upper bound (open) for the internal
44 | IDs. By knowing this ID range, users can treat the internal IDs as an array
45 | index range in computations.
46 |
47 | Utilizing the internal IDs in this manner reduces complexity from O(log(n)) to
48 | O(1) when compared to using external IDs as keys in a mapping. This approach
49 | allows for faster computations and improved efficiency.
50 |
51 | GRIN assumes that the internal IDs are 64-bit integers. The range
52 | constraint is imposed on all vertices for a simple graph and on all vertices
53 | within each type for a LPG.
54 |
55 | The APIs for internal ID on simple graphs are as follows:
56 |
57 | .. code-block:: c
58 |
59 | long long int grin_get_vertex_internal_id(GRIN_GRAPH, GRIN_VERTEX);
60 |
61 | GRIN_VERTEX grin_get_vertex_by_internal_id(GRIN_GRAPH, long long int id);
62 |
63 | long long int grin_get_vertex_internal_id_upper_bound(GRIN_GRAPH);
64 |
65 | long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH);
66 |
67 | While the APIs for internal ID on LPGs are as follows:
68 |
69 | .. code-block:: c
70 |
71 | long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX);
72 |
73 | GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, long long int id);
74 |
75 | long long int grin_get_vertex_internal_id_upper_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
76 |
77 | long long int grin_get_vertex_internal_id_lower_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
78 |
79 |
80 |
81 | PK Indexing
82 | ------------
83 | PK indexing is used to retrieve a vertex or an edge based on its primary keys
84 | (PK). To obtain a vertex using its PK values, we need to arrange all the values
85 | into a row, following the PK properties of the vertex's type. This row can then
86 | be used to retrieve the vertex handle. The case for an edge is similar.
87 |
88 | The following example illustrates how to retrieve a vertex of type "person" with
89 | a name of "marko" and an age of 29, assuming that the PK properties for "person"
90 | are "name" and "age".
91 |
92 | .. code-block:: c
93 |
94 | GRIN_VERTEX_TYPE vtype = grin_get_vertex_type_by_name(g, "person");
95 | GRIN_ROW row = grin_create_row(g);
96 | if (!grin_insert_string_to_row(g, row, "marko")) {
97 | printf("Failed to insert string to row\n");
98 | }
99 | if (!grin_insert_int32_to_row(g, row, 29)) {
100 | printf("Failed to insert int32 to row\n");
101 | }
102 | GRIN_VERTEX v = grin_get_vertex_by_primary_keys(g, vtype, row);
103 |
104 |
105 | Label Indexing
106 | ---------------
107 | Label indexing is used to retrieve vertices or edges having a specific label.
108 |
109 | For simple graphs, the APIs are:
110 |
111 | .. code-block:: c
112 |
113 | GRIN_VERTEX_LIST grin_get_vertex_list_by_label(GRIN_GRAPH, GRIN_LABEL);
114 |
115 | GRIN_EDGE_LIST grin_get_edge_list_by_label(GRIN_GRAPH, GRIN_LABEL);
116 |
117 | For LPGs, the APIs are:
118 |
119 | .. code-block:: c
120 |
121 | GRIN_VERTEX_LIST grin_get_vertex_list_by_type_by_label(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_LABEL);
122 |
123 | GRIN_EDGE_LIST grin_get_edge_list_by_type_by_label(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_LABEL);
124 |
125 | This is because vertex and edge lists in LPGs can only contain vertices and edges of the same type.
126 |
--------------------------------------------------------------------------------
/docs/source/api/5.common_api.rst:
--------------------------------------------------------------------------------
1 | Common Functional APIs
2 | =======================
3 |
4 | Error Code
5 | --------------
6 | GRIN uses the ``error code`` mechanism to indicate errors for return value types
7 | that are hard to define ``invalid`` values, such as ``int`` and ``double``.
8 |
9 | The following code snippet shows how to check the returned value is valid
10 | when calling the API to get a vertex property value of ``int32``.
11 |
12 | .. code-block:: c
13 | :linenos:
14 |
15 | GRIN_GRAPH g = ...
16 | GRIN_VERTEX v = ...
17 | GRIN_VERTEX_PROPERTY vp = ...
18 |
19 | int value = grin_get_vertex_property_value_of_int32(g, v, vp);
20 | if (grin_get_last_error_code() != GRIN_ERROR_CODE::NO_ERROR) {
21 | // handle error
22 | }
23 |
24 | Suppose we have obtained three handles in GRIN: the graph handle, the vertex handle, and
25 | the vertex property handle.
26 | In the fifth line, we aim to retrieve the vertex property value of the vertex ``v``.
27 | To verify the validity of the returned ``value``, we can use the API ``grin_get_last_error_code``
28 | in the sixth line. This API allows us to retrieve the last error code. We can then compare this
29 | error code with the ``GRIN_ERROR_CODE::NO_ERROR``.
30 |
31 | In GRIN, the ``GRIN_ERROR_CODE`` is an enumeration that defines all the error codes used in GRIN.
32 | Currently GRIN has defined the following error codes:
33 |
34 | - ``NO_ERROR``: Success.
35 | - ``UNKNOWN_ERROR``: Unknown error.
36 | - ``UNKNOWN_DATATYPE``: The data type is unknown.
37 | - ``INVALID_VALUE``: The return value is invalid (some error happens when retrieving the value).
38 | - ``NULL_VALUE``: The return value is null (missing).
39 |
40 |
41 | Schema Message
42 | --------------
43 | Usually, before users start using GRIN to retrieve graph data, they would like
44 | to know the schema of the graph data in order to optimize their execution plans.
45 | GRIN provides a protobuf definition for the graph schema, along with an API for
46 | retrieving the schema message.
47 |
48 | .. code-block:: c
49 |
50 | const char* grin_get_graph_schema_msg(const char* uri);
51 |
52 | The API requires the user to provide the URI of the
53 | graph as input. In return, it provides the schema message in JSON format.
54 |
55 | The schema protobuf primarily contains two main definitions: the *LPG schema*
56 | and the *partition strategy*. If the graph uses the LPG data model, the storage
57 | should fill in the *LPG schema* part. Similarly, if the graph is partitioned,
58 | the storage should fill in the *partition strategy* part. The details of the
59 | schema protobuf can be found in the ``proto`` directory.
--------------------------------------------------------------------------------
/docs/source/api/6.extension_api.rst:
--------------------------------------------------------------------------------
1 | Extension APIs
2 | ===============
3 |
4 | GRIN Extension offers high-level handles and APIs to provide advanced functionalities,
5 | with default implementation using basic (low-level) APIs of GRIN.
6 | Storages may overwrite the default implementation if they can provide more efficient
7 | implementations.
8 |
9 |
10 | List Chain
11 | -------------
12 | As we mentioned in ``Property Graph and APIs``,
13 | GRIN offers low-level APIs to retrieve the vertex list of a single vertex type for LPGs,
14 | due to the type-centric data organization of LPG.
15 | However, in many cases, users need to traverse all the vertices in a LPG.
16 | Although the user can first iterate all the vertex types and then get the vertex list of each vertex type to traverse,
17 | this approach increases boilerplate code.
18 |
19 | To address this issue, GRIN extension provides a high-level handle ``GRIN_VERTEX_LIST_CHAIN``,
20 | which is a chain of vertex lists of all vertex types in a LPG.
21 | To traverse all the vertices in a LPG, users can first get the vertex list chain from the LPG as follows:
22 |
23 | .. code-block:: c
24 |
25 | GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types(GRIN_GRAPH);
26 |
27 | Then iterate the vertex list chain just like a vertex list to get all the vertices using the following APIs:
28 |
29 | .. code-block:: c
30 |
31 | GRIN_VERTEX_LIST_CHAIN_ITERATOR grin_get_vertex_list_chain_begin(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN);
32 |
33 | void grin_get_next_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
34 |
35 | bool grin_is_vertex_list_chain_end(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
36 |
37 | GRIN_VERTEX grin_get_vertex_from_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
38 |
39 | Note that we can also select master and mirror vertices from the vertex list chain, like what we do for a vertex list:
40 |
41 | .. code-block:: c
42 |
43 | GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_master(GRIN_GRAPH);
44 |
45 | GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_mirror(GRIN_GRAPH);
46 |
47 | GRIN does NOT offer array-like access for a vertex list chain, because it may incur hidden overhead to
48 | maintain the array-like access using the basic APIs of GRIN.
49 |
50 | Similar APIs are also defined for edge list chain and adjacent list chain. We don't repeat them here.
51 |
52 |
53 | Indexed Adjacent List
54 | ----------------------
55 | Some storage systems may only provide an iterator for the adjacent list of a
56 | vertex, which means that array-like access is not available. This limitation
57 | is often due to efficiency concerns, particularly when the storage system does
58 | not maintain a continuous memory layout for the adjacent list.
59 |
60 | However, in many cases, users need to access the adjacent list of a vertex using
61 | array-like access, especially during the sampling phase of a GNN (Graph Neural
62 | Network) algorithm.
63 |
64 | To address this issue, the GRIN extension offers a high-level handle called
65 | ``GRIN_INDEXED_ADJACENT_LIST``. This handle allows for array-like access to the
66 | adjacent list of a vertex by temporarily caching the adjacent list in memory.
67 |
68 | The APIs are as follows:
69 |
70 | .. code-block:: c
71 |
72 | GRIN_INDEXED_ADJACENT_LIST grin_get_indexed_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST);
73 |
74 | void grin_destroy_indexed_adjacent_list(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST);
75 |
76 | size_t grin_get_indexed_adjacent_list_size(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST);
77 |
78 | GRIN_VERTEX grin_get_neighbor_from_indexed_adjacent_list(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST, size_t);
79 |
80 | GRIN_EDGE grin_get_edge_from_indexed_adjacent_list(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST, size_t);
81 |
82 |
83 | Static Storage Feature Message
84 | -------------------------------
85 |
86 | C macros are used by GRIN to filter out APIs that storage systems cannot
87 | handle. In the above example, some storage system may not support array-like access
88 | to the adjacent list of a vertex. In such a case, the storage system can
89 | disable the ``GRIN_ENABLE_ADJACENT_LIST_ARRAY`` macro to exclude the APIs
90 | related to array-like access of adjacent lists.
91 | The selections on macros are referred to
92 | as the ``static storage features`` of a storage system.
93 |
94 | When users access a storage system through GRIN, they may need to know the
95 | static storage features of the storage system to adjust their execution plans
96 | accordingly. GRIN defines the ``static storage features`` as a proto
97 | (Protocol Buffer) in ``proto/storage.proto`` and provides a common API in GRIN
98 | extension to automatically generate the proto message for the storage
99 | system.
100 |
101 | The API is:
102 |
103 | .. code-block:: c
104 |
105 | const char* grin_get_static_storage_feature_msg();
106 |
107 | The returned string is a JSON string that contains the static storage features of the storage system.
108 |
109 |
--------------------------------------------------------------------------------
/docs/source/conf.py:
--------------------------------------------------------------------------------
1 | # Configuration file for the Sphinx documentation builder.
2 | #
3 | # For the full list of built-in configuration values, see the documentation:
4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html
5 |
6 | # -- Project information -----------------------------------------------------
7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8 |
9 | project = 'GRIN'
10 | copyright = '2023, grin workers'
11 | author = 'grin workers'
12 | release = '0.1.4'
13 |
14 | # -- General configuration ---------------------------------------------------
15 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16 |
17 | extensions = []
18 |
19 | templates_path = ['_templates']
20 | exclude_patterns = []
21 |
22 |
23 |
24 | # -- Options for HTML output -------------------------------------------------
25 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
26 |
27 | html_theme = 'furo'
28 | html_static_path = ['_static']
29 |
--------------------------------------------------------------------------------
/docs/source/get_started.rst:
--------------------------------------------------------------------------------
1 | Getting Started
2 | ----------------
3 |
4 | Get Graph from Storage
5 | ^^^^^^^^^^^^^^^^^^^^^^
6 | GRIN offers a set of APIs to retrieve graph data in storage.
7 | The first API we need is to get a graph handle for a graph from storage.
8 | The API is:
9 |
10 | .. code-block:: c
11 |
12 | GRIN_GRAPH grin_get_graph_from_storage(const char* uri);
13 |
14 | This API takes a URI as its parameter, which is a string that identifies the graph in storage.
15 |
16 | Different storage systems may define different required parameters in the URI:
17 |
18 | - gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}
19 | - graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}
20 | - v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.
21 |
22 | The return value of this API is a GRIN graph handle.
23 |
24 | Handle
25 | ^^^^^^^^^
26 | A handle is an opaque value that identifies an object in GRIN. The type of a handle is
27 | predefined by the storage using ``typedef`` in ``C``. For example, the handle type
28 | ``GRIN_GRAPH`` we mentioned earlier could be declared as ``void*`` in some storage
29 | implementation.
30 |
31 | It is important to note that users should not make any assumptions about the type or
32 | value of a handle. Handles should be used as input parameters for related APIs to access
33 | the object they represent.
34 |
35 | For instance, let's consider an example where we use the mentioned API to obtain a graph
36 | handle. We can then use this handle to check whether the graph is directed.
37 | The code is as follows:
38 |
39 | .. code-block:: c
40 | :linenos:
41 |
42 | #include "predefine.h"
43 | #include "topology/structure.h"
44 |
45 | int main(int argc, char** argv) {
46 | GRIN_GRAPH g = grin_get_graph_from_storage(argv[1]);
47 |
48 | if (grin_is_directed(g)) {
49 | printf("The graph is directed");
50 | } else {
51 | printf("The graph is undirected");
52 | }
53 | }
54 |
55 | In the code snippet, the first line includes the ``predefine.h`` header file, which contains the
56 | necessary typedef for ``GRIN_GRAPH`` and other handles in GRIN. The second line includes the
57 | ``topology/structure.h`` header file, which declares the API ``bool grin_is_directed(GRIN_GRAPH)``.
58 | Moving on, in the fifth line of the ``main`` function, the graph handle ``g`` is obtained from the
59 | storage using a given uri from the command-line. Finally, in the seventh line, we can check whether
60 | the graph represented by ``g`` is directed.
61 |
62 | GRIN provides various handle types, each representing a specific graph concept. These handle
63 | types include graph, vertex, edge, vertex list, edge list, adjacent list, and more. We will introduce
64 | these handle types in detail when discussing related APIs.
65 |
66 | Return Values
67 | ^^^^^^^^^^^^^^
68 | The most common return values of GRIN APIs are handles. These handles correspond to the resources
69 | created by the APIs. To free these resources after use, GRIN provides corresponding ``destroy`` APIs.
70 | For example, when calling the ``grin_get_graph_from_storage`` API, a graph handle is returned, which
71 | can be freed using the ``grin_destroy_graph`` API. It's important to note that GRIN APIs are stateless,
72 | meaning that the responsibility of memory management lies with the users, rather than the storages.
73 |
74 | Some APIs may return values other than handles, such as primitive types like ``int`` and ``double``.
75 | For example, primitive values returned by APIs to get vertex property values are stored on the ``stack``,
76 | meaning they do not need to be freed. We will provide more
77 | detailed information about these return values and whether or not there are corresponding
78 | ``destroy`` APIs, when discussing related APIs.
79 |
80 | Error Handling
81 | ^^^^^^^^^^^^^^^
82 | Each handle type also has a ``invalid`` value.
83 | For example, the ``GRIN_GRAPH`` handle type has a ``invalid`` value denoted as ``GRIN_NULL_GRAPH``.
84 | When the ``grin_get_graph_from_storage`` API cannot find the graph with the given uri from the storage,
85 | it returns the ``GRIN_NULL_GRAPH`` value. This value can be used to check whether the API call is
86 | successful. An example code snippet is as follows:
87 |
88 | .. code-block:: c
89 |
90 | #include "predefine.h"
91 | #include "topology/structure.h"
92 |
93 | int main(int argc, char** argv) {
94 | GRIN_GRAPH g = grin_get_graph_from_storage(argv[1]);
95 |
96 | if (g == GRIN_NULL_GRAPH) {
97 | printf("The graph does not exist");
98 | } else {
99 | printf("The graph exists");
100 | }
101 | }
102 |
103 | The ``GRIN_NULL_GRAPH`` value is also defined in the ``predefine.h`` header file,
104 | using a ``#define`` statetment as follows:
105 |
106 | .. code-block:: c
107 |
108 | #define GRIN_NULL_GRAPH NULL
109 |
110 | However, it is hard to define a ``invalid`` value for primitive types like ``int`` or ``double``.
111 | Therefore, GRIN uses the ``error code`` mechanism to indicate errors for these return value types.
112 | The details can be found in the ``Error Code`` section in ``Common Functional APIs``.
--------------------------------------------------------------------------------
/docs/source/guide/storage.rst:
--------------------------------------------------------------------------------
1 | Developer Guide For Storage Implementors
2 | -----------------------------------------
3 |
4 | To support GRIN, storage system implementors should implement the APIs that
5 | they **choose** to support.
6 | The first step is to create a ``predefine.h`` header file from the template.
7 | Within this header file, the implementors will define the macros for the
8 | categories and traits they have decided to support. Additionally, they will
9 | type-define the corresponding handle types.
10 | Finally, the implementors will proceed to implement the APIs of the categories
11 | and traits that they have chosen to support.
12 |
13 |
14 | Implementation Principles
15 | ==========================
16 |
17 | Efficiency First
18 | ^^^^^^^^^^^^^^^^^
19 | To effectively implement GRIN APIs, implementors should prioritize efficiency as
20 | their main consideration. It is crucial to aim for the best possible time
21 | complexity, while still maintaining a reasonable level of space complexity.
22 | Ideally, the recommended upper bound for time complexity should be O(log n),
23 | where n represents the size of the graph.
24 |
25 | In cases where achieving O(log n) time complexity is not feasible for certain
26 | APIs, implementors should explore the option of caching the results the first
27 | time the API is called. Subsequently, when the API is called again, the cached
28 | results can be returned, thereby improving overall performance.
29 |
30 |
31 | More Traits More Users
32 | ^^^^^^^^^^^^^^^^^^^^^^^
33 | The implementation of a storage system should aim to support a wide range of
34 | categories and traits. This is important because certain users may depend on
35 | specific traits to effectively implement their algorithms. For instance,
36 | graph analytical systems often rely on the ``internal ID`` indexing trait in
37 | order to efficiently implement a Single-Source Shortest Path (SSSP)
38 | algorithm. By incorporating a greater number of traits, a storage system can
39 | cater to a larger user base seeking to implement their algorithms using GRIN.
40 |
41 |
42 | How to Implement GRIN
43 | ======================
44 |
45 | To implement GRIN within a storage system, follow these steps:
46 |
47 | 1. Add GRIN as a submodule to the storage system's repository.
48 | 2. Create a ``grin`` folder.
49 | 3. Inside the ``grin`` folder, create a ``predefine.h`` header file using the
50 | provided template from GRIN.
51 | 4. Define the macros for the categories and traits that the storage system has
52 | decided to support in the ``predefine.h`` header file.
53 | 5. Type-define the corresponding handle types in the ``predefine.h`` header file.
54 | 6. Create a ``src`` folder inside the ``grin`` folder and create sub-folders for
55 | each category.
56 | 7. Implement the APIs of each category in their corresponding sub-folders.
57 | 8. Add scripts to build and install the GRIN library into the storage system's
58 | build system (e.g., CMakeLists.txt).
59 |
60 |
61 |
--------------------------------------------------------------------------------
/docs/source/guide/user.rst:
--------------------------------------------------------------------------------
1 | Developer Guide For Users
2 | ----------------------------
3 |
4 | How to Use GRIN
5 | ================
6 |
7 | To use GRIN within a graph computing system, follow these recommended steps:
8 |
9 | 1. Start by adding GRIN as a submodule to the repository of the graph
10 | computing system.
11 | 2. Ensure that the storage system is installed locally and that it implements
12 | the same version of GRIN that you intend to use.
13 | 3. If you are programming in C++, include the necessary header files for the
14 | GRIN APIs in your program. If you are programming in Rust, import the GRIN
15 | APIs using the auto-generated ``Rust-FFI`` files found in the ``rust`` folder.
16 | 4. Link the GRIN library of the storage system to your program.
17 | 5. (Optional) If applicable, load a sample graph into the storage system and run
18 | the ctest for GRIN to verify its functionality.
19 | 6. Confirm that the graph has been successfully loaded into the storage system
20 | and make a note of its ``URI``.
21 | 7. Build your program and run it, specifying the ``URI`` of the graph to be used.
22 |
23 |
24 | API Naming Rules
25 | =================
26 |
27 | GRIN APIs are defined in C and thus their names can be complex.
28 | We provide the following naming rules to help users understand how the APIs are named,
29 | so that they will not be confused when programming with GRIN APIs.
30 |
31 | Get A From B
32 | ^^^^^^^^^^^^^^
33 | The most common API pattern in GRIN is ``get_A_from_B``.
34 | The word **from** indicates that A is within B, or A is a part of B.
35 | For example, ``grin_get_graph_from_storage``, ``grin_get_src_vertex_from_edge``,
36 | ``grin_get_int32_from_row``, and ``grin_get_neighbor_from_adjacent_list``.
37 |
38 | When B is an A list, we use ``get_A_from_list`` for short.
39 | For example, ``grin_get_vertex_from_list``, ``grin_get_edge_property_from_list``.
40 |
41 | When B is an A iterator, we also use ``get_A_from_iter`` for short.
42 | For example, ``grin_get_vertex_from_iter``.
43 | But ``grin_get_neighbor_from_adjacent_list_iter`` has no short name, because B
44 | is an adjacent list iterator, while ``neighbor`` is a vertex.
45 |
46 | We also use ``from`` in converting references to handles.
47 | For example, ``grin_get_vertex_from_vertex_ref``.
48 | We don't use ``by`` here because in general the vertex reference contains more information
49 | than the vertex, so we consider the vertex as "a part of" the vertex reference.
50 |
51 | Get B A
52 | ^^^^^^^^^
53 | This pattern is also used when A is a part of B, when A is not a handle, but ``size``,
54 | ``name``, etc.
55 | For example, ``grin_get_vertex_list_size``, ``grin_get_vertex_property_name``.
56 |
57 |
58 | Get A by B
59 | ^^^^^^^^^^^^
60 | This pattern is used when B is like a key for A.
61 | For example, ``grin_get_vertex_by_external_id_of_int64``, ``grin_get_vertex_list_by_label``,
62 | ``grin_get_vertex_by_primary_keys_row``, ``grin_get_local_graph_by_partition``,
63 | ``grin_get_vertex_property_list_by_type`` and ``grin_get_edge_type_by_id``.
64 |
65 | We also use ``by`` in converting handles to references.
66 | For example, ``grin_get_vertex_ref_by_vertex``.
67 |
68 | Get A of B
69 | ^^^^^^^^^^^^
70 | This pattern is used when B is a data type.
71 | For example, ``grin_get_vertex_property_value_of_uint32``.
72 |
73 | Get A
74 | ^^^^^^
75 | This pattern is mainly used when A is a statistic.
76 | For example, ``grin_get_vertex_num``.
77 |
78 | Destroy A
79 | ^^^^^^^^^^
80 | This pattern is used when destroy a handle.
81 | For example, ``grin_destroy_graph``, ``grin_destroy_vertex_list``.
82 | Return values like string or float array should also be destroyed,
83 | we use ``of`` to indicate the type.
84 | For example, ``grin_destroy_vertex_property_value_of_string``.
85 |
86 | Is C
87 | ^^^^^^
88 | This pattern is used when C is a condition.
89 | For example, ``grin_is_directed`` and ``grin_is_vertex_list_end``.
90 |
91 | Equal A
92 | ^^^^^^^^
93 | This pattern is used when comparing two handles of type A.
94 | For example, ``grin_equal_vertex``.
--------------------------------------------------------------------------------
/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | .. GRIN documentation master file, created by
2 | sphinx-quickstart on Thu May 11 17:08:47 2023.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to GRIN's documentation!
7 | ================================
8 |
9 | .. \outline{GRIN stands for the Graph Retrieval INterface in GraphScope||1}
10 | .. \outline{GRIN offers graph computing engines in GraphScope a unique way to retrieve graph data stored in different storage systems in GraphScope||1}
11 | .. \outline{To achieve the goal, GRIN abstracts the common graph retrieval requirements in graph computing systems into categories, such as topology, property, partition, index, etc.||1}
12 | .. \outline{GRIN also abstracts the compute-specific graph retrieval requirements into traits, such as traversal, filter, partition strategy, external/internal ids, etc.||1}
13 | .. \outline{GRIN offers APIs for the above abstracted requirements, and organize them with a series of C macros.||1}
14 | .. \outline{Each graph storage system that supports GRIN can filter out the APIs that it cannot support using the C macros.||1}
15 | .. \outline{Then for the rest APIs that the storage can support, it should implement the APIs efficiently, and avoid hidden overheads, so that the computing systems can these APIs without worring about the performance.||2}
16 | .. introduction
17 |
18 | GRIN, which stands for Graph Retrieval INterface, is an interface designed to simplify the retrieval of graph data
19 | from various storage systems within GraphScope.
20 | It organizes **common** graph retrieval needs into
21 | categories such as topology, property, partition, and index,
22 | as well as **compute-specific** graph
23 | retrieval requirements as traits including traversal, filter, partition strategy,
24 | external/internal ids, etc.
25 |
26 | GRIN offers APIs to fulfill these abstracted requirements.
27 | These APIs are defined in C and can be utilized in systems developed in various programming languages such as C++, Rust, and Java.
28 | GRIN organizes its APIs using categorized header files.
29 | Additionally, C macros are utilized by GRIN to allow storage systems that support GRIN
30 | to filter out APIs that they are unable to handle.
31 | This ensures compatibility while maximizing efficiency.
32 | The supported APIs are then implemented in the storage systems to prioritize efficient retrieval with minimal hidden overhead.
33 | By using GRIN, computing systems can utilize the supported APIs without worrying about performance concerns.
34 |
35 | The documentation is organized as follows:
36 |
37 | First, we introduce the basic concepts of GRIN, including the handle, API, and macros.
38 |
39 | Next, we dive into the details of each API category, starting with the ``topology`` APIs.
40 | We then introduce the Labeled Property Graph (LPG) data model along with the ``property`` APIs.
41 | Within the LPG data model, we also address the additional ``topology``-related APIs that handle the transition from a simple graph to a LPG.
42 | After that, we introduce the ``partition`` APIs, which are designed for partitioned graphs.
43 | Since graph partitioning is another layer on top of simple graphs and LPGs, we also provide additional ``topology`` and ``property``-related APIs for this purpose.
44 | This three-level "stacking" of ``topology``, ``property``, and ``partition`` forms the fundamental organization of GRIN APIs.
45 |
46 | Next, we introduce the ``index`` APIs, which are designed for graph indexing.
47 | Following that, we present the ``common`` APIs, which include the common functions of GRIN, such as *schema* message and *error code*.
48 | Finally, we end the per-category API introduction by presenting the ``extension`` APIs, which are a series of advanced APIs with default implementations that utilize the basic APIs of GRIN.
49 |
50 | Lastly, we provide the developer guide of GRIN for developers to follow.
51 |
52 | .. toctree::
53 | :maxdepth: 2
54 | :caption: Contents:
55 | :glob:
56 |
57 | get_started
58 | api/1.topology_api
59 | api/2.property_api
60 | api/3.partition_api
61 | api/4.index_api
62 | api/5.common_api
63 | api/6.extension_api
64 | guide/storage
65 | guide/user
66 |
67 | .. getting_started
68 |
69 | .. apis
70 | .. graph topology & apis
71 | .. LPG data model & apis
72 | .. graph partition strategy & partition apis
73 | .. graph index & apis
74 | .. common functions & apis
75 | .. grin extension & apis
76 |
77 | .. developer_guide
78 | .. for graph storage system developer
79 | .. add submodule
80 | .. implement principles
81 | .. for graph computing engine developer
82 | .. v6d cmake example
83 | .. api naming
84 |
85 |
86 |
87 |
88 | .. **GRIN** is a proposed standard graph retrieval interface in GraphScope.
89 | .. The goal of GRIN is to provide a common way for the graph computing engines to
90 | .. retrieve graph data stored in different storage systems in GraphScope,
91 | .. and to simplify the integration of these engines with each other.
92 |
93 | .. GRIN is defined in C, which makes it portable to systems written in different
94 | .. programming languages, such as C++, Rust and Java.
95 | .. It provides a set of common operations and data structure handles that can
96 | .. be used to access graph data, regardless of the underlying storage system.
97 |
98 | .. These operations include:
99 |
100 | .. - *Traversal*: navigating the graph structure to explore relationships between vertices
101 | .. - *Retrieval*: retrieving the data and properties of vertices and edges
102 | .. - *Filter*: filtering data structures with partitioning or property conditions
103 |
104 | .. GRIN is designed to be read-only, meaning that it does not provide operations for
105 | .. modifying the graph data. This decision was made to simplify the implementation
106 | .. of GRIN and ensure that it can be used safely with any storage system.
107 |
108 |
109 | .. 0.get_started
110 | .. 1.return_value
111 | .. 2.api_naming
112 | .. 4.partition_api
113 | .. 6.index_api
114 | .. 7.extension
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/extension/handle.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | /**
17 | * @file extension/predefine.h
18 | * @brief Pre-defined macros, handles and null values for
19 | * GRIN extensions.
20 | */
21 |
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | #ifndef GRIN_EXTENSION_HANDLE_H_
27 | #define GRIN_EXTENSION_HANDLE_H_
28 |
29 | #if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY)
30 | typedef struct GRIN_VERTEX_LIST_CHAIN {
31 | GRIN_VERTEX_LIST* lists;
32 | unsigned int size;
33 | } GRIN_VERTEX_LIST_CHAIN;
34 |
35 | typedef struct GRIN_VERTEX_LIST_CHAIN_ITERATOR_T {
36 | GRIN_VERTEX_LIST_ITERATOR* iterators;
37 | unsigned int size;
38 | unsigned int current;
39 | } GRIN_VERTEX_LIST_CHAIN_ITERATOR_T;
40 |
41 | typedef void* GRIN_VERTEX_LIST_CHAIN_ITERATOR;
42 | #endif
43 |
44 | #if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY)
45 | typedef void* GRIN_EDGE_LIST_CHAIN;
46 |
47 | typedef void* GRIN_EDGE_LIST_CHAIN_ITERATOR;
48 | #endif
49 |
50 | #if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_WITH_EDGE_PROPERTY)
51 | typedef struct GRIN_ADJACENT_LIST_CHAIN {
52 | GRIN_ADJACENT_LIST* lists;
53 | unsigned int size;
54 | } GRIN_ADJACENT_LIST_CHAIN;
55 |
56 | typedef struct GRIN_ADJACENT_LIST_CHAIN_ITERATOR_T {
57 | GRIN_ADJACENT_LIST_ITERATOR* iterators;
58 | unsigned int size;
59 | unsigned int current;
60 | } GRIN_ADJACENT_LIST_CHAIN_ITERATOR_T;
61 |
62 | typedef void* GRIN_ADJACENT_LIST_CHAIN_ITERATOR;
63 | #endif
64 |
65 | #if defined (GRIN_ENABLE_ADJACENT_LIST_ITERATOR) && !defined(GRIN_ENABLE_ADJACENT_LIST_ARRAY)
66 | typedef void* GRIN_INDEXED_ADJACENT_LIST;
67 | #endif
68 |
69 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY
70 | typedef GRIN_ADJACENT_LIST GRIN_INDEXED_ADJACENT_LIST;
71 | #define GRIN_NULL_INDEXED_ADJACENT_LIST GRIN_NULL_ADJACENT_LIST
72 | #endif
73 |
74 | #endif // GRIN_EXTENSION_HANDLE_H_
75 |
76 | #ifdef __cplusplus
77 | }
78 | #endif
--------------------------------------------------------------------------------
/extension/include/indexed_adjacent_list.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | #ifdef __cplusplus
17 | extern "C" {
18 | #endif
19 |
20 | #ifndef GRIN_EXTENSION_INCLUDE_INDEXED_ADJACENT_LIST_H_
21 | #define GRIN_EXTENSION_INCLUDE_INDEXED_ADJACENT_LIST_H_
22 |
23 | #include "../handle.h"
24 |
25 | GRIN_INDEXED_ADJACENT_LIST grin_get_indexed_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST);
26 |
27 | void grin_destroy_indexed_adjacent_list(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST);
28 |
29 | size_t grin_get_indexed_adjacent_list_size(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST);
30 |
31 | GRIN_VERTEX grin_get_neighbor_from_indexed_adjacent_list(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST, size_t);
32 |
33 | GRIN_EDGE grin_get_edge_from_indexed_adjacent_list(GRIN_GRAPH, GRIN_INDEXED_ADJACENT_LIST, size_t);
34 |
35 |
36 | #endif // GRIN_EXTENSION_INCLUDE_INDEXED_ADJACENT_LIST_H_
37 |
38 | #ifdef __cplusplus
39 | }
40 | #endif
--------------------------------------------------------------------------------
/extension/include/list_chain.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | #ifdef __cplusplus
17 | extern "C" {
18 | #endif
19 |
20 | #ifndef GRIN_EXTENSION_INCLUDE_LIST_CHAIN_H_
21 | #define GRIN_EXTENSION_INCLUDE_LIST_CHAIN_H_
22 |
23 | #include "common/enum_types.h"
24 | #include "../handle.h"
25 |
26 | #if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_ENABLE_SCHEMA)
27 | GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types(GRIN_GRAPH);
28 |
29 | void grin_destroy_vertex_list_chain(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN);
30 |
31 | GRIN_VERTEX_LIST_CHAIN_ITERATOR grin_get_vertex_list_chain_begin(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN);
32 |
33 | void grin_destroy_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
34 |
35 | void grin_get_next_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
36 |
37 | bool grin_is_vertex_list_chain_end(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
38 |
39 | GRIN_VERTEX grin_get_vertex_from_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR);
40 | #endif
41 |
42 | #if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST)
43 | GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_master(GRIN_GRAPH);
44 |
45 | GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_mirror(GRIN_GRAPH);
46 | #endif
47 |
48 | #if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_ENABLE_SCHEMA)
49 | GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types(GRIN_GRAPH);
50 |
51 | void grin_destroy_edge_list_chain(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN);
52 |
53 | GRIN_EDGE_LIST_CHAIN_ITERATOR grin_get_edge_list_chain_begin(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN);
54 |
55 | void grin_destroy_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR);
56 |
57 | void grin_get_next_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR);
58 |
59 | bool grin_is_edge_list_chain_end(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR);
60 |
61 | GRIN_EDGE grin_get_edge_from_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR);
62 | #endif
63 |
64 | #if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST)
65 | GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types_select_master(GRIN_GRAPH);
66 |
67 | GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types_select_mirror(GRIN_GRAPH);
68 | #endif
69 |
70 | #if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_ENABLE_SCHEMA)
71 | GRIN_ADJACENT_LIST_CHAIN grin_get_adjacent_list_chain_of_all_edge_types(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
72 |
73 | void grin_destroy_adjacent_list_chain(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN);
74 |
75 | GRIN_ADJACENT_LIST_CHAIN_ITERATOR grin_get_adjacent_list_chain_begin(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN);
76 |
77 | void grin_destroy_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR);
78 |
79 | void grin_get_next_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR);
80 |
81 | bool grin_is_adjacent_list_chain_end(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR);
82 |
83 | GRIN_EDGE grin_get_edge_from_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR);
84 |
85 | GRIN_VERTEX grin_get_neighbor_from_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR);
86 | #endif
87 |
88 | #endif // GRIN_EXTENSION_INCLUDE_LIST_CHAIN_H_
89 |
90 | #ifdef __cplusplus
91 | }
92 | #endif
--------------------------------------------------------------------------------
/extension/include/static_message.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | #ifdef __cplusplus
17 | extern "C" {
18 | #endif
19 |
20 | #ifndef GRIN_EXTENSION_INCLUDE_STATIC_MESSAGE_H_
21 | #define GRIN_EXTENSION_INCLUDE_STATIC_MESSAGE_H_
22 |
23 | #include "../handle.h"
24 |
25 | void grin_destroy_static_storage_feature_msg(const char* msg);
26 |
27 | const char* grin_get_static_storage_feature_msg();
28 |
29 | #endif // GRIN_EXTENSION_INCLUDE_STATIC_MESSAGE_H_
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
--------------------------------------------------------------------------------
/extension/src/indexed_adjacent_list.cc:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 | #include
16 | #include "predefine.h"
17 |
18 | #include "indexed_adjacent_list.h"
19 | #include "property/type.h"
20 | #include "property/topology.h"
21 | #include "topology/adjacentlist.h"
22 | #include "topology/structure.h"
23 | #include "index/internal_id.h"
24 |
25 | #if defined (GRIN_ENABLE_ADJACENT_LIST_ITERATOR) && !defined(GRIN_ENABLE_ADJACENT_LIST_ARRAY)
26 | typedef struct GRIN_INDEXED_ADJACENT_LIST_T {
27 | GRIN_ADJACENT_LIST_ITERATOR iterator;
28 | std::vector neighbors;
29 | std::vector edges;
30 | bool cache_built;
31 | } GRIN_INDEXED_ADJACENT_LIST_T;
32 |
33 | void _prepare_cache_for_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list) {
34 | auto _indexed_adj_list = static_cast(indexed_adj_list);
35 | while (!grin_is_adjacent_list_end(g, _indexed_adj_list->iterator)) {
36 | auto dst_vertex = grin_get_neighbor_from_adjacent_list_iter(g, _indexed_adj_list->iterator);
37 | _indexed_adj_list->neighbors.push_back(dst_vertex);
38 | auto edge = grin_get_edge_from_adjacent_list_iter(g, _indexed_adj_list->iterator);
39 | _indexed_adj_list->edges.push_back(edge);
40 | grin_get_next_adjacent_list_iter(g, _indexed_adj_list->iterator);
41 | }
42 | }
43 |
44 | GRIN_INDEXED_ADJACENT_LIST grin_get_indexed_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) {
45 | GRIN_INDEXED_ADJACENT_LIST_T* indexed_adj_list = new GRIN_INDEXED_ADJACENT_LIST_T();
46 | indexed_adj_list->iterator = grin_get_adjacent_list_begin(g, adj_list);
47 | indexed_adj_list->neighbors.clear();
48 | indexed_adj_list->edges.clear();
49 | indexed_adj_list->cache_built = false;
50 | return indexed_adj_list;
51 | }
52 |
53 | void grin_destroy_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list) {
54 | auto _indexed_adj_list = static_cast(indexed_adj_list);
55 | grin_destroy_adjacent_list_iter(g, _indexed_adj_list->iterator);
56 | for (auto idx = 0; idx < _indexed_adj_list->neighbors.size(); idx++) {
57 | grin_destroy_vertex(g, _indexed_adj_list->neighbors[idx]);
58 | grin_destroy_edge(g, _indexed_adj_list->edges[idx]);
59 | }
60 | _indexed_adj_list->neighbors.clear();
61 | _indexed_adj_list->edges.clear();
62 | delete _indexed_adj_list;
63 | }
64 |
65 | size_t grin_get_indexed_adjacent_list_size(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list) {
66 | auto _indexed_adj_list = static_cast(indexed_adj_list);
67 | if (_indexed_adj_list->cache_built) {
68 | return _indexed_adj_list->neighbors.size();
69 | }
70 | _prepare_cache_for_indexed_adjacent_list(g, indexed_adj_list);
71 | _indexed_adj_list->cache_built = true;
72 | return _indexed_adj_list->neighbors.size();
73 | }
74 |
75 | GRIN_VERTEX grin_get_neighbor_from_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list, size_t index) {
76 | auto _indexed_adj_list = static_cast(indexed_adj_list);
77 | if (_indexed_adj_list->cache_built) {
78 | if (index >= _indexed_adj_list->neighbors.size()) {
79 | return GRIN_NULL_VERTEX;
80 | }
81 | return _indexed_adj_list->neighbors[index];
82 | }
83 | _prepare_cache_for_indexed_adjacent_list(g, indexed_adj_list);
84 | _indexed_adj_list->cache_built = true;
85 | if (index >= _indexed_adj_list->neighbors.size()) {
86 | return GRIN_NULL_VERTEX;
87 | }
88 | return _indexed_adj_list->neighbors[index];
89 | }
90 |
91 | GRIN_EDGE grin_get_edge_from_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list, size_t index) {
92 | auto _indexed_adj_list = static_cast(indexed_adj_list);
93 | if (_indexed_adj_list->cache_built) {
94 | if (index >= _indexed_adj_list->edges.size()) {
95 | return GRIN_NULL_EDGE;
96 | }
97 | return _indexed_adj_list->edges[index];
98 | }
99 | _indexed_adj_list->cache_built = true;
100 | _prepare_cache_for_indexed_adjacent_list(g, indexed_adj_list);
101 | if (index >= _indexed_adj_list->edges.size()) {
102 | return GRIN_NULL_EDGE;
103 | }
104 | return _indexed_adj_list->edges[index];
105 | }
106 |
107 | #endif
108 |
109 |
110 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY
111 | GRIN_INDEXED_ADJACENT_LIST grin_get_indexed_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) {
112 | return adj_list;
113 | }
114 |
115 | void grin_destroy_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list) {
116 | grin_destroy_adjacent_list(g, indexed_adj_list);
117 | }
118 |
119 | size_t grin_get_indexed_adjacent_list_size(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list) {
120 | return grin_get_adjacent_list_size(g, indexed_adj_list);
121 | }
122 |
123 | GRIN_VERTEX grin_get_neighbor_from_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list, size_t index) {
124 | return grin_get_neighbor_from_adjacent_list(g, indexed_adj_list, index);
125 | }
126 |
127 | GRIN_EDGE grin_get_edge_from_indexed_adjacent_list(GRIN_GRAPH g, GRIN_INDEXED_ADJACENT_LIST indexed_adj_list, size_t index) {
128 | return grin_get_edge_from_adjacent_list(g, indexed_adj_list, index);
129 | }
130 | #endif
131 |
--------------------------------------------------------------------------------
/include/common/enum_types.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file error.h
17 | @brief Define the error code related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_ENUM_TYPES_H_
25 | #define GRIN_INCLUDE_ENUM_TYPES_H_
26 |
27 | /* Enumerate types of GRIN */
28 | /// Enumerates the directions of edges with respect to a certain vertex
29 | typedef enum {
30 | IN = 0, ///< incoming
31 | OUT = 1, ///< outgoing
32 | BOTH = 2, ///< incoming & outgoing
33 | } GRIN_DIRECTION;
34 |
35 | /// Enumerates the datatype supported in the storage
36 | typedef enum {
37 | Undefined = 0, ///< other unknown types
38 | Int32 = 1, ///< int
39 | UInt32 = 2, ///< unsigned int
40 | Int64 = 3, ///< long int
41 | UInt64 = 4, ///< unsigned long int
42 | Float = 5, ///< float
43 | Double = 6, ///< double
44 | String = 7, ///< string
45 | Date32 = 8, ///< date
46 | Time32 = 9, ///< Time32
47 | Timestamp64 = 10, ///< Timestamp
48 | #ifdef GRIN_TRAIT_PROPERTY_VALUE_OF_FLOAT_ARRAY
49 | FloatArray = 11, ///< float array
50 | #endif
51 | } GRIN_DATATYPE;
52 |
53 | /// Enumerates the error codes of grin
54 | typedef enum {
55 | NO_ERROR = 0, ///< success
56 | UNKNOWN_ERROR = 1, ///< unknown error
57 | INVALID_VALUE = 2, ///< invalid value
58 | UNKNOWN_DATATYPE = 3, ///< unknown datatype
59 | NULL_VALUE = 4, ///< null value
60 | } GRIN_ERROR_CODE;
61 |
62 | #endif // GRIN_INCLUDE_ENUM_TYPES_H_
63 |
64 | #ifdef __cplusplus
65 | }
66 | #endif
--------------------------------------------------------------------------------
/include/common/error.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file error.h
17 | @brief Define the error code related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_COMMON_ERROR_H_
25 | #define GRIN_INCLUDE_COMMON_ERROR_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | extern __thread GRIN_ERROR_CODE grin_error_code;
30 |
31 | /**
32 | * @brief Get the last error code.
33 | * The error code is thread local.
34 | * Currently users only need to check the error code when using
35 | * getting-value APIs whose return has no predefined invalid value.
36 | */
37 | GRIN_ERROR_CODE grin_get_last_error_code();
38 |
39 | #endif // GRIN_INCLUDE_COMMON_ERROR_H_
40 |
41 | #ifdef __cplusplus
42 | }
43 | #endif
--------------------------------------------------------------------------------
/include/common/message.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file message.h
17 | @brief Define storage feature protobuf message
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_COMMON_MESSAGE_H_
25 | #define GRIN_INCLUDE_COMMON_MESSAGE_H_
26 |
27 | #ifdef GRIN_ENABLE_SCHEMA
28 | void grin_destroy_graph_schema_msg(const char* msg);
29 |
30 | const char* grin_get_graph_schema_msg(const char* uri);
31 | #endif
32 |
33 | #endif // GRIN_INCLUDE_PROTO_MESSAGE_H_
34 |
35 | #ifdef __cplusplus
36 | }
37 | #endif
--------------------------------------------------------------------------------
/include/index/external_id.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file external_id.h
17 | @brief Define the external ID related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_INDEX_EXTERNAL_ID_H_
25 | #define GRIN_INCLUDE_INDEX_EXTERNAL_ID_H_
26 |
27 | #ifdef GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_INT64
28 | /**
29 | * @brief Get the vertex by external id of int64.
30 | * @param GRIN_GRAPH The graph
31 | * @param id The external id of int64
32 | * @return The vertex
33 | */
34 | GRIN_VERTEX grin_get_vertex_by_external_id_of_int64(GRIN_GRAPH, long long int id);
35 |
36 | /**
37 | * @brief Get the external id of int64 of a vertex
38 | * @param GRIN_GRAPH The graph
39 | * @param GRIN_VERTEX The vertex
40 | * @return The external id of int64 of the vertex
41 | */
42 | long long int grin_get_vertex_external_id_of_int64(GRIN_GRAPH, GRIN_VERTEX);
43 | #endif
44 |
45 | #ifdef GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_STRING
46 | void grin_destroy_vertex_external_id_of_string(GRIN_GRAPH, const char*);
47 |
48 | /**
49 | * @brief Get the vertex by external id of string.
50 | * @param GRIN_GRAPH The graph
51 | * @param id The external id of string
52 | * @return The vertex
53 | */
54 | GRIN_VERTEX grin_get_vertex_by_external_id_of_string(GRIN_GRAPH, const char* id);
55 |
56 | /**
57 | * @brief Get the external id of string of a vertex
58 | * @param GRIN_GRAPH The graph
59 | * @param GRIN_VERTEX The vertex
60 | * @return The external id of string of the vertex
61 | */
62 | const char* grin_get_vertex_external_id_of_string(GRIN_GRAPH, GRIN_VERTEX);
63 | #endif
64 |
65 | #endif // GRIN_INCLUDE_INDEX_EXTERNAL_ID_H_
66 |
67 | #ifdef __cplusplus
68 | }
69 | #endif
--------------------------------------------------------------------------------
/include/index/internal_id.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file internal_id.h
17 | @brief Define the internal ID related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_INDEX_INTERNAL_ID_H_
25 | #define GRIN_INCLUDE_INDEX_INTERNAL_ID_H_
26 |
27 | #if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && !defined(GRIN_ENABLE_SCHEMA)
28 | /**
29 | * @brief Get the int64 internal id of a vertex
30 | * @param GRIN_GRAPH The graph
31 | * @param GRIN_VERTEX The vertex
32 | * @return The int64 internal id of the vertex
33 | */
34 | long long int grin_get_vertex_internal_id(GRIN_GRAPH, GRIN_VERTEX);
35 |
36 | /**
37 | * @brief Get the vertex by internal id.
38 | * Different from pk_of_int64, the internal id is unique over all vertex types.
39 | * @param GRIN_GRAPH The graph
40 | * @param id The internal id of the vertex
41 | * @return The vertex
42 | */
43 | GRIN_VERTEX grin_get_vertex_by_internal_id(GRIN_GRAPH, long long int id);
44 |
45 | /**
46 | * @brief Get the upper bound of internal id.
47 | * @param GRIN_GRAPH The graph
48 | * @return The upper bound
49 | */
50 | long long int grin_get_vertex_internal_id_upper_bound(GRIN_GRAPH);
51 |
52 | /**
53 | * @brief Get the lower bound of internal id.
54 | * @param GRIN_GRAPH The graph
55 | * @return The lower bound
56 | */
57 | long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH);
58 | #endif
59 |
60 | #if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && defined(GRIN_ENABLE_SCHEMA)
61 | /**
62 | * @brief Get the int64 internal id of a vertex of a type
63 | * @param GRIN_GRAPH The graph
64 | * @param GRIN_VERTEX_TYPE The vertex type
65 | * @param GRIN_VERTEX The vertex
66 | * @return The int64 internal id of the vertex
67 | */
68 | long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX);
69 |
70 | /**
71 | * @brief Get the vertex by internal id under type
72 | * @param GRIN_GRAPH The graph
73 | * @param GRIN_VERTEX_TYPE The vertex type
74 | * @param id The internal id of the vertex under type
75 | * @return The vertex
76 | */
77 | GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, long long int id);
78 |
79 | /**
80 | * @brief Get the upper bound of internal id under type.
81 | * @param GRIN_GRAPH The graph
82 | * @param GRIN_VERTEX_TYPE The vertex type
83 | * @return The upper bound of internal id under type
84 | */
85 | long long int grin_get_vertex_internal_id_upper_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
86 |
87 | /**
88 | * @brief Get the lower bound internal id under type.
89 | * @param GRIN_GRAPH The graph
90 | * @param GRIN_VERTEX_TYPE The vertex type
91 | * @return The lower bound internal id under type
92 | */
93 | long long int grin_get_vertex_internal_id_lower_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
94 | #endif
95 |
96 | #endif // GRIN_INCLUDE_INDEX_INTERNAL_ID_H_
97 |
98 | #ifdef __cplusplus
99 | }
100 | #endif
--------------------------------------------------------------------------------
/include/index/label.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file label.h
17 | @brief Define the label related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_INDEX_LABEL_H_
25 | #define GRIN_INCLUDE_INDEX_LABEL_H_
26 |
27 | #ifdef GRIN_WITH_VERTEX_LABEL
28 | /**
29 | * @brief get the label list for vertices in the graph
30 | * @param GRIN_GRAPH the graph
31 | * @return the label list for vertices
32 | */
33 | GRIN_LABEL_LIST grin_get_vertex_label_list(GRIN_GRAPH);
34 | #endif
35 |
36 | #if defined(GRIN_WITH_VERTEX_LABEL) && !defined(GRIN_ENABLE_SCHEMA)
37 | /**
38 | * @brief get the vertex list by label
39 | * @param GRIN_GRAPH the graph
40 | * @param GRIN_LABEL the label
41 | * @return the vertex list
42 | */
43 | GRIN_VERTEX_LIST grin_get_vertex_list_by_label(GRIN_GRAPH, GRIN_LABEL);
44 | #endif
45 |
46 | #if defined(GRIN_WITH_VERTEX_LABEL) && defined(GRIN_ENABLE_SCHEMA)
47 | /**
48 | * @brief get the vertex list by type and label
49 | * @param GRIN_GRAPH the graph
50 | * @param GRIN_VERTEX_TYPE the vertex type
51 | * @param GRIN_LABEL the label
52 | * @return the vertex list
53 | */
54 | GRIN_VERTEX_LIST grin_get_vertex_list_by_type_by_label(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_LABEL);
55 | #endif
56 |
57 |
58 | #ifdef GRIN_WITH_EDGE_LABEL
59 | /**
60 | * @brief get the label list for edges in the graph
61 | * @param GRIN_GRAPH the graph
62 | * @return the label list for edges
63 | */
64 | GRIN_LABEL_LIST grin_get_edge_label_list(GRIN_GRAPH);
65 | #endif
66 |
67 | #if defined(GRIN_WITH_EDGE_LABEL) && !defined(GRIN_ENABLE_SCHEMA)
68 | /**
69 | * @brief get the edge list by label
70 | * @param GRIN_GRAPH the graph
71 | * @param GRIN_LABEL the label
72 | * @return the edge list
73 | */
74 | GRIN_EDGE_LIST grin_get_edge_list_by_label(GRIN_GRAPH, GRIN_LABEL);
75 | #endif
76 |
77 | #if defined(GRIN_WITH_EDGE_LABEL) && defined(GRIN_ENABLE_SCHEMA)
78 | /**
79 | * @brief get the edge list by type and label
80 | * @param GRIN_GRAPH the graph
81 | * @param GRIN_EDGE_TYPE the edge type
82 | * @param GRIN_LABEL the label
83 | * @return the edge list
84 | */
85 | GRIN_EDGE_LIST grin_get_edge_list_by_type_by_label(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_LABEL);
86 | #endif
87 |
88 | #endif // GRIN_INCLUDE_INDEX_LABEL_H_
89 |
90 | #ifdef __cplusplus
91 | }
92 | #endif
--------------------------------------------------------------------------------
/include/index/order.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file order.h
17 | @brief Define the vertex ordering predicate APIs, this header file will be deprecated in the future
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_INDEX_ORDER_H_
25 | #define GRIN_INCLUDE_INDEX_ORDER_H_
26 |
27 | #ifdef GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
28 | bool grin_smaller_vertex(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX);
29 | #endif
30 |
31 | #if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY)
32 | /**
33 | * @brief Get the position of a vertex in a sorted list
34 | * caller must guarantee the input vertex list is sorted to get the correct result
35 | * @param GRIN_GRAPH The graph
36 | * @param GRIN_VERTEX_LIST The sorted vertex list
37 | * @param GRIN_VERTEX The vertex to find
38 | * @return The position of the vertex
39 | */
40 | size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH, GRIN_VERTEX_LIST, GRIN_VERTEX);
41 | #endif
42 |
43 | #endif // GRIN_INCLUDE_INDEX_ORDER_H_
44 |
45 | #ifdef __cplusplus
46 | }
47 | #endif
--------------------------------------------------------------------------------
/include/index/pk.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file pk.h
17 | @brief Define the primary key indexing related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_INDEX_PK_H_
25 | #define GRIN_INCLUDE_INDEX_PK_H_
26 |
27 | #if defined(GRIN_ENABLE_VERTEX_PK_INDEX) && defined(GRIN_ENABLE_VERTEX_PRIMARY_KEYS)
28 | /**
29 | * @brief Get the vertex by primary keys row.
30 | * The values in the row must be in the same order as the primary keys
31 | * properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``.
32 | * @param GRIN_GRAPH The graph.
33 | * @param GRIN_VERTEX_TYPE The vertex type.
34 | * @param GRIN_ROW The values row of primary keys properties.
35 | * @return The vertex.
36 | */
37 | GRIN_VERTEX grin_get_vertex_by_primary_keys_row(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_ROW);
38 | #endif
39 |
40 | #if defined(GRIN_ENABLE_EDGE_PK_INDEX) && defined(GRIN_ENABLE_EDGE_PRIMARY_KEYS)
41 | GRIN_EDGE grin_get_edge_by_primary_keys_row(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_ROW);
42 | #endif
43 |
44 | #endif // GRIN_INCLUDE_INDEX_PK_H_
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
--------------------------------------------------------------------------------
/include/partition/partition.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file partition.h
17 | @brief Define the partition related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PARTITION_PARTITION_H_
25 | #define GRIN_INCLUDE_PARTITION_PARTITION_H_
26 |
27 | #ifdef GRIN_ENABLE_GRAPH_PARTITION
28 | /**
29 | * @brief Get a partitioned graph from a storage.
30 | * @param uri The URI of the graph.
31 | * Current URI for supported storage includes:
32 | * 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}
33 | * 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}
34 | * 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.
35 | * @return A partitioned graph handle.
36 | */
37 | GRIN_PARTITIONED_GRAPH grin_get_partitioned_graph_from_storage(const char* uri);
38 |
39 | void grin_destroy_partitioned_graph(GRIN_PARTITIONED_GRAPH);
40 |
41 | size_t grin_get_total_partitions_number(GRIN_PARTITIONED_GRAPH);
42 |
43 | /**
44 | * @brief Get the local partition list of the partitioned graph.
45 | * For example, a graph may be partitioned into 6 partitions and located in
46 | * 2 machines, then each machine may contain a local partition list of size 3.
47 | * @param GRIN_PARTITIONED_GRAPH The partitioned graph.
48 | * @return A partition list of local partitions.
49 | */
50 | GRIN_PARTITION_LIST grin_get_local_partition_list(GRIN_PARTITIONED_GRAPH);
51 |
52 | void grin_destroy_partition_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST);
53 |
54 | GRIN_PARTITION_LIST grin_create_partition_list(GRIN_PARTITIONED_GRAPH);
55 |
56 | bool grin_insert_partition_to_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST, GRIN_PARTITION);
57 |
58 | size_t grin_get_partition_list_size(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST);
59 |
60 | GRIN_PARTITION grin_get_partition_from_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST, size_t);
61 |
62 | bool grin_equal_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION, GRIN_PARTITION);
63 |
64 | void grin_destroy_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION);
65 |
66 | /**
67 | * @brief Get the partition info of a partition.
68 | * This api will be deprecated in the future.
69 | * @param GRIN_PARTITIONED_GRAPH The partitioned graph.
70 | * @param GRIN_PARTITION The partition of the graph.
71 | * @return The partition info.
72 | */
73 | const void* grin_get_partition_info(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION);
74 |
75 | /**
76 | * @brief Get a local graph of the partitioned graph.
77 | * @param GRIN_PARTITIONED_GRAPH The partitioned graph.
78 | * @param GRIN_PARTITION The partition of the graph.
79 | * @return A local graph.
80 | */
81 | GRIN_GRAPH grin_get_local_graph_by_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION);
82 | #endif
83 |
84 | #ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
85 | GRIN_PARTITION grin_get_partition_by_id(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_ID);
86 |
87 | GRIN_PARTITION_ID grin_get_partition_id(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION);
88 | #endif
89 |
90 | #endif // GRIN_INCLUDE_PARTITION_PARTITION_H_
91 |
92 | #ifdef __cplusplus
93 | }
94 | #endif
95 |
--------------------------------------------------------------------------------
/include/partition/reference.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file reference.h
17 | @brief Define the reference related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PARTITION_REFERENCE_H_
25 | #define GRIN_INCLUDE_PARTITION_REFERENCE_H_
26 |
27 | #ifdef GRIN_ENABLE_VERTEX_REF
28 | /**
29 | * @brief Get the vertex ref of a vertex.
30 | * A vertex ref is a reference for a "local" vertex, and the reference can
31 | * be recognized by other partitions.
32 | * To transfer the vertex ref handle between partitions, users should
33 | * first call serialization methods to serialize the vertex ref handle
34 | * into string or int64 based on the storage's features;
35 | * then send the messages to remote partitions and deserialize the string or
36 | * int64 remotely to get the vertex ref handle on the remote partition;
37 | * finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle
38 | * on the remote partition.
39 | * These two vertices should represent the same vertex in the partitioned graph.
40 | * @param GRIN_GRAPH The graph
41 | * @param GRIN_VERTEX The vertex
42 | * @return The vertex ref
43 | */
44 | GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH, GRIN_VERTEX);
45 |
46 | void grin_destroy_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF);
47 |
48 | /**
49 | * @brief get the local vertex handle from the vertex ref handle
50 | * if the vertex ref handle is not recognized, a null vertex is returned
51 | * @param GRIN_GRAPH The graph
52 | * @param GRIN_VERTEX_REF The vertex ref
53 | * @return The vertex handle
54 | */
55 | GRIN_VERTEX grin_get_vertex_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF);
56 |
57 | /**
58 | * @brief get the master partition of a vertex ref.
59 | * Some storage can still provide the master partition of the vertex ref,
60 | * even if the vertex ref can NOT be recognized locally.
61 | * @param GRIN_GRAPH The graph
62 | * @param GRIN_VERTEX_REF The vertex ref
63 | */
64 | GRIN_PARTITION grin_get_master_partition_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF);
65 |
66 | /**
67 | * @brief serialize the vertex ref handle to string
68 | * The returned string should be freed by ``grin_destroy_serialized_vertex_ref``
69 | * @param GRIN_GRAPH The graph
70 | * @param GRIN_VERTEX_REF The vertex ref
71 | */
72 | const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF);
73 |
74 | void grin_destroy_serialized_vertex_ref(GRIN_GRAPH, const char*);
75 |
76 | /**
77 | * @brief deserialize the string to vertex ref handle
78 | * If the string is invalid, a null vertex ref is returned
79 | * @param GRIN_GRAPH The graph
80 | * @param msg The string message to be deserialized
81 | */
82 | GRIN_VERTEX_REF grin_deserialize_to_vertex_ref(GRIN_GRAPH, const char* msg);
83 |
84 | /**
85 | * @brief check if the vertex is a master vertex
86 | * @param GRIN_GRAPH The graph
87 | * @param GRIN_VERTEX The vertex
88 | */
89 | bool grin_is_master_vertex(GRIN_GRAPH, GRIN_VERTEX);
90 |
91 | /**
92 | * @brief check if the vertex is a mirror vertex
93 | * @param GRIN_GRAPH The graph
94 | * @param GRIN_VERTEX The vertex
95 | */
96 | bool grin_is_mirror_vertex(GRIN_GRAPH, GRIN_VERTEX);
97 | #endif
98 |
99 | #ifdef GRIN_TRAIT_FAST_VERTEX_REF
100 | /**
101 | * @brief serialize the vertex ref handle to int64
102 | * This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref
103 | * can be serialized into int64 instead of string.
104 | * Obviously transferring and serializing int64 is faster than string.
105 | * @param GRIN_GRAPH The graph
106 | * @param GRIN_VERTEX_REF The vertex ref
107 | */
108 | long long int grin_serialize_vertex_ref_as_int64(GRIN_GRAPH, GRIN_VERTEX_REF);
109 |
110 | /**
111 | * @brief deserialize the int64 to vertex ref handle
112 | * @param GRIN_GRAPH The graph
113 | * @param msg The int64 message to be deserialized
114 | */
115 | GRIN_VERTEX_REF grin_deserialize_int64_to_vertex_ref(GRIN_GRAPH, long long int msg);
116 | #endif
117 |
118 | #ifdef GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST
119 | GRIN_PARTITION_LIST grin_get_master_vertex_mirror_partition_list(GRIN_GRAPH, GRIN_VERTEX);
120 | #endif
121 |
122 | #ifdef GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST
123 | GRIN_PARTITION_LIST grin_get_mirror_vertex_mirror_partition_list(GRIN_GRAPH, GRIN_VERTEX);
124 | #endif
125 |
126 | #ifdef GRIN_ENABLE_EDGE_REF
127 | GRIN_EDGE_REF grin_get_edge_ref_by_edge(GRIN_GRAPH, GRIN_EDGE);
128 |
129 | void grin_destroy_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF);
130 |
131 | GRIN_EDGE grin_get_edge_from_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF);
132 |
133 | GRIN_PARTITION grin_get_master_partition_from_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF);
134 |
135 | const char* grin_serialize_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF);
136 |
137 | void grin_destroy_serialized_edge_ref(GRIN_GRAPH, const char*);
138 |
139 | GRIN_EDGE_REF grin_deserialize_to_edge_ref(GRIN_GRAPH, const char*);
140 |
141 | bool grin_is_master_edge(GRIN_GRAPH, GRIN_EDGE);
142 |
143 | bool grin_is_mirror_edge(GRIN_GRAPH, GRIN_EDGE);
144 | #endif
145 |
146 | #ifdef GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST
147 | GRIN_PARTITION_LIST grin_get_master_edge_mirror_partition_list(GRIN_GRAPH, GRIN_EDGE);
148 | #endif
149 |
150 | #ifdef GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST
151 | GRIN_PARTITION_LIST grin_get_mirror_edge_mirror_partition_list(GRIN_GRAPH, GRIN_EDGE);
152 | #endif
153 |
154 | #endif // GRIN_INCLUDE_PARTITION_REFERENCE_H_
155 |
156 | #ifdef __cplusplus
157 | }
158 | #endif
159 |
--------------------------------------------------------------------------------
/include/partition/topology.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file partition/topology.h
17 | @brief Define the topoloy related APIs under partitioned graph
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PARTITION_TOPOLOGY_H_
25 | #define GRIN_INCLUDE_PARTITION_TOPOLOGY_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | #if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && !defined(GRIN_ENABLE_SCHEMA)
30 | /**
31 | * @brief Get the vertex list of the graph with master vertices only.
32 | * This API is only available when schema is not enabled.
33 | * @param GRIN_GRAPH The graph.
34 | * @return The vertex list of master vertices only.
35 | */
36 | GRIN_VERTEX_LIST grin_get_vertex_list_select_master(GRIN_GRAPH);
37 |
38 | /**
39 | * @brief Get the vertex list of the graph with mirror vertices only.
40 | * This API is only available when schema is not enabled.
41 | * @param GRIN_GRAPH The graph.
42 | * @return The vertex list of mirror vertices only.
43 | */
44 | GRIN_VERTEX_LIST grin_get_vertex_list_select_mirror(GRIN_GRAPH);
45 | #endif
46 |
47 | #if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && defined(GRIN_ENABLE_SCHEMA)
48 | /**
49 | * @brief Get the vertex list of a given type with master vertices only.
50 | * This API is only available when schema is enabled.
51 | * @param GRIN_GRAPH The graph.
52 | * @param GRIN_VERTEX_TYPE The vertex type.
53 | * @return The vertex list of master vertices only.
54 | */
55 | GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_master(GRIN_GRAPH, GRIN_VERTEX_TYPE);
56 |
57 | /**
58 | * @brief Get the vertex list of a given type with mirror vertices only.
59 | * This API is only available when schema is enabled.
60 | * @param GRIN_GRAPH The graph.
61 | * @param GRIN_VERTEX_TYPE The vertex type.
62 | * @return The vertex list of mirror vertices only.
63 | */
64 | GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_mirror(GRIN_GRAPH, GRIN_VERTEX_TYPE);
65 | #endif
66 |
67 |
68 | #if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && !defined(GRIN_ENABLE_SCHEMA)
69 | GRIN_VERTEX_LIST grin_get_vertex_list_select_partition(GRIN_GRAPH, GRIN_PARTITION);
70 | #endif
71 |
72 | #if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && defined(GRIN_ENABLE_SCHEMA)
73 | GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_partition(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_PARTITION);
74 | #endif
75 |
76 |
77 | #if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && !defined(GRIN_ENABLE_SCHEMA)
78 | GRIN_EDGE_LIST grin_get_edge_list_select_master(GRIN_GRAPH);
79 |
80 | GRIN_EDGE_LIST grin_get_edge_list_select_mirror(GRIN_GRAPH);
81 | #endif
82 |
83 | #if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && defined(GRIN_ENABLE_SCHEMA)
84 | GRIN_EDGE_LIST grin_get_edge_list_by_type_select_master(GRIN_GRAPH, GRIN_EDGE_TYPE);
85 |
86 | GRIN_EDGE_LIST grin_get_edge_list_by_type_select_mirror(GRIN_GRAPH, GRIN_EDGE_TYPE);
87 | #endif
88 |
89 |
90 | #if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && !defined(GRIN_ENABLE_SCHEMA)
91 | GRIN_EDGE_LIST grin_get_edge_list_select_partition(GRIN_GRAPH, GRIN_PARTITION);
92 | #endif
93 |
94 | #if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && defined(GRIN_ENABLE_SCHEMA)
95 | GRIN_EDGE_LIST grin_get_edge_list_by_type_select_partition(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_PARTITION);
96 | #endif
97 |
98 |
99 | #if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && !defined(GRIN_ENABLE_SCHEMA)
100 | GRIN_ADJACENT_LIST grin_get_adjacent_list_select_master_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
101 |
102 | GRIN_ADJACENT_LIST grin_get_adjacent_list_select_mirror_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
103 | #endif
104 |
105 | #if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && defined(GRIN_ENABLE_SCHEMA)
106 | GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_master_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE);
107 |
108 | GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_mirror_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE);
109 | #endif
110 |
111 |
112 | #if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && !defined(GRIN_ENABLE_SCHEMA)
113 | GRIN_ADJACENT_LIST grin_get_adjacent_list_select_partition_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_PARTITION);
114 | #endif
115 |
116 | #if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && defined(GRIN_ENABLE_SCHEMA)
117 | GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_partition_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE, GRIN_PARTITION);
118 | #endif
119 |
120 | // Universal Vertices
121 | #if defined(GRIN_ASSUME_WITH_UNIVERSAL_VERTICES) && defined(GRIN_ENABLE_SCHEMA)
122 | GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list_select_universal(GRIN_GRAPH);
123 |
124 | GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list_select_non_universal(GRIN_GRAPH);
125 |
126 | bool grin_is_vertex_type_unisversal(GRIN_GRAPH, GRIN_VERTEX_TYPE);
127 | #endif
128 |
129 | #if defined(GRIN_ASSUME_WITH_UNIVERSAL_VERTICES) && !defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_ENABLE_VERTEX_LIST)
130 | GRIN_VERTEX_LIST grin_get_vertex_list_select_universal(GRIN_GRAPH);
131 |
132 | GRIN_VERTEX_LIST grin_get_vertex_list_select_non_universal(GRIN_GRAPH);
133 | #endif
134 |
135 | #if defined(GRIN_ASSUME_WITH_UNIVERSAL_VERTICES) && !defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_ENABLE_EDGE_LIST)
136 | GRIN_EDGE_LIST grin_get_edge_list_select_universal(GRIN_GRAPH);
137 |
138 | GRIN_EDGE_LIST grin_get_edge_list_select_non_universal(GRIN_GRAPH);
139 | #endif
140 |
141 |
142 | #if defined(GRIN_ASSUME_WITH_UNIVERSAL_VERTICES) && !defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_ENABLE_ADJACENT_LIST)
143 | GRIN_ADJACENT_LIST grin_get_adjacent_list_select_universal_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
144 |
145 | GRIN_ADJACENT_LIST grin_get_adjacent_list_select_non_universal_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
146 | #endif
147 |
148 |
149 | #endif // GRIN_INCLUDE_PARTITION_TOPOLOGY_H_
150 |
151 | #ifdef __cplusplus
152 | }
153 | #endif
--------------------------------------------------------------------------------
/include/property/label.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file label.h
17 | @brief Define the label related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_LABEL_H_
25 | #define GRIN_INCLUDE_PROPERTY_LABEL_H_
26 |
27 | #if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL)
28 | /**
29 | * @brief get label list size
30 | * @param GRIN_GRAPH the graph
31 | * @param GRIN_LABEL_LIST the label list
32 | * @return the label list size
33 | */
34 | size_t grin_get_label_list_size(GRIN_GRAPH, GRIN_LABEL_LIST);
35 |
36 | /**
37 | * @brief get the label from the label list by index
38 | * @param GRIN_GRAPH the graph
39 | * @param GRIN_LABEL_LIST the label list
40 | * @param index the index
41 | */
42 | GRIN_LABEL grin_get_label_from_list(GRIN_GRAPH, GRIN_LABEL_LIST, size_t);
43 |
44 | /**
45 | * @brief get the label by name
46 | * @param GRIN_GRAPH the graph
47 | * @param label_name the label name
48 | * @return the label
49 | */
50 | GRIN_LABEL grin_get_label_by_name(GRIN_GRAPH, const char*);
51 |
52 | /**
53 | * @brief get the label name
54 | * @param GRIN_GRAPH the graph
55 | * @param GRIN_LABEL the label
56 | * @return the label name
57 | */
58 | const char* grin_get_label_name(GRIN_GRAPH, GRIN_LABEL);
59 |
60 | void grin_destroy_label(GRIN_GRAPH, GRIN_LABEL);
61 |
62 | void grin_destroy_label_list(GRIN_GRAPH, GRIN_LABEL_LIST);
63 | #endif
64 |
65 | #ifdef GRIN_WITH_VERTEX_LABEL
66 | /**
67 | * @brief get all the labels of a vertex as a label list
68 | * @param GRIN_GRAPH the graph
69 | * @param GRIN_VERTEX the vertex
70 | * @return the label list
71 | */
72 | GRIN_LABEL_LIST grin_get_label_list_by_vertex(GRIN_GRAPH, GRIN_VERTEX);
73 | #endif
74 |
75 | #if defined(GRIN_WITH_VERTEX_LABEL) && defined(GRIN_ENABLE_SCHEMA)
76 | /**
77 | * @brief get all the vertex types that might have the label
78 | * @param GRIN_GRAPH the graph
79 | * @param GRIN_LABEL the label
80 | * @return the vertex type list
81 | */
82 | GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list_by_label(GRIN_GRAPH, GRIN_LABEL);
83 |
84 | /**
85 | * @brief get the candidate label list by vertex type
86 | * @param GRIN_GRAPH the graph
87 | * @param GRIN_VERTEX_TYPE the vertex type
88 | * @return the label list
89 | */
90 | GRIN_LABEL_LIST grin_get_label_list_by_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
91 | #endif
92 |
93 |
94 | #ifdef GRIN_WITH_EDGE_LABEL
95 | /**
96 | * @brief get all the labels of an edge as a label list
97 | * @param GRIN_GRAPH the graph
98 | * @param GRIN_EDGE the edge
99 | * @return the label list
100 | */
101 | GRIN_LABEL_LIST grin_get_label_list_by_edge(GRIN_GRAPH, GRIN_EDGE);
102 | #endif
103 |
104 | #if defined(GRIN_WITH_EDGE_LABEL) && defined(GRIN_ENABLE_SCHEMA)
105 | /**
106 | * @brief get all the edge types that might have the label
107 | * @param GRIN_GRAPH the graph
108 | * @param GRIN_LABEL the label
109 | * @return the edge type list
110 | */
111 | GRIN_EDGE_TYPE_LIST grin_get_edge_type_list_by_label(GRIN_GRAPH, GRIN_LABEL);
112 |
113 | /**
114 | * @brief get the candidate label list by edge type
115 | * @param GRIN_GRAPH the graph
116 | * @param GRIN_EDGE_TYPE the edge type
117 | * @return the label list
118 | */
119 | GRIN_LABEL_LIST grin_get_label_list_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
120 | #endif
121 |
122 | #endif // GRIN_INCLUDE_PROPERTY_LABEL_H_
123 |
124 | #ifdef __cplusplus
125 | }
126 | #endif
--------------------------------------------------------------------------------
/include/property/primarykey.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file primarykey.h
17 | @brief Define the primary key related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_
25 | #define GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_
26 |
27 | #ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS
28 | /**
29 | * @brief Get the vertex types that have primary keys
30 | * In some graph, not every vertex type has primary keys.
31 | * @param GRIN_GRAPH The graph
32 | * @return The vertex type list of types that have primary keys
33 | */
34 | GRIN_VERTEX_TYPE_LIST grin_get_vertex_types_with_primary_keys(GRIN_GRAPH);
35 |
36 | /**
37 | * @brief Get the primary keys properties of a vertex type
38 | * The primary keys properties are the properties that can be used to identify a vertex.
39 | * They are a subset of the properties of a vertex type.
40 | * @param GRIN_GRAPH The graph
41 | * @param GRIN_VERTEX_TYPE The vertex type
42 | * @return The primary keys properties list
43 | */
44 | GRIN_VERTEX_PROPERTY_LIST grin_get_primary_keys_by_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
45 |
46 | /**
47 | * @brief Get the primary keys values row of a vertex
48 | * The values in the row are in the same order as the primary keys properties.
49 | * @param GRIN_GRAPH The graph
50 | * @param GRIN_VERTEX The vertex
51 | * @return The primary keys values row
52 | */
53 | GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH, GRIN_VERTEX);
54 | #endif
55 |
56 | #ifdef GRIN_ENABLE_EDGE_PRIMARY_KEYS
57 | GRIN_EDGE_TYPE_LIST grin_get_edge_types_with_primary_keys(GRIN_GRAPH);
58 |
59 | GRIN_EDGE_PROPERTY_LIST grin_get_primary_keys_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
60 |
61 | GRIN_ROW grin_get_edge_primary_keys_row(GRIN_GRAPH, GRIN_EDGE);
62 | #endif
63 |
64 | #endif // GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_
65 |
66 | #ifdef __cplusplus
67 | }
68 | #endif
--------------------------------------------------------------------------------
/include/property/property.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file property.h
17 | @brief Define the property related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_PROPERTY_H_
25 | #define GRIN_INCLUDE_PROPERTY_PROPERTY_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | #if !defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_WITH_VERTEX_PROPERTY)
30 | /**
31 | * @brief Get the vertex property list of the vertex.
32 | * When schema is not enabled, each vertex has its own property list.
33 | * @param GRIN_GRAPH The graph.
34 | * @param GRIN_VERTEX The vertex.
35 | * @return The vertex property list.
36 | */
37 | GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list(GRIN_GRAPH, GRIN_VERTEX);
38 |
39 | /**
40 | * @brief Get the vertex property name
41 | * @param GRIN_GRAPH The graph
42 | * @param GRIN_VERTEX The vertex
43 | * @param GRIN_VERTEX_PROPERTY The vertex property
44 | * @return The property's name as string
45 | */
46 | const char* grin_get_vertex_property_name(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY);
47 |
48 | /**
49 | * @brief Get the vertex property with a given name under a specific vertex
50 | * @param GRIN_GRAPH The graph
51 | * @param GRIN_VERTEX The specific vertex
52 | * @param name The name
53 | * @return The vertex property
54 | */
55 | GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH, GRIN_VERTEX, const char* name);
56 | #endif
57 |
58 | #if defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_WITH_VERTEX_PROPERTY)
59 | /**
60 | * @brief Get the vertex property list of the graph.
61 | * This API is only available for property graph.
62 | * @param GRIN_GRAPH The graph.
63 | * @return The vertex property list.
64 | */
65 | GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
66 |
67 | /**
68 | * @brief Get the vertex type that a given vertex property belongs to.
69 | * @param GRIN_GRAPH The graph
70 | * @param GRIN_VERTEX_PROPERTY The vertex property
71 | * @return The vertex type
72 | */
73 | GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY);
74 |
75 | /**
76 | * @brief Get the vertex property name
77 | * @param GRIN_GRAPH The graph
78 | * @param GRIN_VERTEX_TYPE The vertex type that the property belongs to
79 | * @param GRIN_VERTEX_PROPERTY The vertex property
80 | * @return The property's name as string
81 | */
82 | const char* grin_get_vertex_property_name(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY);
83 |
84 | /**
85 | * @brief Get the vertex property with a given name under a specific vertex type
86 | * @param GRIN_GRAPH The graph
87 | * @param GRIN_VERTEX_TYPE The specific vertex type
88 | * @param name The name
89 | * @return The vertex property
90 | */
91 | GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH, GRIN_VERTEX_TYPE, const char* name);
92 |
93 | /**
94 | * @brief Get properties under all types with a given name.
95 | * For example, vertex type "person" and "company" both have a property
96 | * called "name". When this API is called given "name", it will return a list
97 | * of "name" properties under both types.
98 | * @param GRIN_GRAPH The graph
99 | * @param name The name
100 | * @return The vertex property list of properties with the given name
101 | */
102 | GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH, const char* name);
103 |
104 | /**
105 | * @brief Get the vertex property handle by id.
106 | * In strict schema, storage has naturally increasing ids for vertex properties
107 | * under a certain vertex type.
108 | * @param GRIN_GRAPH The graph.
109 | * @param GRIN_VERTEX_TYPE The vertex type.
110 | * @param GRIN_VERTEX_PROPERTY_ID The vertex property id.
111 | * @return The vertex property handle.
112 | */
113 | GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY_ID);
114 |
115 | /**
116 | * @brief Get the vertex property's natural id.
117 | * In strict schema, the storage has naturally increasing ids for vertex properties
118 | * under a certain vertex type.
119 | * @param GRIN_GRAPH The graph.
120 | * @param GRIN_VERTEX_TYPE The vertex type.
121 | * @param GRIN_VERTEX_PROPERTY The vertex property handle.
122 | * @return The vertex property id.
123 | */
124 | GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY);
125 | #endif
126 |
127 | #if !defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_WITH_EDGE_PROPERTY)
128 | GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list(GRIN_GRAPH, GRIN_EDGE);
129 |
130 | const char* grin_get_edge_property_name(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY);
131 |
132 | GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH, GRIN_EDGE, const char* name);
133 | #endif
134 |
135 | #if defined(GRIN_ENABLE_SCHEMA) && defined(GRIN_WITH_EDGE_PROPERTY)
136 | GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
137 |
138 | const char* grin_get_edge_property_name(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY);
139 |
140 | GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH, GRIN_EDGE_TYPE, const char* name);
141 |
142 | GRIN_EDGE_PROPERTY_LIST grin_get_edge_properties_by_name(GRIN_GRAPH, const char* name);
143 |
144 | GRIN_EDGE_TYPE grin_get_edge_type_from_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY);
145 |
146 | GRIN_EDGE_PROPERTY grin_get_edge_property_by_id(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY_ID);
147 |
148 | GRIN_EDGE_PROPERTY_ID grin_get_edge_property_id(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY);
149 | #endif
150 |
151 | #ifdef GRIN_WITH_VERTEX_PROPERTY
152 | bool grin_equal_vertex_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY, GRIN_VERTEX_PROPERTY);
153 |
154 | void grin_destroy_vertex_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY);
155 |
156 | /**
157 | * @brief Get the datatype of the vertex property
158 | * @param GRIN_GRAPH The graph
159 | * @param GRIN_VERTEX_PROPERTY The vertex property
160 | * @return The datatype of the vertex property
161 | */
162 | GRIN_DATATYPE grin_get_vertex_property_datatype(GRIN_GRAPH, GRIN_VERTEX_PROPERTY);
163 | #endif
164 |
165 | #ifdef GRIN_WITH_EDGE_PROPERTY
166 | bool grin_equal_edge_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY, GRIN_EDGE_PROPERTY);
167 |
168 | void grin_destroy_edge_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY);
169 |
170 | GRIN_DATATYPE grin_get_edge_property_datatype(GRIN_GRAPH, GRIN_EDGE_PROPERTY);
171 | #endif
172 |
173 | #endif // GRIN_INCLUDE_PROPERTY_PROPERTY_H_
174 |
175 | #ifdef __cplusplus
176 | }
177 | #endif
--------------------------------------------------------------------------------
/include/property/propertylist.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file propertylist.h
17 | @brief Define the property list related and graph projection APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_
25 | #define GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_
26 |
27 | #ifdef GRIN_WITH_VERTEX_PROPERTY
28 | size_t grin_get_vertex_property_list_size(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST);
29 |
30 | GRIN_VERTEX_PROPERTY grin_get_vertex_property_from_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST, size_t);
31 |
32 | GRIN_VERTEX_PROPERTY_LIST grin_create_vertex_property_list(GRIN_GRAPH);
33 |
34 | void grin_destroy_vertex_property_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST);
35 |
36 | bool grin_insert_vertex_property_to_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST, GRIN_VERTEX_PROPERTY);
37 | #endif
38 |
39 |
40 | #ifdef GRIN_WITH_EDGE_PROPERTY
41 | size_t grin_get_edge_property_list_size(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST);
42 |
43 | GRIN_EDGE_PROPERTY grin_get_edge_property_from_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST, size_t);
44 |
45 | GRIN_EDGE_PROPERTY_LIST grin_create_edge_property_list(GRIN_GRAPH);
46 |
47 | void grin_destroy_edge_property_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST);
48 |
49 | bool grin_insert_edge_property_to_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST, GRIN_EDGE_PROPERTY);
50 | #endif
51 |
52 | #endif // GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_
53 |
54 | #ifdef __cplusplus
55 | }
56 | #endif
--------------------------------------------------------------------------------
/include/property/row.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file row.h
17 | @brief Define the row related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_ROW_H_
25 | #define GRIN_INCLUDE_PROPERTY_ROW_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | #if defined(GRIN_ENABLE_ROW) && defined(GRIN_TRAIT_PROPERTY_VALUE_OF_FLOAT_ARRAY)
30 | void grin_destroy_row_value_of_float_array(GRIN_GRAPH, const float*, size_t);
31 |
32 | const float* grin_get_float_array_from_row(GRIN_GRAPH, GRIN_ROW, size_t, size_t*);
33 |
34 | bool grin_insert_float_array_to_row(GRIN_GRAPH, GRIN_ROW, const float*, size_t);
35 | #endif
36 |
37 | #ifdef GRIN_ENABLE_ROW
38 | void grin_destroy_row(GRIN_GRAPH, GRIN_ROW);
39 |
40 | void grin_destroy_row_value_of_string(GRIN_GRAPH, const char*);
41 |
42 | int grin_get_int32_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
43 |
44 | unsigned int grin_get_uint32_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
45 |
46 | long long int grin_get_int64_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
47 |
48 | unsigned long long int grin_get_uint64_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
49 |
50 | float grin_get_float_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
51 |
52 | double grin_get_double_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
53 |
54 | const char* grin_get_string_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
55 |
56 | int grin_get_date32_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
57 |
58 | int grin_get_time32_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
59 |
60 | long long int grin_get_timestamp64_from_row(GRIN_GRAPH, GRIN_ROW, size_t);
61 |
62 | /**
63 | * @brief Create a row.
64 | * Row works as carrier of property values in GRIN.
65 | * It is a pure value array, and users can only get the value by the array index.
66 | * That means users should understand the property that each value is
67 | * representing when using the row.
68 | * Currently rows are used in two scenarios:
69 | * 1. Users can create a row of values for primary keys properties,
70 | * and then query the vertex/edge using the row if pk indexing is enabled.
71 | * 2. Users can get the row of values for the entire property list of
72 | * a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``.
73 | * However this API is not recommended if the user only wants to get the
74 | * properties values, in which case, the user can get property values
75 | * one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``.
76 | */
77 | GRIN_ROW grin_create_row(GRIN_GRAPH);
78 |
79 | bool grin_insert_int32_to_row(GRIN_GRAPH, GRIN_ROW, int);
80 |
81 | bool grin_insert_uint32_to_row(GRIN_GRAPH, GRIN_ROW, unsigned int);
82 |
83 | bool grin_insert_int64_to_row(GRIN_GRAPH, GRIN_ROW, long long int);
84 |
85 | bool grin_insert_uint64_to_row(GRIN_GRAPH, GRIN_ROW, unsigned long long int);
86 |
87 | bool grin_insert_float_to_row(GRIN_GRAPH, GRIN_ROW, float);
88 |
89 | bool grin_insert_double_to_row(GRIN_GRAPH, GRIN_ROW, double);
90 |
91 | bool grin_insert_string_to_row(GRIN_GRAPH, GRIN_ROW, const char*);
92 |
93 | bool grin_insert_date32_to_row(GRIN_GRAPH, GRIN_ROW, int);
94 |
95 | bool grin_insert_time32_to_row(GRIN_GRAPH, GRIN_ROW, int);
96 |
97 | bool grin_insert_timestamp64_to_row(GRIN_GRAPH, GRIN_ROW, long long int);
98 | #endif
99 |
100 | #if defined(GRIN_ENABLE_ROW) && defined(GRIN_TRAIT_CONST_VALUE_PTR)
101 | const void* grin_get_value_from_row(GRIN_GRAPH, GRIN_ROW, GRIN_DATATYPE, size_t);
102 | #endif
103 |
104 |
105 | #if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_ENABLE_ROW)
106 | /**
107 | * @brief Get row of values for the entire property list of a vertex.
108 | * Later users can get property values from the row using APIs like
109 | * ``grin_get_int32_from_row``.
110 | * However this two-step value getting is not recommended if the user
111 | * only wants to get the value of one property, in which case, the user
112 | * should use APIs like ``grin_get_vertex_property_value_of_int32``.
113 | * @param GRIN_GRAPH The graph
114 | * @param GRIN_VERTEX The vertex
115 | */
116 | GRIN_ROW grin_get_vertex_row(GRIN_GRAPH, GRIN_VERTEX);
117 | #endif
118 |
119 |
120 | #if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_ENABLE_ROW)
121 | GRIN_ROW grin_get_edge_row(GRIN_GRAPH, GRIN_EDGE);
122 | #endif
123 |
124 | #endif // GRIN_INCLUDE_PROPERTY_ROW_H_
125 |
126 | #ifdef __cplusplus
127 | }
128 | #endif
--------------------------------------------------------------------------------
/include/property/topology.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file property/topology.h
17 | @brief Define the topology related APIs under property graph
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_
25 | #define GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | #ifdef GRIN_ENABLE_SCHEMA
30 | /**
31 | * @brief Get the vertex number of a given type in the graph.
32 | * This API is only available for property graph.
33 | * @param GRIN_GRAPH The graph.
34 | * @param GRIN_VERTEX_TYPE The vertex type.
35 | * @return The vertex number.
36 | */
37 | size_t grin_get_vertex_num_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
38 |
39 | size_t grin_get_edge_num_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
40 | #endif
41 |
42 | #if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_ENABLE_SCHEMA)
43 | /**
44 | * @brief Get the vertex list of a given type.
45 | * This API is only available for property graph.
46 | * To get a vertex list chain of all types, using APIs in GRIN extension.
47 | * @param GRIN_GRAPH The graph.
48 | * @param GRIN_VERTEX_TYPE The vertex type.
49 | * @return The vertex list of the given type.
50 | */
51 | GRIN_VERTEX_LIST grin_get_vertex_list_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
52 | #endif
53 |
54 | #if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_ENABLE_SCHEMA)
55 | GRIN_EDGE_LIST grin_get_edge_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
56 | #endif
57 |
58 | #if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_ENABLE_SCHEMA)
59 | /**
60 | * @brief Get the adjacent list of given direction, vertex and edge type.
61 | * This API is only available for property graph.
62 | * To get a adjacent list chain of all types, using APIs in GRIN extension.
63 | * @param GRIN_GRAPH The graph.
64 | * @param GRIN_DIRECTION The direction of the adjacent list.
65 | * @param GRIN_VERTEX The vertex.
66 | * @return The adjacent list.
67 | */
68 | GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE);
69 | #endif
70 |
71 | #endif // GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
--------------------------------------------------------------------------------
/include/property/type.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file type.h
17 | @brief Define the vertex/edge type related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_PROPERTY_TYPE_H_
25 | #define GRIN_INCLUDE_PROPERTY_TYPE_H_
26 |
27 | #ifdef GRIN_ENABLE_SCHEMA
28 | /**************** vertex type ****************/
29 | bool grin_equal_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_TYPE);
30 |
31 | GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH, GRIN_VERTEX);
32 |
33 | void grin_destroy_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE);
34 |
35 | /**
36 | * @brief Get the vertex type name.
37 | * This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,
38 | * meaning that the graph has a unique name for each vertex type.
39 | * @param GRIN_GRAPH The graph.
40 | * @param GRIN_VERTEX_TYPE The vertex type.
41 | * @return The vertex type name of string.
42 | */
43 | const char* grin_get_vertex_type_name(GRIN_GRAPH, GRIN_VERTEX_TYPE);
44 |
45 | /**
46 | * @brief Get the vertex type by name.
47 | * This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,
48 | * meaning that the graph has a unique name for each vertex type.
49 | * @param GRIN_GRAPH The graph.
50 | * @param name The vertex type name.
51 | * @return The vertex type.
52 | */
53 | GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH, const char* name);
54 |
55 | /**
56 | * @brief Get the vertex type id.
57 | * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,
58 | * meaning that the graph has naturally increasing ids for vertex types.
59 | * @param GRIN_GRAPH The graph.
60 | * @param GRIN_VERTEX_TYPE The vertex type.
61 | * @return The vertex type id.
62 | */
63 | GRIN_VERTEX_TYPE_ID grin_get_vertex_type_id(GRIN_GRAPH, GRIN_VERTEX_TYPE);
64 |
65 | /**
66 | * @brief Get the vertex type by id.
67 | * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,
68 | * meaning that the graph has naturally increasing ids for vertex types.
69 | * @param GRIN_GRAPH The graph.
70 | * @param GRIN_VERTEX_TYPE_ID The vertex type id.
71 | * @return The vertex type.
72 | */
73 | GRIN_VERTEX_TYPE grin_get_vertex_type_by_id(GRIN_GRAPH, GRIN_VERTEX_TYPE_ID);
74 |
75 | /**************** vertex type list ****************/
76 | /**
77 | * @brief Get the vertex type list of the graph
78 | * This API is only available for property graph.
79 | * It lists all the vertex types in the graph.
80 | * @param GRIN_GRAPH The graph.
81 | * @return The vertex type list.
82 | */
83 | GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list(GRIN_GRAPH);
84 |
85 | void grin_destroy_vertex_type_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST);
86 |
87 | GRIN_VERTEX_TYPE_LIST grin_create_vertex_type_list(GRIN_GRAPH);
88 |
89 | bool grin_insert_vertex_type_to_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST, GRIN_VERTEX_TYPE);
90 |
91 | size_t grin_get_vertex_type_list_size(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST);
92 |
93 | GRIN_VERTEX_TYPE grin_get_vertex_type_from_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST, size_t);
94 |
95 |
96 | /**************** edge type ****************/
97 | bool grin_equal_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_TYPE);
98 |
99 | GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH, GRIN_EDGE);
100 |
101 | void grin_destroy_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
102 |
103 | const char* grin_get_edge_type_name(GRIN_GRAPH, GRIN_EDGE_TYPE);
104 |
105 | GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH, const char*);
106 |
107 | GRIN_EDGE_TYPE_ID grin_get_edge_type_id(GRIN_GRAPH, GRIN_EDGE_TYPE);
108 |
109 | GRIN_EDGE_TYPE grin_get_edge_type_by_id(GRIN_GRAPH, GRIN_EDGE_TYPE_ID);
110 |
111 | /**************** edge type list ****************/
112 | GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH);
113 |
114 | void grin_destroy_edge_type_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST);
115 |
116 | GRIN_EDGE_TYPE_LIST grin_create_edge_type_list(GRIN_GRAPH);
117 |
118 | bool grin_insert_edge_type_to_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST, GRIN_EDGE_TYPE);
119 |
120 | size_t grin_get_edge_type_list_size(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST);
121 |
122 | GRIN_EDGE_TYPE grin_get_edge_type_from_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST, size_t);
123 |
124 |
125 | /**************** relations between vertex type pair and edge type ****************/
126 | /**
127 | * @brief Get source vertex types related to an edge type.
128 | * GRIN assumes the relation between edge type and pairs of vertex types is
129 | * many-to-many.
130 | * To return the related pairs of vertex types, GRIN provides two APIs to get
131 | * the src and dst vertex types respectively.
132 | * The returned vertex type lists are of the same size,
133 | * and the src/dst vertex types are aligned with their positions in the lists.
134 | * @param GRIN_GRAPH The graph.
135 | * @param GRIN_EDGE_TYPE The edge type.
136 | * @return The vertex type list of source.
137 | */
138 | GRIN_VERTEX_TYPE_LIST grin_get_src_types_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
139 |
140 | /**
141 | * @brief Get destination vertex types related to an edge type.
142 | * GRIN assumes the relation between edge type and pairs of vertex types is
143 | * many-to-many.
144 | * To return the related pairs of vertex types, GRIN provides two APIs to get
145 | * the src and dst vertex types respectively.
146 | * The returned vertex type lists are of the same size,
147 | * and the src/dst vertex types are aligned with their positions in the lists.
148 | * @param GRIN_GRAPH The graph.
149 | * @param GRIN_EDGE_TYPE The edge type.
150 | * @return The vertex type list of destination.
151 | */
152 | GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE);
153 |
154 | /**
155 | * @brief Get edge types related to a pair of vertex types.
156 | * GRIN assumes the relation between edge type and pairs of vertex types is
157 | * many-to-many.
158 | * @param GRIN_GRAPH The graph.
159 | * @param GRIN_VERTEX_TYPE The source vertex type.
160 | * @param GRIN_VERTEX_TYPE The destination vertex type.
161 | * @return The related edge type list.
162 | */
163 | GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_TYPE);
164 | #endif
165 |
166 | #endif // GRIN_INCLUDE_PROPERTY_TYPE_H_
167 |
168 | #ifdef __cplusplus
169 | }
170 | #endif
--------------------------------------------------------------------------------
/include/topology/adjacentlist.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file adjacentlist.h
17 | @brief Define the adjacent list related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_
25 | #define GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | #if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_ENABLE_SCHEMA)
30 | /**
31 | * @brief Get the adjacent list of a vertex.
32 | * This API is only available when schema is not enabled.
33 | * Otherwise, use ``grin_get_adjacent_list_by_edge_type`` instead,
34 | * or consider ``adjacent_list_chain`` in GRIN extension.
35 | * @param GRIN_GRAPH The graph.
36 | * @param GRIN_DIRECTION The direction of the adjacent list.
37 | * @param GRIN_VERTEX The vertex.
38 | * @return The adjacent list.
39 | */
40 | GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX);
41 | #endif
42 |
43 | #ifdef GRIN_ENABLE_ADJACENT_LIST
44 | void grin_destroy_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST);
45 | #endif
46 |
47 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY
48 | size_t grin_get_adjacent_list_size(GRIN_GRAPH, GRIN_ADJACENT_LIST);
49 |
50 | /**
51 | * @brief Get the neighbor vertex from the adjacent list.
52 | * @param GRIN_GRAPH The graph.
53 | * @param GRIN_ADJACENT_LIST The adjacent list.
54 | * @param index The index of the edge to/from the neighbor in the adjacent list.
55 | * @return The neighbor vertex.
56 | */
57 | GRIN_VERTEX grin_get_neighbor_from_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST, size_t index);
58 |
59 | /**
60 | * @brief Get the edge from the adjacent list.
61 | * @param GRIN_GRAPH The graph.
62 | * @param GRIN_ADJACENT_LIST The adjacent list.
63 | * @param index The index of the edge in the adjacent list.
64 | * @return The edge. Note that when the direction is OUT, the destination vertex
65 | * of the edge is the neighbor vertex. While the direction is IN, the source
66 | * vertex of the edge is the neighbor vertex.
67 | */
68 | GRIN_EDGE grin_get_edge_from_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST, size_t);
69 | #endif
70 |
71 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR
72 | /**
73 | * @brief Get the begin iterator of the adjacent list.
74 | * @param GRIN_GRAPH The graph.
75 | * @param GRIN_ADJACENT_LIST The adjacent list.
76 | * @return The begin iterator of the adjacent list.
77 | */
78 | GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin(GRIN_GRAPH, GRIN_ADJACENT_LIST);
79 |
80 | void grin_destroy_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR);
81 |
82 | /**
83 | * @brief Update the iterator to the next of the adjacent list.
84 | * @param GRIN_GRAPH The graph.
85 | * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator to be updated.
86 | */
87 | void grin_get_next_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR);
88 |
89 | /**
90 | * @brief Check if the adjacent list iterator is at the end.
91 | * Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin``
92 | * if the adjacent list is empty.
93 | * Users should check if the iterator is at the end before using it.
94 | * @param GRIN_GRAPH The graph.
95 | * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.
96 | * @return True if the iterator is at the end, otherwise false.
97 | */
98 | bool grin_is_adjacent_list_end(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR);
99 |
100 | /**
101 | * @brief Get the neighbor vertex from the adjacent list iterator.
102 | * @param GRIN_GRAPH The graph.
103 | * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.
104 | * @return The neighbor vertex.
105 | */
106 | GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR);
107 |
108 | /**
109 | * @brief Get the edge from the adjacent list iterator.
110 | * @param GRIN_GRAPH The graph.
111 | * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.
112 | * @return The edge. Note that when the direction is OUT, the destination vertex
113 | * of the edge is the neighbor vertex. While the direction is IN, the source
114 | * vertex of the edge is the neighbor vertex.
115 | */
116 | GRIN_EDGE grin_get_edge_from_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR);
117 | #endif
118 |
119 | #endif // GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_
120 |
121 | #ifdef __cplusplus
122 | }
123 | #endif
124 |
--------------------------------------------------------------------------------
/include/topology/edgelist.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file edgelist.h
17 | @brief Define the edge list related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_
25 | #define GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_
26 |
27 | #if defined(GRIN_ENABLE_EDGE_LIST) && !defined(GRIN_ENABLE_SCHEMA)
28 | GRIN_EDGE_LIST grin_get_edge_list(GRIN_GRAPH);
29 | #endif
30 |
31 | #ifdef GRIN_ENABLE_EDGE_LIST
32 | void grin_destroy_edge_list(GRIN_GRAPH, GRIN_EDGE_LIST);
33 | #endif
34 |
35 | #ifdef GRIN_ENABLE_EDGE_LIST_ARRAY
36 | size_t grin_get_edge_list_size(GRIN_GRAPH, GRIN_EDGE_LIST);
37 |
38 | GRIN_EDGE grin_get_edge_from_list(GRIN_GRAPH, GRIN_EDGE_LIST, size_t);
39 | #endif
40 |
41 | #ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR
42 | GRIN_EDGE_LIST_ITERATOR grin_get_edge_list_begin(GRIN_GRAPH, GRIN_EDGE_LIST);
43 |
44 | void grin_destroy_edge_list_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR);
45 |
46 | void grin_get_next_edge_list_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR);
47 |
48 | bool grin_is_edge_list_end(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR);
49 |
50 | GRIN_EDGE grin_get_edge_from_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR);
51 | #endif
52 |
53 | #endif // GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_
54 |
55 | #ifdef __cplusplus
56 | }
57 | #endif
--------------------------------------------------------------------------------
/include/topology/structure.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file structure.h
17 | @brief Define the basic topology structure related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_
25 | #define GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_
26 |
27 | #include "common/enum_types.h"
28 |
29 | /**
30 | * @brief Get a (non-partitioned) graph from storage
31 | * @param uri The URI of the graph.
32 | * Current URI for supported storage includes:
33 | * 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}
34 | * 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}
35 | * 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.
36 | * @return A graph handle.
37 | */
38 | GRIN_GRAPH grin_get_graph_from_storage(const char*);
39 |
40 | void grin_destroy_graph(GRIN_GRAPH);
41 |
42 | // Graph
43 | #if defined(GRIN_ASSUME_HAS_DIRECTED_GRAPH) && defined(GRIN_ASSUME_HAS_UNDIRECTED_GRAPH)
44 | /**
45 | * @brief Check if the graph is directed.
46 | * This API is only available when the storage supports both directed and
47 | * undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH``
48 | * and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined.
49 | * @param GRIN_GRAPH The graph.
50 | * @return True if the graph is directed, otherwise false.
51 | */
52 | bool grin_is_directed(GRIN_GRAPH);
53 | #endif
54 |
55 | #ifdef GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
56 | /**
57 | * @brief Check if the graph is a multigraph.
58 | * This API is only available when the storage supports multigraph.
59 | * @param GRIN_GRAPH The graph.
60 | * @return True if the graph is a multigraph, otherwise false.
61 | */
62 | bool grin_is_multigraph(GRIN_GRAPH);
63 | #endif
64 |
65 | #ifndef GRIN_ENABLE_SCHEMA
66 | /**
67 | * @brief Get the number of vertices in the graph.
68 | * This API is only available for simple graph.
69 | * @param GRIN_GRAPH The graph.
70 | * @return The number of vertices in the graph.
71 | */
72 | size_t grin_get_vertex_num(GRIN_GRAPH);
73 |
74 | /**
75 | * @brief Get the number of edges in the graph.
76 | * This API is only available for simple graph.
77 | * @param GRIN_GRAPH The graph.
78 | * @return The number of edges in the graph.
79 | */
80 | size_t grin_get_edge_num(GRIN_GRAPH);
81 | #endif
82 |
83 |
84 | // Vertex
85 | void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX);
86 |
87 | bool grin_equal_vertex(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX);
88 |
89 | // Data
90 | #ifdef GRIN_WITH_VERTEX_DATA
91 | GRIN_DATATYPE grin_get_vertex_data_datatype(GRIN_GRAPH, GRIN_VERTEX);
92 |
93 | const void* grin_get_vertex_data_value(GRIN_GRAPH, GRIN_VERTEX);
94 | #endif
95 |
96 | // Edge
97 | void grin_destroy_edge(GRIN_GRAPH, GRIN_EDGE);
98 |
99 | /**
100 | * @brief Get the source vertex of an edge.
101 | * @param GRIN_GRAPH The graph.
102 | * @param GRIN_EDGE The edge.
103 | * @return The source vertex of the edge.
104 | */
105 | GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE);
106 |
107 | /**
108 | * @brief Get the destination vertex of an edge.
109 | * @param GRIN_GRAPH The graph.
110 | * @param GRIN_EDGE The edge.
111 | * @return The destination vertex of the edge.
112 | */
113 | GRIN_VERTEX grin_get_dst_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE);
114 |
115 | #ifdef GRIN_WITH_EDGE_DATA
116 | GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE);
117 |
118 | const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE);
119 | #endif
120 |
121 | #endif // GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_
122 |
123 | #ifdef __cplusplus
124 | }
125 | #endif
--------------------------------------------------------------------------------
/include/topology/vertexlist.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | /**
16 | @file vertexlist.h
17 | @brief Define the vertex list related APIs
18 | */
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | #ifndef GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_
25 | #define GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_
26 |
27 | #if defined(GRIN_ENABLE_VERTEX_LIST) && !defined(GRIN_ENABLE_SCHEMA)
28 | /**
29 | * @brief Get the vertex list of the graph
30 | * This API is only available when schema is not enabled.
31 | * When schema is enabled, use ``grin_get_vertex_list_by_type`` to
32 | * get the vertex list of a single vertex type,
33 | * or consider ``vertex_list_chain`` in GRIN extension.
34 | * @param GRIN_GRAPH The graph.
35 | * @return The vertex list.
36 | */
37 | GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH);
38 | #endif
39 |
40 | #ifdef GRIN_ENABLE_VERTEX_LIST
41 | void grin_destroy_vertex_list(GRIN_GRAPH, GRIN_VERTEX_LIST);
42 | #endif
43 |
44 | #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY
45 | size_t grin_get_vertex_list_size(GRIN_GRAPH, GRIN_VERTEX_LIST);
46 |
47 | /**
48 | * @brief Get the vertex from the vertex list.
49 | * @param GRIN_GRAPH The graph.
50 | * @param GRIN_VERTEX_LIST The vertex list.
51 | * @param index The index of the vertex in the vertex list.
52 | * @return The vertex.
53 | */
54 | GRIN_VERTEX grin_get_vertex_from_list(GRIN_GRAPH, GRIN_VERTEX_LIST, size_t index);
55 | #endif
56 |
57 | #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR
58 | /**
59 | * @brief Get the begin iterator of the vertex list.
60 | * @param GRIN_GRAPH The graph.
61 | * @param GRIN_VERTEX_LIST The vertex list.
62 | * @return The begin iterator.
63 | */
64 | GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH, GRIN_VERTEX_LIST);
65 |
66 | void grin_destroy_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
67 |
68 | /**
69 | * @brief Update the iterator to the next of the vertex list.
70 | * @param GRIN_GRAPH The graph.
71 | * @param GRIN_VERTEX_LIST_ITERATOR The iterator to be updated.
72 | */
73 | void grin_get_next_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
74 |
75 | /**
76 | * @brief Check whether the iterator reaches the end of the vertex list.
77 | * Note that we may get an end iterator when calling ``grin_get_vertex_list_begin``
78 | * if the vertex list is empty.
79 | * Users should check if the iterator is at the end before using it.
80 | * @param GRIN_GRAPH The graph.
81 | * @param GRIN_VERTEX_LIST_ITERATOR The iterator.
82 | * @return True if the iterator reaches the end of the vertex list.
83 | */
84 | bool grin_is_vertex_list_end(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
85 |
86 | /**
87 | * @brief Get the vertex from the iterator.
88 | * @param GRIN_GRAPH The graph.
89 | * @param GRIN_VERTEX_LIST_ITERATOR The iterator.
90 | * @return The vertex.
91 | */
92 | GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR);
93 | #endif
94 |
95 | #endif // GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_
96 |
97 | #ifdef __cplusplus
98 | }
99 | #endif
100 |
--------------------------------------------------------------------------------
/proto/gie_data_model/data_type.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package gie;
4 | option java_package = "com.alibaba.graphscope.proto.schema";
5 |
6 | enum PrimitiveType {
7 | DT_ANY = 0;
8 | DT_SIGNED_INT32 = 1;
9 | DT_UNSIGNED_INT32 = 2;
10 | DT_SIGNED_INT64 = 3;
11 | DT_UNSIGNED_INT64 = 4;
12 | DT_BOOL = 5;
13 | DT_FLOAT = 6;
14 | DT_DOUBLE = 7;
15 | DT_STRING = 8; // string with unlimited length
16 | }
17 |
18 | message Numeric { // precision=4 scale=2 : 23.12
19 | uint32 precision = 1;
20 | uint32 scale = 2;
21 | }
22 |
23 | message Char {
24 | uint32 fixed_length = 1;
25 | }
26 |
27 | message VarChar {
28 | uint32 max_length = 1;
29 | }
30 |
31 | // temporal types
32 |
33 | enum DateFormat {
34 | DF_YYYY_MM_DD = 0; // ISO fomat: 2019-01-01
35 | }
36 |
37 | enum TimeFormat {
38 | TF_HH_MM_SS_SSS = 0; // ISO format: 00:00:00.000
39 | }
40 |
41 | enum DateTimeFormat {
42 | DTF_YYYY_MM_DD_HH_MM_SS_SSS = 0; // ISO format: 2019-01-01 00:00:00.000
43 | }
44 |
45 | enum TimeZoneFormat {
46 | TZF_UTC = 0; // Z
47 | TZF_OFFSET = 1; // +08:00 or -08:00
48 | }
49 |
50 | message Date {
51 | DateFormat date_format = 1;
52 | }
53 |
54 | message Time {
55 | TimeFormat time_format = 1;
56 | TimeZoneFormat time_zone_format = 2;
57 | }
58 |
59 | message DateTime {
60 | DateTimeFormat date_time_format = 1;
61 | TimeZoneFormat time_zone_format = 2;
62 | }
63 |
64 | // element type nested in array or multiset or map
65 | message ComponentType {
66 | oneof item {
67 | PrimitiveType primitive_type = 1;
68 | Numeric numeric = 2;
69 | Char char = 3;
70 | VarChar var_char = 4;
71 | Date date = 5;
72 | Time time = 6;
73 | DateTime date_time = 7;
74 | }
75 | }
76 |
77 | message Array {
78 | ComponentType component_type = 1;
79 | uint32 max_length = 2;
80 | }
81 |
82 | message MultiSet {
83 | ComponentType component_type = 1;
84 | }
85 |
86 | message Map {
87 | // type can be hashing
88 | message KeyType {
89 | enum PrimitiveKeyType {
90 | DT_SIGNED_INT32 = 0;
91 | DT_UNSIGNED_INT32 = 1;
92 | DT_SIGNED_INT64 = 2;
93 | DT_UNSIGNED_INT64 = 3;
94 | DT_BOOL = 4;
95 | DT_STRING = 5;
96 | }
97 |
98 | oneof item {
99 | PrimitiveKeyType primitive_key_type = 1;
100 | Char char = 2;
101 | VarChar var_char = 3;
102 | Date date = 4;
103 | Time time = 5;
104 | DateTime date_time = 6;
105 | }
106 | }
107 |
108 | KeyType key_type = 1;
109 | ComponentType value_type = 2;
110 | }
111 |
112 | message StorageDataType {
113 | oneof item {
114 | PrimitiveType primitive_type = 1;
115 | Numeric numeric = 2;
116 | Char char = 3;
117 | VarChar var_char = 4;
118 | Date date = 5;
119 | Time time = 6;
120 | DateTime date_time = 7;
121 | Array array = 8;
122 | MultiSet multi_set = 9;
123 | Map map = 10;
124 | }
125 |
126 | bool nullable = 11;
127 | }
128 |
--------------------------------------------------------------------------------
/proto/gie_data_model/graph.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package gie;
4 | option java_package = "com.alibaba.graphscope.proto.schema";
5 |
6 | import "schema.proto";
7 | import "partition.proto";
8 |
9 | message Graph {
10 | string snapshot_id = 1;
11 | Schema schema = 2;
12 | GraphPartitionStrategy partition_strategy = 3;
13 | }
--------------------------------------------------------------------------------
/proto/gie_data_model/partition.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package gie;
4 | option java_package = "com.alibaba.graphscope.proto.schema";
5 |
6 | import "schema.proto";
7 |
8 | message GraphTopologyPartitionStrategy {
9 | enum VertexPartitionStrategy {
10 | VPS_ALL = 0; // a vertex is replicated in all partitions
11 | VPS_ONE = 1; // Edge-Cut, a vertex is distributed to one partition
12 | VPS_FOLLOW_EDGE = 2; // Vertex-Cut, a vertex is distributed to the partitions where its edge resides, i.e. for query 'g.V(id)', we need broadcast to find all edges first and then filter out the vertex
13 | }
14 |
15 | enum EdgePartitionStrategy {
16 | EPS_ALL = 0; // an edge is replicated in all partitions
17 | EPS_ONE = 1; // Vertex-Cut, an edge is distributed to one partition
18 | EPS_FOLLOW_SRC = 2; // Edge-Cut, an edge is distributed to the partition where its source vertex resides
19 | EPS_FOLLOW_DST = 3; // Edge-Cut, an edge is distributed to the partition where its dst vertex resides
20 | EPS_FOLLOW_BOTH = 4; // Edge-Cut, an edge is distributed to the partitions where its src or dst vertices reside
21 | }
22 |
23 | // Index Strategy to lookup edges by vertex
24 | enum VertexToEdgeIndexStrategy {
25 | VTE_NONE = 0; // no indexing, i.e. Vertex-Cut
26 | VTE_INDEX_SRC = 1; // indexing based on the source vertex
27 | VTE_INDEX_DST = 2; // indexing based on the dst vertex
28 | VTE_INDEX_BOTH = 3; // indexing based on both the src and dst vertices
29 | }
30 |
31 | message AllReplicate {
32 | // VertexPartitionStrategy = ALL
33 | // EdgePartitionStrategy = ALL
34 | VertexToEdgeIndexStrategy index_strategy = 1;
35 | }
36 |
37 | message VertexCut {
38 | // partition edges first, then place vertices automatically
39 | }
40 |
41 | message EdgeCut {
42 | // partition vertices first using MAP_TO_ONE strategy,
43 | // then place edges with certain placement strategy
44 |
45 | // VertexPartitionStrategy = ONE
46 | EdgePartitionStrategy edge_partition_strategy = 1;
47 | VertexToEdgeIndexStrategy edge_index_strategy = 2;
48 | }
49 |
50 | message AdvancedEdgeCut {
51 | message VertexTypePairEdgePartitionStrategy {
52 | uint32 src_type = 1;
53 | uint32 dst_type = 2;
54 | EdgePartitionStrategy edge_partition_strategy = 3;
55 | }
56 |
57 | message VertexTypePairEdgeIndexStrategy {
58 | uint32 src_type = 1;
59 | uint32 dst_type = 2;
60 | VertexToEdgeIndexStrategy edge_index_strategy = 3;
61 | }
62 |
63 | message VertexTypePairEdgePartitionStrategyArray {
64 | repeated VertexTypePairEdgePartitionStrategy vertex_type_pair_edge_partition_strategy = 1;
65 | }
66 |
67 | message VertexTypePairEdgeIndexStrategyArray {
68 | repeated VertexTypePairEdgeIndexStrategy vertex_type_pair_edge_index_strategy = 1;
69 | }
70 |
71 | map vertex_type_to_partition_strategy = 1;
72 | map edge_type_to_partition_strategy = 2;
73 | map edge_type_to_index_strategy = 3;
74 | }
75 |
76 | oneof item {
77 | AllReplicate replicate = 1;
78 | EdgeCut edge_cut = 2;
79 | VertexCut vertex_cut = 3;
80 | AdvancedEdgeCut advanced_edge_cut = 4;
81 | }
82 | }
83 |
84 | message GraphPropertyPlacementStrategy {
85 | // This strategy assumes that properties are always distributed along with the topology of the vertices/edges.
86 | // Other strategies, i.e., properties are not distributed along with the topology, are not currently being considered.
87 | enum PropertyPlacementStrategy {
88 | PPS_UNDEFINED = 0;
89 | // Properties exist only in one of partitions (i.e., the master node in GRIN) where the vertex/edge topology resides.
90 | // i.e., In EdgeCut, the vertex properties exist only once in the partition where the vertex topology resides, we consider this case as 'PPS_ON_MASTER'.
91 | PPS_ON_MASTER = 1;
92 | // Properties exist in each partition where the vertex/edge topology resides.
93 | // i.e., In EdgeCut, the edge properties exist in each partition where the edge topology resides, we consider this case as 'PPS_ON_MASTER_N_MIRROR'.
94 | PPS_ON_MASTER_N_MIRROR = 2;
95 | }
96 |
97 | message AllReplicatePropertyPlacement {
98 | PropertyPlacementStrategy all_replicate_vertex_property_placement_strategy = 1;
99 | PropertyPlacementStrategy all_replicate_edge_property_placement_strategy = 2;
100 | }
101 |
102 | // Combine the EdgeCut and AdvancedEdgeCut partition strategies.
103 | message EdgeCutPropertyPlacement {
104 | PropertyPlacementStrategy all_replicate_vertex_property_placement_strategy = 1;
105 | PropertyPlacementStrategy edge_cut_vertex_property_placement_strategy = 2;
106 | PropertyPlacementStrategy edge_cut_edge_property_placement_strategy = 3;
107 | }
108 |
109 | message VertexCutPropertyPlacement {
110 | // property placement in VertexCut is not considered currently.
111 | }
112 |
113 | oneof item {
114 | AllReplicatePropertyPlacement all_replicate_property_placement = 1;
115 | EdgeCutPropertyPlacement edge_cut_property_placement = 2;
116 | VertexCutPropertyPlacement vertex_cut_property_placement = 3;
117 | }
118 | }
119 |
120 | message GraphPartitionStrategy {
121 | GraphTopologyPartitionStrategy topology_partition = 1;
122 | GraphPropertyPlacementStrategy property_placement = 2;
123 | }
124 |
--------------------------------------------------------------------------------
/proto/gie_data_model/schema.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package gie;
4 | option java_package = "com.alibaba.graphscope.proto.schema";
5 |
6 | import "data_type.proto";
7 |
8 | message Property {
9 | uint32 property_id = 1;
10 | string property_name = 2;
11 | StorageDataType property_type = 3;
12 | string comment = 4; // description of the property
13 | }
14 |
15 | message VertexType {
16 | uint32 type_id = 1;
17 | string type_name = 2;
18 | repeated Property properties = 3;
19 | repeated uint32 primary_key_ids = 4;
20 | string comment = 5; // description of the vertex type
21 | }
22 |
23 | message EdgeType {
24 | enum Relation {
25 | MANY_TO_MANY = 0;
26 | MANY_TO_ONE = 1;
27 | ONE_TO_MANY = 2;
28 | ONE_TO_ONE = 3;
29 | }
30 | message VertexTypePairRelation {
31 | uint32 src_type_id = 1;
32 | uint32 dst_type_id = 2;
33 | Relation relation = 3;
34 | }
35 | uint32 type_id = 1;
36 | string type_name = 2;
37 | repeated Property properties = 3;
38 | repeated uint32 primary_key_ids = 4;
39 | repeated VertexTypePairRelation vertex_type_pair_relations = 5;
40 | string comment = 6; // description of the edge type
41 | }
42 |
43 | message Schema {
44 | repeated VertexType vertex_types = 1;
45 | repeated EdgeType edge_types = 2;
46 | }
47 |
--------------------------------------------------------------------------------
/proto/gie_data_model/statistics.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package gie;
4 | option java_package = "com.alibaba.graphscope.proto.schema";
5 |
6 | message VertexTypeStatistics {
7 | uint32 vertex_type_id = 1;
8 | uint64 num_vertices = 2;
9 | }
10 |
11 | message EdgeTypeStatistics {
12 | message EntityPairStatistics {
13 | uint32 src_type_id = 1;
14 | uint32 dst_type_id = 2;
15 | uint64 num_edges = 3;
16 | }
17 | uint32 edge_type_id = 1;
18 | repeated EntityPairStatistics entity_pair_statistics = 2;
19 | }
20 |
21 | message Statistics {
22 | string snapshot_id = 1;
23 |
24 | uint32 num_partitions = 2;
25 | uint64 num_vertices = 3;
26 | uint64 num_edges = 4;
27 |
28 | repeated VertexTypeStatistics vertex_type_statistics = 5;
29 | repeated EdgeTypeStatistics edge_type_statistics = 6;
30 | }
31 |
--------------------------------------------------------------------------------
/proto/grin_schema/data_type.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package grin;
4 | option java_package = "com.alibaba.graphscope.proto.grin_schema";
5 |
6 | enum DataType {
7 | DT_ANY = 0;
8 | DT_SIGNED_INT32 = 1;
9 | DT_UNSIGNED_INT32 = 2;
10 | DT_SIGNED_INT64 = 3;
11 | DT_UNSIGNED_INT64 = 4;
12 | DT_FLOAT = 5;
13 | DT_DOUBLE = 6;
14 | DT_STRING = 7;
15 | DT_DATE = 8;
16 | DT_TIME = 9;
17 | DT_TIMESTAMP = 10;
18 | DT_FLOAT_ARRAY = 11;
19 | }
20 |
21 |
22 | message StorageDataType {
23 | DataType datatype = 1;
24 | bool nullable = 2;
25 | }
26 |
--------------------------------------------------------------------------------
/proto/grin_schema/graph.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package grin;
4 | option java_package = "com.alibaba.graphscope.proto.grin_schema";
5 |
6 | import "schema.proto";
7 | import "partition.proto";
8 |
9 | enum ExternalIDType {
10 | UNSUPPORTED = 0;
11 | INT64 = 1;
12 | STRING = 2;
13 | }
14 |
15 | message Graph {
16 | string uri = 1;
17 | Schema schema = 2;
18 | Partition partition = 3;
19 | ExternalIDType external_id_type = 4;
20 | }
--------------------------------------------------------------------------------
/proto/grin_schema/partition.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package grin;
4 | option java_package = "com.alibaba.graphscope.proto.grin_schema";
5 |
6 | import "schema.proto";
7 |
8 | message PartitionStrategy {
9 | /**
10 | * Given a partition P that divides the original graph G into p partitions,
11 | * let V_i and E_i represent the sets of vertices and edges, respectively,
12 | * in partition i (where i = 1, 2, ..., p in P).
13 | * Correspondingly, let V_i^m and E_i^m represent the master sets of vertices
14 | * and edges, respectively, in partition i (where i = 1, 2, ..., p in P).
15 | *
16 | * P is considered valid if it satisfies the following conditions:
17 | * 1. V_i^m is a subset of V_i.
18 | * 2. E_i^m is a subset of E_i.
19 | * 3. The sets V_i^m are disjoint and their union is V.
20 | * 4. The sets E_i^m are disjoint and their union is E.
21 | * Consequently, we refer to the vertices in V_i^m as master vertices in partition i,
22 | * and the vertices in V_i - V_i^m as mirror vertices.
23 | * Similarly, we have master edges and mirror edges.
24 | *
25 | * Moreover, a partition strategy is defined as the process through which
26 | * V_i^m, E_i^m, V_i, and E_i are computed.
27 | * A partition P is said to follow a particular partition strategy
28 | * if the partition can be computed using the defined process.
29 | * This means that a graph partition P may follow multiple partition strategies.
30 | */
31 |
32 | message EdgeCut {
33 | /**
34 | * The edge cut partition strategy begins by assigning each vertex,
35 | * denoted as v, in the set V to a single partition.
36 | * This initial assignment results in the set V_i^m.
37 | * Next, for each partition i, we place the edges of E(V_i^m) into partition i.
38 | * Afterwards, we apply the cut edge placement strategies to place the cut edges,
39 | * which are edges with endpoints in different partitions, into their respective partitions.
40 | * This step generates the set E_i.
41 | * It is important to note that if the strategy does not involve replicating the cut edges,
42 | * then E_i^m will be equal to E_i.
43 | * However, if the cut edges are being replicated, then each replicated cut edge
44 | * is assigned a master partition to build the set E_i^m.
45 | * Finally, by letting V_i equal the union of V(E_i) and V_i^m,
46 | * we obtain the final partition.
47 | */
48 |
49 | enum DirectedEdgePlacementStrategy {
50 | // Each edge is placed to the partition of its source vertex
51 | DEPS_TO_SRC = 0;
52 | // Each edge is placed to the partition of its destination vertex
53 | DEPS_TO_DST = 1;
54 | }
55 |
56 | message DirectedEdgePlacementStrategies {
57 | repeated DirectedEdgePlacementStrategy cut_edge_placement_strategies = 1;
58 | }
59 |
60 | enum UndirectedEdgePlacementStrategy {
61 | // Each edge is placed to the lower partition of its endpoints
62 | UEPS_TO_LOWER = 0;
63 | // Each edge is placed to the higher partition of its endpoints
64 | UEPS_TO_HIGHER = 1;
65 | }
66 |
67 | message UndirectedEdgePlacementStrategies {
68 | repeated UndirectedEdgePlacementStrategy cut_edge_placement_strategies = 1;
69 | }
70 |
71 | oneof item {
72 | DirectedEdgePlacementStrategies directed_cut_edge_placement_strategies = 1;
73 | UndirectedEdgePlacementStrategies undirected_cut_edge_placement_strategies = 2;
74 | }
75 | }
76 |
77 | message VertexCut {
78 | /**
79 | * The vertex cut partition strategy starts by assigning each edge e in E
80 | * to a single partition, resulting in E_i^m.
81 | * We then have E_i = E_i^m and V_i = V(E_i).
82 | * Next, for each zero-degree vertex z, we assign a master partition to that vertex.
83 | * Finally, for each vertex v that appears in multiple V_i, we assign a master
84 | * partition to that vertex to create V_i^m, completing the final partition.
85 | */
86 | }
87 |
88 | oneof item {
89 | EdgeCut edge_cut = 1;
90 | VertexCut vertex_cut = 2;
91 | }
92 | }
93 |
94 | message UniversalVertices {
95 | /**
96 | * Universal vertices, denoted as U, are replicated to all partitions.
97 | * Additionally, the edges between them, denoted as E(U),
98 | * are also replicated to all partitions, and we call them universal edges.
99 | * The process begins by selecting U before the partition. This involves
100 | * removing U from V and removing E(U) and CE(U, V) from E, where CE(U, V)
101 | * represents the cross edges between U and V.
102 | * Next, the remaining vertices and edges are partitioned.
103 | * Following this, each cross edge e in CE(U, V) is placed based on the cross
104 | * edge placement strategy, and E_i is updated accordingly.
105 | * If replication is involved during the placement process, a master partition
106 | * is assigned to each cross edge, and E_i^m is updated.
107 | * Finally, the resulting partition is obtained.
108 | */
109 | enum EdgePlacementStrategy {
110 | EPS_TO_MASTER = 0;
111 | EPS_TO_MIRROR = 1;
112 | EPS_TO_UNIVERSAL = 2;
113 | }
114 |
115 | repeated uint32 universal_vertex_type_ids = 1;
116 | repeated EdgePlacementStrategy cross_edge_placement_strategies = 2;
117 | }
118 |
119 | enum SparseIndexStrategy {
120 | SIS_NO_INDEX = 0;
121 | // The Compressed Sparse Row Storage
122 | SIS_CSR = 1;
123 | // The Compressed Sparse Column Storage
124 | SIS_CSC = 2;
125 | // The Coordinate Storage
126 | SIS_COO = 3;
127 | }
128 |
129 | enum PropertyPlacementStrategy {
130 | // Property is placed on master entities
131 | PPS_ON_MASTER = 0;
132 | // Property is placed on mirror entities
133 | PPS_ON_MIRROR = 1;
134 | // Property is placed on universal entities
135 | PPS_ON_UNIVERSAL = 2;
136 |
137 | // Property is split on master and mirror entities
138 | PPS_SPLIT_MASTER_MIRROR = 3;
139 | // Property is split on universal entities
140 | PPS_SPLIT_UNIVERSAL = 4;
141 | }
142 |
143 | message Partition {
144 | repeated PartitionStrategy partition_strategies = 1;
145 | UniversalVertices universal_vertices = 2;
146 |
147 | repeated PropertyPlacementStrategy vertex_property_placement_strategies = 3;
148 | repeated PropertyPlacementStrategy edge_property_placement_strategies = 4;
149 |
150 | repeated SparseIndexStrategy master_vertices_sparse_index_strategies = 5;
151 | repeated SparseIndexStrategy mirror_vertices_sparse_index_strategies = 6;
152 | repeated SparseIndexStrategy universal_vertices_sparse_index_strategies = 7;
153 | }
154 |
--------------------------------------------------------------------------------
/proto/grin_schema/schema.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package grin;
4 | option java_package = "com.alibaba.graphscope.proto.grin_schema";
5 |
6 | import "data_type.proto";
7 |
8 |
9 | message Property {
10 | uint32 property_id = 1;
11 | string property_name = 2;
12 | StorageDataType property_type = 3;
13 | string comment = 4; // description of the property
14 | bool mandatory = 5; // whether this property is mandatory or optional
15 | }
16 |
17 | message VertexType {
18 | uint32 type_id = 1;
19 | string type_name = 2;
20 | repeated Property properties = 3;
21 |
22 | repeated uint32 primary_key_ids = 4; // PK properties must be mandatory
23 | string comment = 5; // description of the vertex type
24 | repeated string labels = 6; // labels of the vertex type
25 | }
26 |
27 | message EdgeType {
28 | enum Relation {
29 | MANY_TO_MANY = 0;
30 | MANY_TO_ONE = 1;
31 | ONE_TO_MANY = 2;
32 | ONE_TO_ONE = 3;
33 | }
34 | message VertexTypePairRelation {
35 | uint32 src_type_id = 1;
36 | uint32 dst_type_id = 2;
37 | Relation relation = 3;
38 | bool src_mandatory = 4; // whether this edge is mandatory or optional to the src vertex
39 | bool dst_mandatory = 5; // whether this edge is mandatory or optional to the dst vertex
40 | }
41 | uint32 type_id = 1;
42 | string type_name = 2;
43 | repeated Property properties = 3;
44 |
45 | repeated uint32 primary_key_ids = 4; // PK properties must be mandatory
46 |
47 | repeated VertexTypePairRelation vertex_type_pair_relations = 5;
48 | string comment = 6; // description of the edge type
49 |
50 | repeated string labels = 7; // labels of the edge type
51 | }
52 |
53 | message Schema {
54 | repeated VertexType vertex_types = 1;
55 | repeated EdgeType edge_types = 2;
56 | }
57 |
--------------------------------------------------------------------------------
/proto/storage.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package grin;
4 |
5 | enum ListRetrieval {
6 | LR_NA = 0;
7 | LR_ARRAY_LIKE = 1;
8 | LR_ITERATOR = 2;
9 | }
10 |
11 | message TopologyFeature {
12 | bool grin_assume_has_directed_graph = 1;
13 | bool grin_assume_has_undirected_graph = 2;
14 | bool grin_assume_has_multi_edge_graph = 3;
15 | bool grin_with_vertex_data = 4;
16 | bool grin_with_edge_data = 5;
17 | repeated ListRetrieval vertex_list_retrievals = 6;
18 | repeated ListRetrieval edge_list_retrievals = 7;
19 | repeated ListRetrieval adjacent_list_retrievals = 8;
20 | }
21 |
22 | message MirrorPartitionListFeature {
23 | bool grin_trait_master_vertex_mirror_partition_list = 1;
24 | bool grin_trait_mirror_vertex_mirror_partition_list = 2;
25 | bool grin_trait_master_edge_mirror_partition_list = 3;
26 | bool grin_trait_mirror_edge_mirror_partition_list = 4;
27 | }
28 |
29 | message PartitionFeature {
30 | bool grin_trait_natural_id_for_partition = 1;
31 | bool grin_enable_vertex_ref = 2;
32 | bool grin_enable_edge_ref = 3;
33 |
34 | MirrorPartitionListFeature mirror_partition_list_feature = 4;
35 |
36 | bool grin_trait_select_master_for_vertex_list = 5;
37 | bool grin_trait_select_partition_for_vertex_list = 6;
38 | bool grin_trait_select_master_for_edge_list = 7;
39 | bool grin_trait_select_partition_for_edge_list = 8;
40 | bool grin_trait_select_master_neighbor_for_adjacent_list = 9;
41 | bool grin_trait_select_neighbor_partition_for_adjacent_list = 10;
42 |
43 | bool grin_trait_fast_vertex_ref = 11;
44 |
45 | bool grin_assume_edge_cut_partition = 12;
46 | bool grin_assume_vertex_cut_partition = 13;
47 | bool grin_with_universal_vertices = 14;
48 | }
49 |
50 | message VertexPropertyFeature {
51 | bool grin_with_vertex_property = 1;
52 | bool grin_with_vertex_property_name = 2;
53 | bool grin_with_vertex_type_name = 3;
54 |
55 | bool grin_enable_vertex_primary_keys = 4;
56 |
57 | bool grin_trait_natural_id_for_vertex_type = 5;
58 | bool grin_trait_natural_id_for_vertex_property = 6;
59 | }
60 |
61 | message EdgePropertyFeature {
62 | bool grin_with_edge_property = 1;
63 | bool grin_with_edge_property_name = 2;
64 | bool grin_with_edge_type_name = 3;
65 |
66 | bool grin_enable_edge_primary_keys = 4;
67 |
68 | bool grin_trait_natural_id_for_edge_type = 5;
69 | bool grin_trait_natural_id_for_edge_property = 6;
70 | }
71 |
72 | message PropertyFeature {
73 | bool grin_enable_row = 1;
74 | VertexPropertyFeature vertex_property_feature = 2;
75 | EdgePropertyFeature edge_property_feature = 3;
76 |
77 | bool grin_trait_const_value_ptr = 4;
78 | }
79 |
80 | message IndexFeature {
81 | bool grin_with_vertex_label = 1;
82 | bool grin_with_edge_label = 2;
83 |
84 | bool grin_assume_all_vertex_list_sorted = 3;
85 |
86 | bool grin_enable_vertex_internal_id_index = 4;
87 |
88 | bool grin_enable_vertex_pk_index = 5;
89 | bool grin_enable_edge_pk_index = 6;
90 |
91 | bool grin_enable_vertex_external_id_of_int64 = 7;
92 | bool grin_enable_vertex_external_id_of_string = 8;
93 | }
94 |
95 | message CommonFeature {
96 | bool grin_trait_loose_schema = 1;
97 | }
98 |
99 | message PredicateFeature {
100 |
101 | }
102 |
103 | message StorageFeature {
104 | oneof specific_feature {
105 | TopologyFeature topology_feature = 1;
106 | PartitionFeature partition_feature = 2;
107 | PropertyFeature property_feature = 3;
108 | IndexFeature index_feature = 4;
109 | CommonFeature common_feature = 5;
110 | PredicateFeature predicate_feature = 6;
111 | }
112 | }
113 |
114 | message StorageFeatures {
115 | string grin_version = 1;
116 | repeated StorageFeature features = 2;
117 | }
118 |
--------------------------------------------------------------------------------
/rust/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "grin"
3 | version = "0.1.4"
4 | authors = ["dijie"]
5 |
6 | [dependencies]
7 | cfg-if = "0.1"
8 |
9 | [features]
10 | grin_predefine_h_ = []
11 | grin_assume_has_directed_graph = []
12 | grin_assume_has_undirected_graph = []
13 | grin_assume_has_multi_edge_graph = []
14 | grin_with_vertex_data = []
15 | grin_with_edge_data = []
16 | grin_enable_vertex_list = []
17 | grin_enable_vertex_list_array = []
18 | grin_enable_vertex_list_iterator = []
19 | grin_enable_edge_list = []
20 | grin_enable_edge_list_array = []
21 | grin_enable_edge_list_iterator = []
22 | grin_enable_adjacent_list = []
23 | grin_enable_adjacent_list_array = []
24 | grin_enable_adjacent_list_iterator = []
25 | grin_enable_graph_partition = []
26 | grin_assume_edge_cut_partition = []
27 | grin_assume_vertex_cut_partition = []
28 | grin_assume_with_universal_vertices = []
29 | grin_trait_natural_id_for_partition = []
30 | grin_enable_vertex_ref = []
31 | grin_trait_fast_vertex_ref = []
32 | grin_enable_edge_ref = []
33 | grin_trait_master_vertex_mirror_partition_list = []
34 | grin_trait_mirror_vertex_mirror_partition_list = []
35 | grin_trait_master_edge_mirror_partition_list = []
36 | grin_trait_mirror_edge_mirror_partition_list = []
37 | grin_trait_select_master_for_vertex_list = []
38 | grin_trait_select_partition_for_vertex_list = []
39 | grin_trait_select_master_for_edge_list = []
40 | grin_trait_select_partition_for_edge_list = []
41 | grin_trait_select_master_neighbor_for_adjacent_list = []
42 | grin_trait_select_neighbor_partition_for_adjacent_list = []
43 | grin_enable_row = []
44 | grin_trait_const_value_ptr = []
45 | grin_enable_schema = []
46 | grin_trait_property_value_of_float_array = []
47 | grin_with_vertex_property = []
48 | grin_enable_vertex_primary_keys = []
49 | grin_with_edge_property = []
50 | grin_enable_edge_primary_keys = []
51 | grin_with_vertex_label = []
52 | grin_with_edge_label = []
53 | grin_assume_all_vertex_list_sorted = []
54 | grin_enable_vertex_internal_id_index = []
55 | grin_enable_vertex_external_id_of_int64 = []
56 | grin_enable_vertex_external_id_of_string = []
57 | grin_enable_vertex_pk_index = []
58 | grin_enable_edge_pk_index = []
59 | grin_features_enable_v6d = ['grin_assume_has_directed_graph', 'grin_assume_has_undirected_graph', 'grin_assume_has_multi_edge_graph', 'grin_enable_vertex_list', 'grin_enable_vertex_list_array', 'grin_enable_vertex_list_iterator', 'grin_enable_adjacent_list', 'grin_enable_adjacent_list_array', 'grin_enable_adjacent_list_iterator', 'grin_enable_graph_partition', 'grin_assume_edge_cut_partition', 'grin_trait_natural_id_for_partition', 'grin_enable_vertex_ref', 'grin_trait_fast_vertex_ref', 'grin_trait_select_master_for_vertex_list', 'grin_enable_row', 'grin_enable_schema', 'grin_trait_property_value_of_float_array', 'grin_with_vertex_property', 'grin_enable_vertex_primary_keys', 'grin_with_edge_property', 'grin_enable_vertex_internal_id_index', 'grin_enable_vertex_external_id_of_int64', 'grin_enable_vertex_pk_index']
60 | grin_features_enable_gart = ['grin_assume_has_undirected_graph', 'grin_assume_has_multi_edge_graph', 'grin_enable_vertex_list', 'grin_enable_vertex_list_iterator', 'grin_enable_adjacent_list', 'grin_enable_adjacent_list_iterator', 'grin_enable_graph_partition', 'grin_assume_edge_cut_partition', 'grin_trait_natural_id_for_partition', 'grin_enable_vertex_ref', 'grin_trait_fast_vertex_ref', 'grin_trait_select_master_for_vertex_list', 'grin_enable_row', 'grin_trait_const_value_ptr', 'grin_enable_schema', 'grin_trait_property_value_of_float_array', 'grin_with_vertex_property', 'grin_with_edge_property', 'grin_enable_vertex_internal_id_index', 'grin_enable_vertex_external_id_of_int64']
61 | grin_features_enable_graphar = ['grin_assume_has_multi_edge_graph', 'grin_enable_vertex_list', 'grin_enable_vertex_list_array', 'grin_enable_vertex_list_iterator', 'grin_enable_edge_list', 'grin_enable_edge_list_iterator', 'grin_enable_adjacent_list', 'grin_enable_adjacent_list_iterator', 'grin_enable_graph_partition', 'grin_trait_natural_id_for_partition', 'grin_enable_vertex_ref', 'grin_trait_fast_vertex_ref', 'grin_trait_master_vertex_mirror_partition_list', 'grin_trait_mirror_vertex_mirror_partition_list', 'grin_trait_select_master_for_vertex_list', 'grin_trait_select_partition_for_vertex_list', 'grin_enable_row', 'grin_enable_schema', 'grin_with_vertex_property', 'grin_enable_vertex_primary_keys', 'grin_with_edge_property', 'grin_trait_property_value_of_float_array', 'grin_assume_all_vertex_list_sorted', 'grin_enable_vertex_internal_id_index', 'grin_enable_vertex_external_id_of_int64']
62 |
--------------------------------------------------------------------------------
/rust/README.md:
--------------------------------------------------------------------------------
1 | # Rust Codegen
2 |
3 | ## For Rust Users
4 | 1. Install bindgen and enter the rust folder in GRIN repo
5 | 2. Run codegen with storages specified, e.g., `python codegen.py v6d gart`
6 | 3. Use `Cargo.toml` and `grin.rs` in your rust project
7 |
8 | ## For Storage Implementors
9 | 1. Create a header file `grin_{storage}.h` in the rust folder.
10 | 2. Put your null value definitions as comments in the header file.
11 | 3. Use header files from other storages as references.
12 |
--------------------------------------------------------------------------------
/rust/grin_GraphAr.h:
--------------------------------------------------------------------------------
1 | #define GRIN_FEATURES_ENABLE_GRAPHAR
2 | #define GRIN_RUST_CODEGEN
3 |
4 | #include "storage/GraphAr/predefine.h"
5 |
6 | #ifdef GRIN_RUST_CODEGEN
7 | /// GRIN_FEATURES_ENABLE_GRAPHAR
8 | /// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;
9 | /// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();
10 | /// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut();
11 | /// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut();
12 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();
13 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();
14 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut();
15 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();
16 | /// RUST_KEEP pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut();
17 | /// RUST_KEEP pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut();
18 | /// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();
19 | /// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX;
20 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();
21 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;
22 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1;
23 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX;
24 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();
25 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u32::MAX;
26 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();
27 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;
28 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;
29 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX;
30 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();
31 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u32::MAX;
32 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();
33 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;
34 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;
35 | /// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();
36 | /// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;
37 | int __rust_keep_grin_null;
38 | #endif
39 |
--------------------------------------------------------------------------------
/rust/grin_GraphAr.rs:
--------------------------------------------------------------------------------
1 | /* automatically generated by rust-bindgen 0.64.0 */
2 |
3 | pub const true_: u32 = 1;
4 | pub const false_: u32 = 0;
5 | pub const __bool_true_false_are_defined: u32 = 1;
6 | pub const GRIN_NULL_VERTEX_REF: i32 = -1;
7 | pub type wchar_t = ::std::os::raw::c_int;
8 | pub type max_align_t = u128;
9 | pub type GRIN_GRAPH = *mut ::std::os::raw::c_void;
10 | pub type GRIN_VERTEX = *mut ::std::os::raw::c_void;
11 | pub type GRIN_EDGE = *mut ::std::os::raw::c_void;
12 | pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void;
13 | pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void;
14 | pub type GRIN_ADJACENT_LIST = *mut ::std::os::raw::c_void;
15 | pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void;
16 | pub type GRIN_EDGE_LIST = *mut ::std::os::raw::c_void;
17 | pub type GRIN_EDGE_LIST_ITERATOR = *mut ::std::os::raw::c_void;
18 | pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void;
19 | pub type GRIN_PARTITION = ::std::os::raw::c_uint;
20 | pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void;
21 | pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint;
22 | pub type GRIN_VERTEX_REF = ::std::os::raw::c_longlong;
23 | pub type GRIN_VERTEX_TYPE = ::std::os::raw::c_uint;
24 | pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void;
25 | pub type GRIN_VERTEX_PROPERTY = ::std::os::raw::c_uint;
26 | pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void;
27 | pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint;
28 | pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint;
29 | pub type GRIN_EDGE_TYPE = ::std::os::raw::c_uint;
30 | pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void;
31 | pub type GRIN_EDGE_PROPERTY = ::std::os::raw::c_uint;
32 | pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void;
33 | pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint;
34 | pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint;
35 | pub type GRIN_ROW = *mut ::std::os::raw::c_void;
36 | extern "C" {
37 | #[doc = " GRIN_FEATURES_ENABLE_GRAPHAR\n RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;\n RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1;\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;"]
38 | pub static mut __rust_keep_grin_null: ::std::os::raw::c_int;
39 | }
40 |
--------------------------------------------------------------------------------
/rust/grin_all.h:
--------------------------------------------------------------------------------
1 | #define GRIN_FEATURES_ENABLE_ALL
2 | #define GRIN_RUST_CODEGEN
3 |
4 | #include "common/enum_types.h"
5 | #include "template/predefine.h"
6 | #include "topology/adjacentlist.h"
7 | #include "topology/edgelist.h"
8 | #include "topology/structure.h"
9 | #include "topology/vertexlist.h"
10 | #include "partition/partition.h"
11 | #include "partition/reference.h"
12 | #include "partition/topology.h"
13 | #include "property/label.h"
14 | #include "property/primarykey.h"
15 | #include "property/property.h"
16 | #include "property/propertylist.h"
17 | #include "property/row.h"
18 | #include "property/topology.h"
19 | #include "property/type.h"
20 | #include "property/value.h"
21 | #include "index/label.h"
22 | #include "index/order.h"
23 | #include "index/internal_id.h"
24 | #include "index/external_id.h"
25 | #include "index/pk.h"
26 | #include "common/error.h"
27 | #include "common/message.h"
28 |
29 | #ifdef GRIN_RUST_CODEGEN
30 | /// GRIN_FEATURES_ENABLE_ALL
31 | /// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;
32 | /// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();
33 | /// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut();
34 | /// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut();
35 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_DATA: GrinVertexData = std::ptr::null_mut();
36 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();
37 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();
38 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut();
39 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();
40 | /// RUST_KEEP pub const GRIN_NULL_EDGE_DATA: GrinEdgeData = std::ptr::null_mut();
41 | /// RUST_KEEP pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut();
42 | /// RUST_KEEP pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut();
43 | /// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();
44 | /// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = std::ptr::null_mut();
45 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();
46 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;
47 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = std::ptr::null_mut();
48 | /// RUST_KEEP pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut();
49 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut();
50 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();
51 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = std::ptr::null_mut();
52 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();
53 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;
54 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;
55 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = std::ptr::null_mut();
56 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();
57 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut();
58 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();
59 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;
60 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;
61 | /// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();
62 | /// RUST_KEEP pub const GRIN_NULL_LABEL: GrinLabel = std::ptr::null_mut();
63 | /// RUST_KEEP pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut();
64 | /// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;
65 | int __rust_keep_grin_null;
66 | #endif
67 |
--------------------------------------------------------------------------------
/rust/grin_gart.h:
--------------------------------------------------------------------------------
1 | #define GRIN_FEATURES_ENABLE_GART
2 | #define GRIN_RUST_CODEGEN
3 |
4 | #include "storage/GART/predefine.h"
5 |
6 | #ifdef GRIN_RUST_CODEGEN
7 | /// GRIN_FEATURES_ENABLE_GART
8 | /// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;
9 | /// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();
10 | /// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX;
11 | /// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = GrinEdge{src: u64::MAX, dst: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX, edata: std::ptr::null_mut()};
12 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();
13 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();
14 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = GrinAdjacentList{v: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX};
15 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();
16 | /// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();
17 | /// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX;
18 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();
19 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;
20 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1;
21 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX;
22 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();
23 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX;
24 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();
25 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;
26 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;
27 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX;
28 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();
29 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX;
30 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();
31 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;
32 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;
33 | /// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();
34 | /// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;
35 | int __rust_keep_grin_null;
36 | #endif
--------------------------------------------------------------------------------
/rust/grin_gart.rs:
--------------------------------------------------------------------------------
1 | /* automatically generated by rust-bindgen 0.64.0 */
2 |
3 | pub const true_: u32 = 1;
4 | pub const false_: u32 = 0;
5 | pub const __bool_true_false_are_defined: u32 = 1;
6 | pub const GRIN_NULL_VERTEX_REF: i32 = -1;
7 | pub type wchar_t = ::std::os::raw::c_int;
8 | pub type max_align_t = u128;
9 | pub type GRIN_GRAPH = *mut ::std::os::raw::c_void;
10 | pub type GRIN_VERTEX = ::std::os::raw::c_ulonglong;
11 | pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void;
12 | pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void;
13 | pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void;
14 | pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void;
15 | pub type GRIN_PARTITION = ::std::os::raw::c_uint;
16 | pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void;
17 | pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint;
18 | pub type GRIN_VERTEX_REF = ::std::os::raw::c_longlong;
19 | pub type GRIN_VERTEX_TYPE = ::std::os::raw::c_uint;
20 | pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void;
21 | pub type GRIN_VERTEX_PROPERTY = ::std::os::raw::c_ulonglong;
22 | pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void;
23 | pub type GRIN_EDGE_TYPE = ::std::os::raw::c_uint;
24 | pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void;
25 | pub type GRIN_EDGE_PROPERTY = ::std::os::raw::c_ulonglong;
26 | pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void;
27 | pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint;
28 | pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint;
29 | pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint;
30 | pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint;
31 | #[repr(C)]
32 | #[derive(Debug, Copy, Clone)]
33 | pub struct GRIN_EDGE {
34 | pub src: GRIN_VERTEX,
35 | pub dst: GRIN_VERTEX,
36 | pub dir: ::std::os::raw::c_uint,
37 | pub etype: GRIN_EDGE_TYPE,
38 | pub edata: *mut ::std::os::raw::c_char,
39 | }
40 | #[repr(C)]
41 | #[derive(Debug, Copy, Clone)]
42 | pub struct GRIN_ADJACENT_LIST {
43 | pub v: GRIN_VERTEX,
44 | pub dir: ::std::os::raw::c_uint,
45 | pub etype: GRIN_EDGE_TYPE,
46 | }
47 | pub type GRIN_ROW = *mut ::std::os::raw::c_void;
48 | extern "C" {
49 | #[doc = " GRIN_FEATURES_ENABLE_GART\n RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;\n RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = GrinEdge{src: u64::MAX, dst: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX, edata: std::ptr::null_mut()};\n RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = GrinAdjacentList{v: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX};\n RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1;\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;"]
50 | pub static mut __rust_keep_grin_null: ::std::os::raw::c_int;
51 | }
52 |
--------------------------------------------------------------------------------
/rust/grin_v6d.h:
--------------------------------------------------------------------------------
1 | #define GRIN_FEATURES_ENABLE_V6D
2 | #define GRIN_RUST_CODEGEN
3 |
4 | #include "storage/v6d/predefine.h"
5 |
6 | #ifdef GRIN_RUST_CODEGEN
7 | /// GRIN_FEATURES_ENABLE_V6D
8 | /// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;
9 | /// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();
10 | /// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX;
11 | /// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = GrinEdge{src: u64::MAX, dst: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX, eid: u64::MAX};
12 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();
13 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();
14 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut();
15 | /// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();
16 | /// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();
17 | /// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX;
18 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();
19 | /// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;
20 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1;
21 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX;
22 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();
23 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX;
24 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();
25 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;
26 | /// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;
27 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX;
28 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();
29 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX;
30 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();
31 | /// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;
32 | /// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;
33 | /// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();
34 | /// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;
35 | int __rust_keep_grin_null;
36 | #endif
37 |
--------------------------------------------------------------------------------
/rust/grin_v6d.rs:
--------------------------------------------------------------------------------
1 | /* automatically generated by rust-bindgen 0.64.0 */
2 |
3 | pub const true_: u32 = 1;
4 | pub const false_: u32 = 0;
5 | pub const __bool_true_false_are_defined: u32 = 1;
6 | pub const GRIN_NULL_VERTEX_REF: i32 = -1;
7 | pub type wchar_t = ::std::os::raw::c_int;
8 | pub type max_align_t = u128;
9 | pub type GRIN_GRAPH = *mut ::std::os::raw::c_void;
10 | pub type GRIN_VERTEX = ::std::os::raw::c_ulonglong;
11 | #[repr(C)]
12 | #[derive(Debug, Copy, Clone)]
13 | pub struct GRIN_EDGE {
14 | pub src: GRIN_VERTEX,
15 | pub dst: GRIN_VERTEX,
16 | pub dir: ::std::os::raw::c_uint,
17 | pub etype: ::std::os::raw::c_uint,
18 | pub eid: ::std::os::raw::c_ulonglong,
19 | }
20 | pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void;
21 | pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void;
22 | pub type GRIN_ADJACENT_LIST = *mut ::std::os::raw::c_void;
23 | pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void;
24 | pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void;
25 | pub type GRIN_PARTITION = ::std::os::raw::c_uint;
26 | pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void;
27 | pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint;
28 | pub type GRIN_VERTEX_REF = ::std::os::raw::c_longlong;
29 | pub type GRIN_VERTEX_PROPERTY = ::std::os::raw::c_ulonglong;
30 | pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void;
31 | pub type GRIN_EDGE_PROPERTY = ::std::os::raw::c_ulonglong;
32 | pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void;
33 | pub type GRIN_VERTEX_TYPE = ::std::os::raw::c_uint;
34 | pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void;
35 | pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint;
36 | pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint;
37 | pub type GRIN_EDGE_TYPE = ::std::os::raw::c_uint;
38 | pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void;
39 | pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint;
40 | pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint;
41 | pub type GRIN_ROW = *mut ::std::os::raw::c_void;
42 | extern "C" {
43 | #[doc = " GRIN_FEATURES_ENABLE_V6D\n RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED;\n RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = GrinEdge{src: u64::MAX, dst: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX, eid: u64::MAX};\n RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1;\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX;\n RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;"]
44 | pub static mut __rust_keep_grin_null: ::std::os::raw::c_int;
45 | }
46 |
--------------------------------------------------------------------------------
/scripts/check_predefine.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from pathlib import Path
4 |
5 | def get_macros(fn, prefix='#define'):
6 | with open(fn) as f:
7 | lines = f.readlines()
8 | macros = []
9 | for line in lines:
10 | if (line.startswith(prefix) and
11 | not any (x in line for x in ['NULL', 'PREDEFINE', '__cplusplus'])):
12 | macros.append(line.split()[1])
13 | return macros
14 |
15 | if __name__ == '__main__':
16 | correct = set(get_macros(Path('..') / 'template' / 'features.h'))
17 | for s in sys.argv[1:]:
18 | for p in ['#define', '#ifdef']:
19 | x = set(get_macros(Path('..') / 'storage' / s / 'predefine.h', p))
20 | if x - correct:
21 | print(s, p, x - correct)
22 | else:
23 | print(s, p, 'OK')
--------------------------------------------------------------------------------
/scripts/enabled_apis.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from pathlib import Path
4 |
5 | def get_macros(fn):
6 | with open(fn) as f:
7 | lines = f.readlines()
8 | macros = []
9 | for line in lines:
10 | if line.startswith('#define') and 'NULL' not in line:
11 | macros.append(line.split()[1])
12 | return macros
13 |
14 | def valid(expr, macros):
15 | expr = expr.strip()
16 | if expr == '*':
17 | return True
18 | elif '||' in expr:
19 | segs = expr.split('||')
20 | for s in segs:
21 | if valid(s, macros):
22 | return True
23 | return False
24 | elif '&&' in expr:
25 | segs = expr.split('&&')
26 | for s in segs:
27 | if not valid(s, macros):
28 | return False
29 | return True
30 | elif expr[0] == '!':
31 | if valid(expr[1:], macros):
32 | return False
33 | return True
34 | elif expr.startswith('defined('):
35 | return valid(expr[len('defined('): -1], macros)
36 | elif expr.startswith('GRIN'):
37 | return (expr in macros)
38 | else:
39 | assert False, expr
40 |
41 | def get_apis_with_expr(fn):
42 | with open(fn) as f:
43 | lines = f.readlines()
44 |
45 | expr = '*'
46 | for line in lines[26:]:
47 | if line.startswith('#ifdef'):
48 | assert expr == '*', 'nested macros'
49 | expr = line.split(' ')[1].strip()
50 | elif line.startswith('#if '):
51 | assert expr == '*', 'nested macros'
52 | expr = line.strip()[4:]
53 | elif line.startswith('#endif'):
54 | expr = '*'
55 | elif line.startswith('#ifndef'):
56 | assert expr == '*', 'nested macros'
57 | expr = '!'+line.split(' ')[1].strip()
58 | elif not line.startswith((' ', '*/', '}', '/', '#', 'type')):
59 | if line.strip():
60 | yield line.strip(), expr
61 |
62 | def get_impl_apis(fn):
63 | with open(fn) as f:
64 | lines = f.readlines()
65 |
66 | apis = []
67 | for line in lines[13:]:
68 | if not line.startswith(('#', ' ', '}', '/')):
69 | if line.strip():
70 | apis.append(line.strip()[:line.find('(')])
71 | return apis
72 |
73 | def get_enabled_apis(prefix, macros, target):
74 | for item in Path(prefix).rglob('*'):
75 | if item.is_file():
76 | apis = []
77 | for api, expr in get_apis_with_expr(item):
78 | if valid(expr, macros):
79 | apis.append(api[:api.find('(')])
80 | if apis:
81 | fn = str(item)
82 | fn = target + fn[len(prefix):-2] + '.cc'
83 | impls = get_impl_apis(fn)
84 | if set(apis) != set(impls):
85 | print(item)
86 | print('unimplemented apis:', set(apis) - set(impls))
87 | print('unnecessary apis:', set(impls) - set(apis))
88 | print()
89 |
90 |
91 | if __name__ == '__main__':
92 | macros = get_macros(sys.argv[1])
93 | get_enabled_apis(sys.argv[2], macros, sys.argv[3])
94 |
--------------------------------------------------------------------------------
/storage/GART/predefine.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | /**
17 | * @file predefine.h
18 | * @brief This template file consists of four parts:
19 | * 1. The predefined enumerate types of GRIN, which should NOT be modified.
20 | * 2. The supported macros which should be specified by storage implementors
21 | * based on storage features.
22 | * 3. The typedefs of the enabled handles. This should be specified by storage.
23 | * 4. The corresponding null values of the enabled handles. This should be
24 | * specified by storage.
25 | */
26 |
27 | #ifndef GRIN_PREDEFINE_H_
28 | #define GRIN_PREDEFINE_H_
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | #include
35 | #include
36 |
37 | /* 1. Define supported macros based on storage features */
38 | // Topology
39 | #define GRIN_ASSUME_HAS_DIRECTED_GRAPH
40 | #define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH
41 | #define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
42 | #define GRIN_ENABLE_VERTEX_LIST
43 | #define GRIN_ENABLE_VERTEX_LIST_ITERATOR
44 | #define GRIN_ENABLE_ADJACENT_LIST
45 | #define GRIN_ENABLE_ADJACENT_LIST_ITERATOR
46 | // Partition
47 | #define GRIN_ENABLE_GRAPH_PARTITION
48 | #define GRIN_ASSUME_EDGE_CUT_PARTITION
49 | #define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
50 | #define GRIN_ENABLE_VERTEX_REF
51 | #define GRIN_TRAIT_FAST_VERTEX_REF
52 | #define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST
53 | // Property
54 | #define GRIN_ENABLE_ROW
55 | #define GRIN_TRAIT_CONST_VALUE_PTR
56 | #define GRIN_ENABLE_SCHEMA
57 | #define GRIN_TRAIT_PROPERTY_VALUE_OF_FLOAT_ARRAY
58 | #define GRIN_WITH_VERTEX_PROPERTY
59 | #define GRIN_WITH_EDGE_PROPERTY
60 | // Index
61 | #define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX
62 | #define GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_INT64
63 |
64 | /* Define the handles using typedef */
65 | typedef void* GRIN_GRAPH;
66 | typedef unsigned long long int GRIN_VERTEX;
67 |
68 | #ifdef GRIN_WITH_VERTEX_DATA
69 | typedef void* GRIN_VERTEX_DATA;
70 | #endif
71 |
72 | #ifdef GRIN_ENABLE_VERTEX_LIST
73 | typedef void* GRIN_VERTEX_LIST;
74 | #endif
75 |
76 | #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR
77 | typedef void* GRIN_VERTEX_LIST_ITERATOR;
78 | #endif
79 |
80 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR
81 | typedef void* GRIN_ADJACENT_LIST_ITERATOR;
82 | #endif
83 |
84 | #ifdef GRIN_WITH_EDGE_DATA
85 | typedef void* GRIN_EDGE_DATA;
86 | #endif
87 |
88 | #ifdef GRIN_ENABLE_EDGE_LIST
89 | typedef void* GRIN_EDGE_LIST;
90 | #endif
91 |
92 | #ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR
93 | typedef void* GRIN_EDGE_LIST_ITERATOR;
94 | #endif
95 |
96 | #ifdef GRIN_ENABLE_GRAPH_PARTITION
97 | typedef void* GRIN_PARTITIONED_GRAPH;
98 | typedef unsigned GRIN_PARTITION;
99 | typedef void* GRIN_PARTITION_LIST;
100 | #endif
101 |
102 | #ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
103 | typedef unsigned GRIN_PARTITION_ID;
104 | #endif
105 |
106 | #ifdef GRIN_ENABLE_VERTEX_REF
107 | typedef long long int GRIN_VERTEX_REF;
108 | #endif
109 |
110 | #ifdef GRIN_ENABLE_EDGE_REF
111 | typedef void* GRIN_EDGE_REF;
112 | #endif
113 |
114 | #ifdef GRIN_WITH_VERTEX_PROPERTY
115 | typedef unsigned GRIN_VERTEX_TYPE;
116 | typedef void* GRIN_VERTEX_TYPE_LIST;
117 | typedef unsigned long long int GRIN_VERTEX_PROPERTY;
118 | typedef void* GRIN_VERTEX_PROPERTY_LIST;
119 | #endif
120 |
121 | #ifdef GRIN_WITH_EDGE_PROPERTY
122 | typedef unsigned GRIN_EDGE_TYPE;
123 | typedef void* GRIN_EDGE_TYPE_LIST;
124 | typedef unsigned long long int GRIN_EDGE_PROPERTY;
125 | typedef void* GRIN_EDGE_PROPERTY_LIST;
126 | #endif
127 |
128 | #ifdef GRIN_ENABLE_SCHEMA
129 | typedef unsigned GRIN_VERTEX_TYPE_ID;
130 | typedef unsigned GRIN_VERTEX_PROPERTY_ID;
131 | typedef unsigned GRIN_EDGE_TYPE_ID;
132 | typedef unsigned GRIN_EDGE_PROPERTY_ID;
133 | #endif
134 |
135 | typedef struct GRIN_EDGE {
136 | GRIN_VERTEX src;
137 | GRIN_VERTEX dst;
138 | unsigned dir;
139 | GRIN_EDGE_TYPE etype;
140 | char* edata;
141 | } GRIN_EDGE;
142 |
143 | #ifdef GRIN_ENABLE_ADJACENT_LIST
144 | typedef struct GRIN_ADJACENT_LIST {
145 | GRIN_VERTEX v;
146 | unsigned dir;
147 | GRIN_EDGE_TYPE etype;
148 | } GRIN_ADJACENT_LIST;
149 | #endif
150 |
151 |
152 | #ifdef GRIN_ENABLE_ROW
153 | typedef void* GRIN_ROW;
154 | #endif
155 |
156 | #if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL)
157 | typedef void* GRIN_LABEL;
158 | typedef void* GRIN_LABEL_LIST;
159 | #endif
160 |
161 | /* Define invalid values for returns of handles */
162 | #define GRIN_NULL_GRAPH NULL
163 | #define GRIN_NULL_VERTEX (unsigned long long int) ~0
164 | #define GRIN_NULL_VERTEX_LIST NULL
165 | #define GRIN_NULL_VERTEX_LIST_ITERATOR NULL
166 | #define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL
167 | #define GRIN_NULL_PARTITIONED_GRAPH NULL
168 | #define GRIN_NULL_PARTITION (unsigned) ~0
169 | #define GRIN_NULL_PARTITION_LIST NULL
170 | #define GRIN_NULL_PARTITION_ID (unsigned) ~0
171 | #define GRIN_NULL_VERTEX_REF -1
172 | #define GRIN_NULL_VERTEX_TYPE (unsigned) ~0
173 | #define GRIN_NULL_VERTEX_TYPE_LIST NULL
174 | #define GRIN_NULL_VERTEX_PROPERTY (unsigned long long int) ~0
175 | #define GRIN_NULL_VERTEX_PROPERTY_LIST NULL
176 | #define GRIN_NULL_VERTEX_TYPE_ID (unsigned) ~0
177 | #define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned) ~0
178 | #define GRIN_NULL_EDGE_TYPE (unsigned) ~0
179 | #define GRIN_NULL_EDGE_TYPE_LIST NULL
180 | #define GRIN_NULL_EDGE_PROPERTY (unsigned long long int) ~0
181 | #define GRIN_NULL_EDGE_PROPERTY_LIST NULL
182 | #define GRIN_NULL_EDGE_TYPE_ID (unsigned) ~0
183 | #define GRIN_NULL_EDGE_PROPERTY_ID (unsigned) ~0
184 | #define GRIN_NULL_ROW NULL
185 | #define GRIN_NULL_SIZE (unsigned) ~0
186 | #define GRIN_NULL_NAME NULL
187 | #define GRIN_NULL_EDGE \
188 | GRIN_EDGE { \
189 | GRIN_NULL_VERTEX, GRIN_NULL_VERTEX, BOTH, GRIN_NULL_EDGE_TYPE_ID, NULL \
190 | }
191 | #define GRIN_NULL_ADJACENT_LIST \
192 | GRIN_ADJACENT_LIST { GRIN_NULL_VERTEX, BOTH, GRIN_NULL_EDGE_TYPE_ID }
193 |
194 | #ifdef __cplusplus
195 | }
196 | #endif
197 |
198 | #endif // GRIN_PREDEFINE_H_
--------------------------------------------------------------------------------
/storage/GraphAr/predefine.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | /**
17 | * @file predefine.h
18 | * @brief This template file consists of four parts:
19 | * 1. The predefined enumerate types of GRIN, which should NOT be modified.
20 | * 2. The supported macros which should be specified by storage implementors
21 | * based on storage features.
22 | * 3. The typedefs of the enabled handles. This should be specified by storage.
23 | * 4. The corresponding null values of the enabled handles. This should be
24 | * specified by storage.
25 | */
26 |
27 | #ifdef __cplusplus
28 | extern "C" {
29 | #endif
30 |
31 | #include
32 | #include
33 |
34 | /* 1. Define supported macros based on storage features */
35 | // Topology
36 | #define GRIN_ASSUME_HAS_DIRECTED_GRAPH
37 | #define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
38 | #define GRIN_ENABLE_VERTEX_LIST
39 | #define GRIN_ENABLE_VERTEX_LIST_ARRAY
40 | #define GRIN_ENABLE_VERTEX_LIST_ITERATOR
41 | #define GRIN_ENABLE_EDGE_LIST
42 | #define GRIN_ENABLE_EDGE_LIST_ITERATOR
43 | #define GRIN_ENABLE_ADJACENT_LIST
44 | #define GRIN_ENABLE_ADJACENT_LIST_ITERATOR
45 | // Partition
46 | #define GRIN_ENABLE_GRAPH_PARTITION
47 | #define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
48 | #define GRIN_ENABLE_VERTEX_REF
49 | #define GRIN_TRAIT_FAST_VERTEX_REF
50 | #define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST
51 | #define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST
52 | #define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST
53 | #define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST
54 | // Property
55 | #define GRIN_ENABLE_ROW
56 | #define GRIN_ENABLE_SCHEMA
57 | #define GRIN_WITH_VERTEX_PROPERTY
58 | #define GRIN_ENABLE_VERTEX_PRIMARY_KEYS
59 | #define GRIN_WITH_EDGE_PROPERTY
60 | #define GRIN_TRAIT_PROPERTY_VALUE_OF_FLOAT_ARRAY
61 | // Index
62 | #define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
63 | #define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX
64 | #define GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_INT64
65 |
66 | /* 2. Define the handles using typedef */
67 | typedef void* GRIN_GRAPH;
68 | typedef void* GRIN_VERTEX;
69 | typedef void* GRIN_EDGE;
70 |
71 | #ifdef GRIN_WITH_VERTEX_DATA
72 | typedef void* GRIN_VERTEX_DATA;
73 | #endif
74 |
75 | #ifdef GRIN_ENABLE_VERTEX_LIST
76 | typedef void* GRIN_VERTEX_LIST;
77 | #endif
78 |
79 | #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR
80 | typedef void* GRIN_VERTEX_LIST_ITERATOR;
81 | #endif
82 |
83 | #ifdef GRIN_ENABLE_ADJACENT_LIST
84 | typedef void* GRIN_ADJACENT_LIST;
85 | #endif
86 |
87 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR
88 | typedef void* GRIN_ADJACENT_LIST_ITERATOR;
89 | #endif
90 |
91 | #ifdef GRIN_WITH_EDGE_DATA
92 | typedef void* GRIN_EDGE_DATA;
93 | #endif
94 |
95 | #ifdef GRIN_ENABLE_EDGE_LIST
96 | typedef void* GRIN_EDGE_LIST;
97 | #endif
98 |
99 | #ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR
100 | typedef void* GRIN_EDGE_LIST_ITERATOR;
101 | #endif
102 |
103 | #ifdef GRIN_ENABLE_GRAPH_PARTITION
104 | typedef void* GRIN_PARTITIONED_GRAPH;
105 | typedef unsigned GRIN_PARTITION;
106 | typedef void* GRIN_PARTITION_LIST;
107 | #endif
108 |
109 | #ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
110 | typedef unsigned GRIN_PARTITION_ID;
111 | #endif
112 |
113 | #ifdef GRIN_ENABLE_VERTEX_REF
114 | typedef long long int GRIN_VERTEX_REF;
115 | #endif
116 |
117 | #ifdef GRIN_ENABLE_EDGE_REF
118 | typedef void* GRIN_EDGE_REF;
119 | #endif
120 |
121 | #ifdef GRIN_WITH_VERTEX_PROPERTY
122 | typedef unsigned GRIN_VERTEX_TYPE;
123 | typedef void* GRIN_VERTEX_TYPE_LIST;
124 | typedef unsigned GRIN_VERTEX_PROPERTY;
125 | typedef void* GRIN_VERTEX_PROPERTY_LIST;
126 | #endif
127 |
128 | typedef unsigned GRIN_VERTEX_TYPE_ID;
129 |
130 | typedef unsigned GRIN_VERTEX_PROPERTY_ID;
131 |
132 | #ifdef GRIN_WITH_EDGE_PROPERTY
133 | typedef unsigned GRIN_EDGE_TYPE;
134 | typedef void* GRIN_EDGE_TYPE_LIST;
135 | typedef unsigned GRIN_EDGE_PROPERTY;
136 | typedef void* GRIN_EDGE_PROPERTY_LIST;
137 | #endif
138 |
139 | typedef unsigned GRIN_EDGE_TYPE_ID;
140 |
141 | typedef unsigned GRIN_EDGE_PROPERTY_ID;
142 |
143 |
144 | #ifdef GRIN_ENABLE_ROW
145 | typedef void* GRIN_ROW;
146 | #endif
147 |
148 | #if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL)
149 | typedef void* GRIN_LABEL;
150 | typedef void* GRIN_LABEL_LIST;
151 | #endif
152 |
153 | /* 3. Define invalid values for returns of handles */
154 | #define GRIN_NULL_GRAPH NULL
155 | #define GRIN_NULL_VERTEX NULL
156 | #define GRIN_NULL_EDGE NULL
157 | #define GRIN_NULL_VERTEX_DATA NULL
158 | #define GRIN_NULL_VERTEX_LIST NULL
159 | #define GRIN_NULL_VERTEX_LIST_ITERATOR NULL
160 | #define GRIN_NULL_ADJACENT_LIST NULL
161 | #define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL
162 | #define GRIN_NULL_EDGE_DATA NULL
163 | #define GRIN_NULL_EDGE_LIST NULL
164 | #define GRIN_NULL_EDGE_LIST_ITERATOR NULL
165 | #define GRIN_NULL_PARTITIONED_GRAPH NULL
166 | #define GRIN_NULL_PARTITION (unsigned) ~0
167 | #define GRIN_NULL_PARTITION_LIST NULL
168 | #define GRIN_NULL_PARTITION_ID (unsigned) ~0
169 | #define GRIN_NULL_VERTEX_REF -1
170 | #define GRIN_NULL_EDGE_REF NULL
171 | #define GRIN_NULL_VERTEX_TYPE (unsigned) ~0
172 | #define GRIN_NULL_VERTEX_TYPE_LIST NULL
173 | #define GRIN_NULL_VERTEX_PROPERTY (unsigned) ~0
174 | #define GRIN_NULL_VERTEX_PROPERTY_LIST NULL
175 | #define GRIN_NULL_VERTEX_TYPE_ID (unsigned) ~0
176 | #define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned) ~0
177 | #define GRIN_NULL_EDGE_TYPE (unsigned) ~0
178 | #define GRIN_NULL_EDGE_TYPE_LIST NULL
179 | #define GRIN_NULL_EDGE_PROPERTY (unsigned) ~0
180 | #define GRIN_NULL_EDGE_PROPERTY_LIST NULL
181 | #define GRIN_NULL_EDGE_TYPE_ID (unsigned) ~0
182 | #define GRIN_NULL_EDGE_PROPERTY_ID (unsigned) ~0
183 | #define GRIN_NULL_ROW NULL
184 | #define GRIN_NULL_LABEL NULL
185 | #define GRIN_NULL_LABEL_LIST NULL
186 | #define GRIN_NULL_SIZE (unsigned) ~0
187 | #define GRIN_NULL_NAME NULL
188 |
189 | #ifdef __cplusplus
190 | }
191 | #endif
--------------------------------------------------------------------------------
/storage/v6d/predefine.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | /**
17 | * @file predefine.h
18 | * @brief This template file consists of four parts:
19 | * 1. The predefined enumerate types of GRIN, which should NOT be modified.
20 | * 2. The supported macros which should be specified by storage implementors
21 | * based on storage features.
22 | * 3. The typedefs of the enabled handles. This should be specified by storage.
23 | * 4. The corresponding null values of the enabled handles. This should be
24 | * specified by storage.
25 | */
26 |
27 | #ifndef GRIN_PREDEFINE_H_
28 | #define GRIN_PREDEFINE_H_
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | #include
35 | #include
36 |
37 | /* 1. Define supported macros based on storage features */
38 | // Topology
39 | #define GRIN_ASSUME_HAS_DIRECTED_GRAPH
40 | #define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH
41 | #define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
42 | #define GRIN_ENABLE_VERTEX_LIST
43 | #define GRIN_ENABLE_VERTEX_LIST_ARRAY
44 | #define GRIN_ENABLE_VERTEX_LIST_ITERATOR
45 | #define GRIN_ENABLE_ADJACENT_LIST
46 | #define GRIN_ENABLE_ADJACENT_LIST_ARRAY
47 | #define GRIN_ENABLE_ADJACENT_LIST_ITERATOR
48 | // Partition
49 | #define GRIN_ENABLE_GRAPH_PARTITION
50 | #define GRIN_ASSUME_EDGE_CUT_PARTITION
51 | #define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
52 | #define GRIN_ENABLE_VERTEX_REF
53 | #define GRIN_TRAIT_FAST_VERTEX_REF
54 | #define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST
55 | // Property
56 | #define GRIN_ENABLE_ROW
57 | #define GRIN_ENABLE_SCHEMA
58 | #define GRIN_TRAIT_PROPERTY_VALUE_OF_FLOAT_ARRAY
59 | #define GRIN_WITH_VERTEX_PROPERTY
60 | #define GRIN_ENABLE_VERTEX_PRIMARY_KEYS
61 | #define GRIN_WITH_EDGE_PROPERTY
62 | // Index
63 | #define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX
64 | #define GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_INT64
65 | #define GRIN_ENABLE_VERTEX_PK_INDEX
66 |
67 | /* 2. Define the handles using typedef */
68 | typedef void* GRIN_GRAPH;
69 | typedef unsigned long long int GRIN_VERTEX;
70 | typedef struct GRIN_EDGE {
71 | GRIN_VERTEX src;
72 | GRIN_VERTEX dst;
73 | unsigned dir;
74 | unsigned etype;
75 | unsigned long long int eid;
76 | } GRIN_EDGE;
77 |
78 | #ifdef GRIN_WITH_VERTEX_DATA
79 | typedef void* GRIN_VERTEX_DATA;
80 | #endif
81 |
82 | #ifdef GRIN_ENABLE_VERTEX_LIST
83 | typedef void* GRIN_VERTEX_LIST;
84 | #endif
85 |
86 | #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR
87 | typedef void* GRIN_VERTEX_LIST_ITERATOR;
88 | #endif
89 |
90 | #ifdef GRIN_ENABLE_ADJACENT_LIST
91 | typedef void* GRIN_ADJACENT_LIST;
92 | #endif
93 |
94 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR
95 | typedef void* GRIN_ADJACENT_LIST_ITERATOR;
96 | #endif
97 |
98 | #ifdef GRIN_WITH_EDGE_DATA
99 | typedef void* GRIN_EDGE_DATA;
100 | #endif
101 |
102 | #ifdef GRIN_ENABLE_EDGE_LIST
103 | typedef void* GRIN_EDGE_LIST;
104 | #endif
105 |
106 | #ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR
107 | typedef void* GRIN_EDGE_LIST_ITERATOR;
108 | #endif
109 |
110 | #ifdef GRIN_ENABLE_GRAPH_PARTITION
111 | typedef void* GRIN_PARTITIONED_GRAPH;
112 | typedef unsigned GRIN_PARTITION;
113 | typedef void* GRIN_PARTITION_LIST;
114 | #endif
115 |
116 | #ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
117 | typedef unsigned GRIN_PARTITION_ID;
118 | #endif
119 |
120 | #ifdef GRIN_ENABLE_VERTEX_REF
121 | typedef long long int GRIN_VERTEX_REF;
122 | #endif
123 |
124 | #ifdef GRIN_ENABLE_EDGE_REF
125 | typedef void* GRIN_EDGE_REF;
126 | #endif
127 |
128 | #ifdef GRIN_WITH_VERTEX_PROPERTY
129 | typedef unsigned long long int GRIN_VERTEX_PROPERTY;
130 | typedef void* GRIN_VERTEX_PROPERTY_LIST;
131 | #endif
132 |
133 | #ifdef GRIN_WITH_EDGE_PROPERTY
134 | typedef unsigned long long int GRIN_EDGE_PROPERTY;
135 | typedef void* GRIN_EDGE_PROPERTY_LIST;
136 | #endif
137 |
138 | #ifdef GRIN_ENABLE_SCHEMA
139 | typedef unsigned GRIN_VERTEX_TYPE;
140 | typedef void* GRIN_VERTEX_TYPE_LIST;
141 | typedef unsigned GRIN_VERTEX_TYPE_ID;
142 | typedef unsigned GRIN_VERTEX_PROPERTY_ID;
143 | typedef unsigned GRIN_EDGE_TYPE;
144 | typedef void* GRIN_EDGE_TYPE_LIST;
145 | typedef unsigned GRIN_EDGE_TYPE_ID;
146 | typedef unsigned GRIN_EDGE_PROPERTY_ID;
147 | #endif
148 |
149 | #ifdef GRIN_ENABLE_ROW
150 | typedef void* GRIN_ROW;
151 | #endif
152 |
153 | #if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL)
154 | typedef void* GRIN_LABEL;
155 | typedef void* GRIN_LABEL_LIST;
156 | #endif
157 |
158 | /* 3. Define invalid values for returns of handles */
159 | #define GRIN_NULL_GRAPH NULL
160 | #define GRIN_NULL_VERTEX (unsigned long long int)~0
161 | #define GRIN_NULL_EDGE GRIN_EDGE{GRIN_NULL_VERTEX, GRIN_NULL_VERTEX, BOTH, (unsigned)~0, (unsigned long long int)~0}
162 | #define GRIN_NULL_VERTEX_LIST NULL
163 | #define GRIN_NULL_VERTEX_LIST_ITERATOR NULL
164 | #define GRIN_NULL_ADJACENT_LIST NULL
165 | #define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL
166 | #define GRIN_NULL_PARTITIONED_GRAPH NULL
167 | #define GRIN_NULL_PARTITION (unsigned)~0
168 | #define GRIN_NULL_PARTITION_LIST NULL
169 | #define GRIN_NULL_PARTITION_ID (unsigned)~0
170 | #define GRIN_NULL_VERTEX_REF -1
171 | #define GRIN_NULL_VERTEX_TYPE (unsigned)~0
172 | #define GRIN_NULL_VERTEX_TYPE_LIST NULL
173 | #define GRIN_NULL_VERTEX_PROPERTY (unsigned long long int)~0
174 | #define GRIN_NULL_VERTEX_PROPERTY_LIST NULL
175 | #define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0
176 | #define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0
177 | #define GRIN_NULL_EDGE_TYPE (unsigned)~0
178 | #define GRIN_NULL_EDGE_TYPE_LIST NULL
179 | #define GRIN_NULL_EDGE_PROPERTY (unsigned long long int)~0
180 | #define GRIN_NULL_EDGE_PROPERTY_LIST NULL
181 | #define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0
182 | #define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0
183 | #define GRIN_NULL_ROW NULL
184 | #define GRIN_NULL_SIZE (unsigned)~0
185 | #define GRIN_NULL_NAME NULL
186 |
187 | #ifdef __cplusplus
188 | }
189 | #endif
190 |
191 | #endif // GRIN_PREDEFINE_H_
192 |
--------------------------------------------------------------------------------
/template/predefine.h:
--------------------------------------------------------------------------------
1 | /** Copyright 2020 Alibaba Group Holding Limited.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | /**
17 | * @file predefine.h
18 | * @brief This template file consists of four parts:
19 | * 1. The predefined enumerate types of GRIN, which should NOT be modified.
20 | * 2. The supported macros which should be specified by storage implementors
21 | * based on storage features.
22 | * 3. The typedefs of the enabled handles. This should be specified by storage.
23 | * 4. The corresponding null values of the enabled handles. This should be
24 | * specified by storage.
25 | */
26 |
27 | #ifndef GRIN_PREDEFINE_H_
28 | #define GRIN_PREDEFINE_H_
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | #include
35 | #include
36 |
37 | /* 1. Define supported macros based on storage features */
38 | // Topology
39 | #define GRIN_ASSUME_HAS_DIRECTED_GRAPH
40 | #define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH
41 | #define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH
42 | #define GRIN_WITH_VERTEX_DATA
43 | #define GRIN_WITH_EDGE_DATA
44 | #define GRIN_ENABLE_VERTEX_LIST
45 | #define GRIN_ENABLE_VERTEX_LIST_ARRAY
46 | #define GRIN_ENABLE_VERTEX_LIST_ITERATOR
47 | #define GRIN_ENABLE_EDGE_LIST
48 | #define GRIN_ENABLE_EDGE_LIST_ARRAY
49 | #define GRIN_ENABLE_EDGE_LIST_ITERATOR
50 | #define GRIN_ENABLE_ADJACENT_LIST
51 | #define GRIN_ENABLE_ADJACENT_LIST_ARRAY
52 | #define GRIN_ENABLE_ADJACENT_LIST_ITERATOR
53 | // Partition
54 | #define GRIN_ENABLE_GRAPH_PARTITION
55 | #define GRIN_ASSUME_EDGE_CUT_PARTITION
56 | #define GRIN_ASSUME_VERTEX_CUT_PARTITION
57 | #define GRIN_ASSUME_WITH_UNIVERSAL_VERTICES
58 | #define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
59 | #define GRIN_ENABLE_VERTEX_REF
60 | #define GRIN_TRAIT_FAST_VERTEX_REF
61 | #define GRIN_ENABLE_EDGE_REF
62 | #define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST
63 | #define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST
64 | #define GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST
65 | #define GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST
66 | #define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST
67 | #define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST
68 | #define GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST
69 | #define GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST
70 | #define GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST
71 | #define GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST
72 | // Property
73 | #define GRIN_ENABLE_ROW
74 | #define GRIN_TRAIT_CONST_VALUE_PTR
75 | #define GRIN_ENABLE_SCHEMA
76 | #define GRIN_TRAIT_PROPERTY_VALUE_OF_FLOAT_ARRAY
77 | #define GRIN_WITH_VERTEX_PROPERTY
78 | #define GRIN_ENABLE_VERTEX_PRIMARY_KEYS
79 | #define GRIN_WITH_EDGE_PROPERTY
80 | #define GRIN_ENABLE_EDGE_PRIMARY_KEYS
81 | // Index
82 | #define GRIN_WITH_VERTEX_LABEL
83 | #define GRIN_WITH_EDGE_LABEL
84 | #define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED
85 | #define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX
86 | #define GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_INT64
87 | #define GRIN_ENABLE_VERTEX_EXTERNAL_ID_OF_STRING
88 | #define GRIN_ENABLE_VERTEX_PK_INDEX
89 | #define GRIN_ENABLE_EDGE_PK_INDEX
90 |
91 |
92 | /* 2. Define the handles using typedef */
93 | typedef void* GRIN_GRAPH;
94 | typedef void* GRIN_VERTEX;
95 | typedef void* GRIN_EDGE;
96 |
97 | #ifdef GRIN_WITH_VERTEX_DATA
98 | typedef void* GRIN_VERTEX_DATA;
99 | #endif
100 |
101 | #ifdef GRIN_ENABLE_VERTEX_LIST
102 | typedef void* GRIN_VERTEX_LIST;
103 | #endif
104 |
105 | #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR
106 | typedef void* GRIN_VERTEX_LIST_ITERATOR;
107 | #endif
108 |
109 | #ifdef GRIN_ENABLE_ADJACENT_LIST
110 | typedef void* GRIN_ADJACENT_LIST;
111 | #endif
112 |
113 | #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR
114 | typedef void* GRIN_ADJACENT_LIST_ITERATOR;
115 | #endif
116 |
117 | #ifdef GRIN_WITH_EDGE_DATA
118 | typedef void* GRIN_EDGE_DATA;
119 | #endif
120 |
121 | #ifdef GRIN_ENABLE_EDGE_LIST
122 | typedef void* GRIN_EDGE_LIST;
123 | #endif
124 |
125 | #ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR
126 | typedef void* GRIN_EDGE_LIST_ITERATOR;
127 | #endif
128 |
129 | #ifdef GRIN_ENABLE_GRAPH_PARTITION
130 | typedef void* GRIN_PARTITIONED_GRAPH;
131 | typedef void* GRIN_PARTITION;
132 | typedef void* GRIN_PARTITION_LIST;
133 | #endif
134 |
135 | #ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION
136 | typedef unsigned GRIN_PARTITION_ID;
137 | #endif
138 |
139 | #ifdef GRIN_ENABLE_VERTEX_REF
140 | typedef void* GRIN_VERTEX_REF;
141 | #endif
142 |
143 | #ifdef GRIN_ENABLE_EDGE_REF
144 | typedef void* GRIN_EDGE_REF;
145 | #endif
146 |
147 | #ifdef GRIN_WITH_VERTEX_PROPERTY
148 | typedef void* GRIN_VERTEX_PROPERTY;
149 | typedef void* GRIN_VERTEX_PROPERTY_LIST;
150 | #endif
151 |
152 | #ifdef GRIN_WITH_EDGE_PROPERTY
153 | typedef void* GRIN_EDGE_PROPERTY;
154 | typedef void* GRIN_EDGE_PROPERTY_LIST;
155 | #endif
156 |
157 | #ifdef GRIN_ENABLE_SCHEMA
158 | typedef void* GRIN_VERTEX_TYPE;
159 | typedef void* GRIN_VERTEX_TYPE_LIST;
160 | typedef unsigned GRIN_VERTEX_TYPE_ID;
161 | typedef unsigned GRIN_VERTEX_PROPERTY_ID;
162 | typedef void* GRIN_EDGE_TYPE;
163 | typedef void* GRIN_EDGE_TYPE_LIST;
164 | typedef unsigned GRIN_EDGE_TYPE_ID;
165 | typedef unsigned GRIN_EDGE_PROPERTY_ID;
166 | #endif
167 |
168 | #ifdef GRIN_ENABLE_ROW
169 | typedef void* GRIN_ROW;
170 | #endif
171 |
172 | #if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL)
173 | typedef void* GRIN_LABEL;
174 | typedef void* GRIN_LABEL_LIST;
175 | #endif
176 |
177 | /* 3. Define invalid values for returns of handles */
178 | #define GRIN_NULL_GRAPH NULL
179 | #define GRIN_NULL_VERTEX NULL
180 | #define GRIN_NULL_EDGE NULL
181 | #define GRIN_NULL_VERTEX_DATA NULL
182 | #define GRIN_NULL_VERTEX_LIST NULL
183 | #define GRIN_NULL_VERTEX_LIST_ITERATOR NULL
184 | #define GRIN_NULL_ADJACENT_LIST NULL
185 | #define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL
186 | #define GRIN_NULL_EDGE_DATA NULL
187 | #define GRIN_NULL_EDGE_LIST NULL
188 | #define GRIN_NULL_EDGE_LIST_ITERATOR NULL
189 | #define GRIN_NULL_PARTITIONED_GRAPH NULL
190 | #define GRIN_NULL_PARTITION NULL
191 | #define GRIN_NULL_PARTITION_LIST NULL
192 | #define GRIN_NULL_PARTITION_ID (unsigned)~0
193 | #define GRIN_NULL_VERTEX_REF NULL
194 | #define GRIN_NULL_EDGE_REF NULL
195 | #define GRIN_NULL_VERTEX_TYPE NULL
196 | #define GRIN_NULL_VERTEX_TYPE_LIST NULL
197 | #define GRIN_NULL_VERTEX_PROPERTY NULL
198 | #define GRIN_NULL_VERTEX_PROPERTY_LIST NULL
199 | #define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0
200 | #define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0
201 | #define GRIN_NULL_EDGE_TYPE NULL
202 | #define GRIN_NULL_EDGE_TYPE_LIST NULL
203 | #define GRIN_NULL_EDGE_PROPERTY NULL
204 | #define GRIN_NULL_EDGE_PROPERTY_LIST NULL
205 | #define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0
206 | #define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0
207 | #define GRIN_NULL_ROW NULL
208 | #define GRIN_NULL_LABEL NULL
209 | #define GRIN_NULL_LABEL_LIST NULL
210 | #define GRIN_NULL_SIZE (unsigned)~0
211 | #define GRIN_NULL_NAME NULL
212 |
213 | #ifdef __cplusplus
214 | }
215 | #endif
216 |
217 | #endif // GRIN_PREDEFINE_H_
--------------------------------------------------------------------------------
/yaml/schema.yaml:
--------------------------------------------------------------------------------
1 | gs.gie.dbms.graph:
2 | name: modern
3 | graph:
4 | snapshotId: xx
5 | schema:
6 | vertexTypes:
7 | - typeId: 0
8 | typeName: person
9 | properties:
10 | - propertyId: 0
11 | propertyName: id
12 | propertyType:
13 | enumType: DT_UNSIGNED_INT64
14 | - propertyId: 1
15 | propertyName: name
16 | propertyType:
17 | enumType: DT_STRING
18 | - propertyId: 2
19 | propertyName: age
20 | propertyType:
21 | enumType: DT_UNSIGNED_INT32
22 | primaryKeyIds:
23 | - 0
24 | - typeId: 1
25 | typeName: software
26 | properties:
27 | - propertyId: 0
28 | propertyName: id
29 | propertyType:
30 | enumType: DT_UNSIGNED_INT64
31 | - propertyId: 1
32 | propertyName: name
33 | propertyType:
34 | enumType: DT_STRING
35 | - propertyId: 2
36 | propertyName: lang
37 | propertyType:
38 | enumType: DT_STRING
39 | - propertyId: 3
40 | propertyName: creationDateTime
41 | propertyType:
42 | dateTime:
43 | dateTimeFormat: DTF_YYYY_MM_DD_HH_MM_SS_SSS
44 | timeZoneFormat: TZF_UTC
45 | primaryKeyIds:
46 | - 0
47 | edgeTypes:
48 | - typeId: 0
49 | typeName: knows
50 | properties:
51 | - propertyId: 0
52 | propertyName: weight
53 | propertyType:
54 | enumType: DT_DOUBLE
55 | vertexTypePairRelations:
56 | - srcTypeId: 0
57 | dstTypeId: 0
58 | relation: MANY_TO_MANY
59 | - typeId: 1
60 | typeName: created
61 | properties:
62 | - propertyId: 0
63 | propertyName: weight
64 | propertyType:
65 | enumType: DT_DOUBLE
66 | vertexTypePairRelations:
67 | - srcTypeId: 0
68 | dstTypeId: 1
69 | relation: MANY_TO_MANY
70 |
--------------------------------------------------------------------------------