From deb8e2d78881fc2f7f27034326d58a2349db91d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Wed, 12 Jul 2023 13:52:43 +0800 Subject: [PATCH 01/30] add grin interface for flex --- .gitmodules | 3 + flex/grin/CMakeLists.txt | 76 ++ flex/grin/include | 1 + flex/grin/predefine.h | 288 +++++ flex/grin/src/common/error.cc | 24 + flex/grin/src/index/internal_id.cc | 103 ++ flex/grin/src/predefine.cc | 18 + flex/grin/src/predefine.h | 104 ++ flex/grin/src/property/property.cc | 388 ++++++ flex/grin/src/property/propertylist.cc | 148 +++ flex/grin/src/property/row.cc | 227 ++++ flex/grin/src/property/topology.cc | 84 ++ flex/grin/src/property/type.cc | 270 +++++ flex/grin/src/topology/adjacentlist.cc | 112 ++ flex/grin/src/topology/structure.cc | 144 +++ flex/grin/src/topology/vertexlist.cc | 65 + flex/grin/test/test.cc | 1058 +++++++++++++++++ flex/storages/rt_mutable_graph/mutable_csr.cc | 3 + flex/storages/rt_mutable_graph/mutable_csr.h | 2 +- .../mutable_property_fragment.cc | 12 + flex/storages/rt_mutable_graph/schema.cc | 4 +- flex/utils/property/column.h | 1 + flex/utils/property/types.cc | 16 + flex/utils/property/types.h | 51 + 24 files changed, 3200 insertions(+), 2 deletions(-) create mode 100644 flex/grin/CMakeLists.txt create mode 160000 flex/grin/include create mode 100644 flex/grin/predefine.h create mode 100644 flex/grin/src/common/error.cc create mode 100644 flex/grin/src/index/internal_id.cc create mode 100644 flex/grin/src/predefine.cc create mode 100644 flex/grin/src/predefine.h create mode 100644 flex/grin/src/property/property.cc create mode 100644 flex/grin/src/property/propertylist.cc create mode 100644 flex/grin/src/property/row.cc create mode 100644 flex/grin/src/property/topology.cc create mode 100644 flex/grin/src/property/type.cc create mode 100644 flex/grin/src/topology/adjacentlist.cc create mode 100644 flex/grin/src/topology/structure.cc create mode 100644 flex/grin/src/topology/vertexlist.cc create mode 100644 flex/grin/test/test.cc diff --git a/.gitmodules b/.gitmodules index f038d8b178ac..dcf152e47bc9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "learning_engine/graph-learn"] path = learning_engine/graph-learn url = https://github.com/alibaba/graph-learn.git +[submodule "flex/grin/include"] + path = flex/grin/include + url = https://github.com/GraphScope/GRIN.git diff --git a/flex/grin/CMakeLists.txt b/flex/grin/CMakeLists.txt new file mode 100644 index 000000000000..d9cdea8aa993 --- /dev/null +++ b/flex/grin/CMakeLists.txt @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.1) + +set(GRIN_READER_MAJOR_VERSION 0) +set(GRIN_READER_MINOR_VERSION 1) +set(GRIN_READER_VERSION ${GRIN_READER_MAJOR_VERSION}.${GRIN_READER_MINOR_VERSION}) + +project(grin_reader LANGUAGES C CXX VERSION ${GRIN_READER_VERSION}) + +# Set flags +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g") + +# ------------------------------------------------------------------------------ +# find_libraries +# ------------------------------------------------------------------------------ + +find_package(MPI REQUIRED) +include_directories(SYSTEM ${MPI_CXX_INCLUDE_PATH}) + +find_package(OpenMP REQUIRED) + +find_package(libgrapelite REQUIRED) +include_directories(${LIBGRAPELITE_INCLUDE_DIRS}) + +include("../../flex/cmake/FindGFlags.cmake") +if (GFLAGS_FOUND) + include_directories(SYSTEM ${GFLAGS_INCLUDE_DIRS}) +else () + message(FATAL_ERROR "gflags not found") +endif () + +include("../../flex/cmake/FindGlog.cmake") +include_directories(SYSTEM ${GLOG_INCLUDE_DIRS}) +if (GLOG_FOUND) + set(CMAKE_REQUIRED_INCLUDES "${GLOG_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${GLOG_LIBRARIES}") +endif () + +#find_package(etcd-cpp-api REQUIRED) +#include_directories(${ETCD_CPP_INCLUDE_DIR}) +#link_libraries(${ETCD_CPP_LIBRARIES}) + +#find_package(yaml-cpp REQUIRED) +#include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) + +set(yaml-cpp_INCLUDE_DIRS "/usr/local/Cellar/yaml-cpp/0.7.0/include") +include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) +set(YAML_CPP_LIBRARIES "/usr/local/Cellar/yaml-cpp/0.7.0/lib/libyaml-cpp.0.7.0.dylib") + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..) +message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}") +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../storages/rt_mutable_graph) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../utils/property) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) + +file(GLOB_RECURSE FILES_NEED_FORMAT "src/*.cc") + +add_custom_target(grin_clformat + COMMAND clang-format --style=file -i ${FILES_NEED_FORMAT} + COMMENT "Running clang-format." + VERBATIM) + +file(GLOB SOURCES "src/*.cc" "src/topology/*.cc" "src/property/*.cc" "src/index/*.cc" "src/common/*.cc" "../utils/property/*.cc" "../storages/rt_mutable_graph/*.cc") +add_library(flex_grin SHARED ${SOURCES}) +target_link_libraries(flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES} ${YAML_CPP_LIBRARIES}) + + +add_executable(run_grin_test test/test.cc) + +target_include_directories(run_grin_test PRIVATE ${LIBGRAPELITE_INCLUDE_DIRS}/grape/analytical_apps fragment) +target_link_libraries(run_grin_test flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES}) +target_link_libraries(run_grin_test OpenMP::OpenMP_CXX) diff --git a/flex/grin/include b/flex/grin/include new file mode 160000 index 000000000000..bcafca761f7a --- /dev/null +++ b/flex/grin/include @@ -0,0 +1 @@ +Subproject commit bcafca761f7ac44f2fb20f599d8ce7c13daae3d9 diff --git a/flex/grin/predefine.h b/flex/grin/predefine.h new file mode 100644 index 000000000000..5d2b9a5aaa1a --- /dev/null +++ b/flex/grin/predefine.h @@ -0,0 +1,288 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file predefine.h + * @brief This template file consists of four parts: + * 1. The predefined enumerate types of GRIN, which should NOT be modified. + * 2. The supported macros which should be specified by storage implementors + * based on storage features. + * 3. The typedefs of the enabled handles. This should be specified by storage. + * 4. The corresponding null values of the enabled handles. This should be + * specified by storage. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* 1. Predefined enumerate types of GRIN */ +/// Enumerates the directions of edges with respect to a certain vertex +typedef enum { + IN = 0, ///< incoming + OUT = 1, ///< outgoing + BOTH = 2, ///< incoming & outgoing +} GRIN_DIRECTION; + +/// Enumerates the datatype supported in the storage +typedef enum { + Undefined = 0, ///< other unknown types + Int32 = 1, ///< int + UInt32 = 2, ///< unsigned int + Int64 = 3, ///< long int + UInt64 = 4, ///< unsigned long int + Float = 5, ///< float + Double = 6, ///< double + String = 7, ///< string + Date32 = 8, ///< date + Time32 = 9, ///< Time32 + Timestamp64 = 10, ///< Timestamp +} GRIN_DATATYPE; + +/// Enumerates the error codes of grin +typedef enum { + NO_ERROR = 0, ///< success + UNKNOWN_ERROR = 1, ///< unknown error + INVALID_VALUE = 2, ///< invalid value + UNKNOWN_DATATYPE = 3, ///< unknown datatype +} GRIN_ERROR_CODE; + +/* 2. Define supported macros based on storage features */ +// Topology +#define GRIN_ASSUME_HAS_DIRECTED_GRAPH +#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH +#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +//#define GRIN_WITH_VERTEX_DATA +#define GRIN_WITH_EDGE_DATA +#define GRIN_ENABLE_VERTEX_LIST +//#define GRIN_ENABLE_VERTEX_LIST_ARRAY +#define GRIN_ENABLE_VERTEX_LIST_ITERATOR +#define GRIN_ENABLE_EDGE_LIST +//#define GRIN_ENABLE_EDGE_LIST_ARRAY +#define GRIN_ENABLE_EDGE_LIST_ITERATOR +#define GRIN_ENABLE_ADJACENT_LIST +//#define GRIN_ENABLE_ADJACENT_LIST_ARRAY +#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR + +// Partition +/** +#define GRIN_ENABLE_GRAPH_PARTITION +#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +#define GRIN_ENABLE_VERTEX_REF +#define GRIN_TRAIT_FAST_VERTEX_REF +#define GRIN_ENABLE_EDGE_REF +#define GRIN_ASSUME_ALL_REPLICATE_PARTITION +#define GRIN_ASSUME_EDGE_CUT_PARTITION +#define GRIN_ASSUME_EDGE_CUT_FOLLOW_SRC_PARTITION +#define GRIN_ASSUME_EDGE_CUT_FOLLOW_DST_PARTITION +#define GRIN_ASSUME_VERTEX_CUT_PARTITION +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_DATA +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_DATA +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA +#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST +#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST +#define GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST +#define GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST +#define GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST +#define GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST +*/ + +// Property +#define GRIN_ENABLE_ROW +#define GRIN_TRAIT_CONST_VALUE_PTR +#define GRIN_WITH_VERTEX_PROPERTY +#define GRIN_WITH_VERTEX_PROPERTY_NAME +#define GRIN_WITH_VERTEX_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +//#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY +//#define GRIN_WITH_EDGE_PROPERTY_NAME +#define GRIN_WITH_EDGE_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +//#define GRIN_ENABLE_EDGE_PRIMARY_KEYS +//#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +//#define GRIN_TRAIT_SPECIFIC_VEV_RELATION +//#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY +//#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +//#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +//#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY +//#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +//#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +// Index +#define GRIN_WITH_VERTEX_LABEL +#define GRIN_WITH_EDGE_LABEL +///#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED +#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX +//#define GRIN_ENABLE_VERTEX_PK_INDEX +//#define GRIN_ENABLE_EDGE_PK_INDEX + +/* 3. Define the handles using typedef */ +typedef void* GRIN_GRAPH; +typedef struct GRIN_VERTEX{ + uint8_t label; + uint32_t vid; +} GRIN_VERTEX; // vid? +//typedef void* GRIN_EDGE; +typedef void* GRIN_EDGE; + +#ifdef GRIN_WITH_VERTEX_DATA +typedef void* GRIN_VERTEX_DATA; +#endif + + +#ifdef GRIN_WITH_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_TYPE; +typedef void* GRIN_VERTEX_TYPE_LIST; +typedef void* GRIN_VERTEX_PROPERTY; +typedef void* GRIN_VERTEX_PROPERTY_LIST; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +typedef struct{ + size_t vertex_num; + GRIN_VERTEX_TYPE label; +} GRIN_VERTEX_LIST; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +typedef void* GRIN_VERTEX_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef void* GRIN_ADJACENT_LIST; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +typedef void* GRIN_ADJACENT_LIST_ITERATOR; +#endif + +#ifdef GRIN_WITH_EDGE_DATA +typedef void* GRIN_EDGE_DATA; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST +typedef void* GRIN_EDGE_LIST; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR +typedef void* GRIN_EDGE_LIST_ITERATOR; +#endif + +/** +#ifdef GRIN_ENABLE_GRAPH_PARTITION +typedef void* GRIN_PARTITIONED_GRAPH; +typedef void* GRIN_PARTITION; +typedef void* GRIN_PARTITION_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +typedef unsigned GRIN_PARTITION_ID; +#endif +*/ + +#ifdef GRIN_ENABLE_VERTEX_REF +typedef void* GRIN_VERTEX_REF; +#endif + +#ifdef GRIN_ENABLE_EDGE_REF +typedef void* GRIN_EDGE_REF; +#endif + + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +typedef GRIN_VERTEX_TYPE GRIN_VERTEX_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_PROPERTY_ID; +#endif +typedef unsigned GRIN_EDGE_TYPE; +#ifdef GRIN_WITH_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_TYPE; +typedef void* GRIN_EDGE_TYPE_LIST; +typedef void* GRIN_VEV_TYPE; +typedef void* GRIN_VEV_TYPE_LIST; +typedef unsigned GRIN_EDGE_PROPERTY; +typedef unsigned GRIN_EDGE_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +typedef unsigned GRIN_EDGE_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_PROPERTY_ID; +#endif + +#ifdef GRIN_ENABLE_ROW +typedef void* GRIN_ROW; +#endif + +#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) +typedef void* GRIN_LABEL; +typedef void* GRIN_LABEL_LIST; +#endif + +/* 4. Define invalid values for returns of handles */ +#define GRIN_NULL_GRAPH NULL +#define GRIN_NULL_VERTEX NULL +#define GRIN_NULL_EDGE NULL +#define GRIN_NULL_VERTEX_DATA NULL +#define GRIN_NULL_VERTEX_LIST NULL +#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL +#define GRIN_NULL_ADJACENT_LIST NULL +#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL +#define GRIN_NULL_EDGE_DATA NULL +#define GRIN_NULL_EDGE_LIST NULL +#define GRIN_NULL_EDGE_LIST_ITERATOR NULL +#define GRIN_NULL_PARTITIONED_GRAPH NULL +#define GRIN_NULL_PARTITION NULL +#define GRIN_NULL_PARTITION_LIST NULL +#define GRIN_NULL_PARTITION_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_REF NULL +#define GRIN_NULL_EDGE_REF NULL +#define GRIN_NULL_VERTEX_TYPE (unsigned) ~0 +#define GRIN_NULL_VERTEX_TYPE_LIST NULL +#define GRIN_NULL_VERTEX_PROPERTY NULL +#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL +#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE_LIST NULL +#define GRIN_NULL_VEV_TYPE NULL +#define GRIN_NULL_VEV_TYPE_LIST NULL +#define GRIN_NULL_EDGE_PROPERTY NULL +#define GRIN_NULL_EDGE_PROPERTY_LIST NULL +#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 +#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_ROW NULL +#define GRIN_NULL_LABEL NULL +#define GRIN_NULL_LABEL_LIST NULL +#define GRIN_NULL_SIZE (unsigned)~0 +#define GRIN_NULL_NAME NULL + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/grin/src/common/error.cc b/flex/grin/src/common/error.cc new file mode 100644 index 000000000000..893bfab3fcaf --- /dev/null +++ b/flex/grin/src/common/error.cc @@ -0,0 +1,24 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file error.h + @brief Define the error code related APIs +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/common/error.h" + +__thread GRIN_ERROR_CODE grin_error_code = GRIN_ERROR_CODE::NO_ERROR; + +GRIN_ERROR_CODE grin_get_last_error_code() { return grin_error_code; } \ No newline at end of file diff --git a/flex/grin/src/index/internal_id.cc b/flex/grin/src/index/internal_id.cc new file mode 100644 index 000000000000..f5ae9e286d30 --- /dev/null +++ b/flex/grin/src/index/internal_id.cc @@ -0,0 +1,103 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/index/internal_id.h" + +#if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && \ + !defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the int64 internal id of a vertex + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The int64 internal id of the vertex + */ +long long int grin_get_vertex_internal_id(GRIN_GRAPH, GRIN_VERTEX); + +/** + * @brief Get the vertex by internal id. + * Different from pk_of_int64, the internal id is unique over all vertex types. + * @param GRIN_GRAPH The graph + * @param id The internal id of the vertex + * @return The vertex + */ +GRIN_VERTEX grin_get_vertex_by_internal_id(GRIN_GRAPH, long long int id); + +/** + * @brief Get the upper bound of internal id. + * @param GRIN_GRAPH The graph + * @return The upper bound + */ +long long int grin_get_vertex_internal_id_upper_bound(GRIN_GRAPH); + +/** + * @brief Get the lower bound of internal id. + * @param GRIN_GRAPH The graph + * @return The lower bound + */ +long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH); +#endif + +#if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && \ + defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the int64 internal id of a vertex + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The int64 internal id of the vertex + */ +long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH g, + GRIN_VERTEX_TYPE vt, + GRIN_VERTEX v) { + return v.vid; +} + +/** + * @brief Get the vertex by internal id under type + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @param id The internal id of the vertex under type + * @return The vertex + */ +GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH g, + GRIN_VERTEX_TYPE vt, + long long int id) { + GRIN_VERTEX v; + v.label = vt; + v.vid = id; + return v; +} + +/** + * @brief Get the upper bound of internal id under type. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @return The upper bound of internal id under type + */ +long long int grin_get_vertex_internal_id_upper_bound_by_type( + GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { + auto _g = static_cast(g); + return _g->vertex_num(vt); +} + +/** + * @brief Get the lower bound internal id under type. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @return The lower bound internal id under type + */ +long long int grin_get_vertex_internal_id_lower_bound_by_type( + GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { + return 0; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/predefine.cc b/flex/grin/src/predefine.cc new file mode 100644 index 000000000000..bc75aba091a9 --- /dev/null +++ b/flex/grin/src/predefine.cc @@ -0,0 +1,18 @@ +#include "grin/src/predefine.h" + +GRIN_DATATYPE _get_data_type(const gs::PropertyType& type){ + if(type == gs::PropertyType::kInt32){ + return GRIN_DATATYPE::Int32; + }else if(type == gs::PropertyType::kInt64){ + return GRIN_DATATYPE::Int64; + }else if(type == gs::PropertyType::kString){ + return GRIN_DATATYPE::String; + }else if(type == gs::PropertyType::kDate){ + return GRIN_DATATYPE::Timestamp64; + }else if(type == gs::PropertyType::kDouble){ + return GRIN_DATATYPE::Double; + }else { + return GRIN_DATATYPE::Undefined; + } + +} \ No newline at end of file diff --git a/flex/grin/src/predefine.h b/flex/grin/src/predefine.h new file mode 100644 index 000000000000..ab5e17e535dc --- /dev/null +++ b/flex/grin/src/predefine.h @@ -0,0 +1,104 @@ +#include "grin/predefine.h" + +#include "storages/rt_mutable_graph/mutable_property_fragment.h" + +typedef gs::oid_t GRIN_OID_T; +typedef gs::vid_t GRIN_VID_T; + +typedef gs::MutablePropertyFragment GRIN_GRAPH_T; + +typedef struct GRIN_EDGE_T{ + GRIN_VERTEX dst; + GRIN_VERTEX src; + GRIN_DIRECTION dir; + gs::label_t label; + gs::Any data; +} GRIN_EDGE_T; + + +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef struct GRIN_ADJACENT_LIST_T { + GRIN_VERTEX v; + GRIN_DIRECTION dir; + //gs::label_t elabel; + std::vector edges_label; +} GRIN_ADJACENT_LIST_T; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +struct GRIN_ADJACENT_LIST_ITERATOR_T { + GRIN_ADJACENT_LIST_ITERATOR_T(GRIN_ADJACENT_LIST_T* adj_list):cur_edge_iter(nullptr),cur_label_idx(0),adj_list(*adj_list){} + void get_cur_edge_iter(GRIN_GRAPH_T* g){ + if(cur_label_idx == adj_list.edges_label.size()){ + return; + } + do{ + auto label = adj_list.edges_label[cur_label_idx]; + auto elabel = label >> 16; + auto vlabel = (label & 0xffff); + if(adj_list.dir == GRIN_DIRECTION::OUT){ + cur_edge_iter = g->get_outgoing_edges(adj_list.v.label, adj_list.v.vid, + vlabel, elabel); + } else{ + cur_edge_iter = g->get_incoming_edges(adj_list.v.label,adj_list.v.vid, + vlabel, elabel); + } + ++cur_label_idx; + }while(((cur_edge_iter == nullptr)||(!cur_edge_iter->is_valid())) && cur_label_idx < adj_list.edges_label.size()); + } + void next(GRIN_GRAPH_T* g){ + cur_edge_iter->next(); + if(!cur_edge_iter->is_valid()){ + get_cur_edge_iter(g); + } + } + bool is_valid(){ + if(cur_edge_iter == nullptr){ + return false; + } + return cur_edge_iter->is_valid(); + } + + GRIN_VERTEX neighbor(){ + GRIN_VERTEX v; + v.label = (adj_list.edges_label[cur_label_idx - 1]) &(0xffff); + v.vid = cur_edge_iter->get_neighbor(); + return v; + } + GRIN_EDGE_TYPE edge_type(){ + auto elabel = (adj_list.edges_label[cur_label_idx - 1]) >> 16; + return elabel; + } + std::shared_ptr cur_edge_iter; + gs::label_t cur_label_idx; + const GRIN_ADJACENT_LIST_T& adj_list; +}; +#endif + +#ifdef GRIN_WITH_VERTEX_PROPERTY +typedef std::vector GRIN_VERTEX_TYPE_LIST_T; + +typedef struct GRIN_VERTEX_PROPERTY_T{ + std::string name; + GRIN_VERTEX_TYPE label; +} GRIN_VERTEX_PROPERTY_T; + +typedef std::vector GRIN_VERTEX_PROPERTY_LIST_T; +#endif + +#if defined(GRIN_WITH_VERTEX_PROPERTY) || defined(GRIN_WITH_EDGE_PROPERTY) +typedef std::vector GRIN_ROW_T; +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +typedef std::vector GRIN_EDGE_TYPE_LIST_T; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +typedef struct { + size_t cur_vid; + GRIN_VERTEX_LIST vertex_list; +} GRIN_VERTEX_LIST_ITERATOR_T; +#endif + +GRIN_DATATYPE _get_data_type(const gs::PropertyType& type); \ No newline at end of file diff --git a/flex/grin/src/property/property.cc b/flex/grin/src/property/property.cc new file mode 100644 index 000000000000..1ce8e7b2ad35 --- /dev/null +++ b/flex/grin/src/property/property.cc @@ -0,0 +1,388 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/common/error.h" +#include "grin/include/include/property/property.h" + + +void grin_destroy_string_value(GRIN_GRAPH g, const char* value) {} + +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME +const char* grin_get_vertex_property_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype, + GRIN_VERTEX_PROPERTY vp) { + auto _vp = static_cast(vp); + const auto& name = _vp->name; + auto len = name.length() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", name.c_str()); + return out; +} + +GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH g, + GRIN_VERTEX_TYPE vt, + const char* name) { + auto _g = static_cast(g); + auto& table = _g->get_vertex_table(vt); + if(table.get_column(name) == nullptr){ + return GRIN_NULL_VERTEX_PROPERTY; + } + auto gvp = new GRIN_VERTEX_PROPERTY_T(); + gvp->name = std::string(name); + gvp->label = vt; + return gvp; +} + +GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, + const char* name) { + auto _g = static_cast(g); + std::string prop_name(name); + auto vps = new GRIN_VERTEX_PROPERTY_LIST_T(); + std::string _name = std::string(name); + for (auto idx = 0; idx < _g->schema().vertex_label_num(); idx++) { + auto& table = _g->get_vertex_table(static_cast(idx)); + + auto col = table.get_column(name); + if (col != nullptr) { + GRIN_VERTEX_PROPERTY_T gvp; + gvp.name = _name; + gvp.label = idx; + vps->emplace_back(gvp); + } + } + if (vps->size() == 0) { + delete vps; + return GRIN_NULL_VERTEX_PROPERTY_LIST; + } + return vps; +} +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME +const char* grin_get_edge_property_name(GRIN_GRAPH g, GRIN_EDGE_TYPE etype, + GRIN_EDGE_PROPERTY ep) { + return static_cast(NULL); +} + +GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH g, + GRIN_EDGE_TYPE et, + const char* name) { + return NULL; +} + +GRIN_EDGE_PROPERTY_LIST grin_get_edge_properties_by_name(GRIN_GRAPH g, + const char* name) { + return NULL; +} +#endif + +#ifdef GRIN_WITH_VERTEX_PROPERTY +bool grin_equal_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp1, + GRIN_VERTEX_PROPERTY vp2) { + auto _vp1 = static_cast(vp1); + auto _vp2 = static_cast(vp2); + return (_vp1->name == _vp2->name) && (_vp1->label == _vp2->label); +} + +void grin_destroy_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { + auto _vp = static_cast(vp); + delete _vp; +} + +GRIN_DATATYPE grin_get_vertex_property_datatype(GRIN_GRAPH g, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + auto& table = _g->get_vertex_table(_vp->label); + const auto& property_names = table.column_names(); + const auto& property_types = table.column_types(); + for(size_t i = 0; i < property_names.size(); ++i){ + if(property_names.at(i) == _vp->name){ + return _get_data_type(property_types.at(i)); + } + } + grin_error_code = UNKNOWN_DATATYPE; + return GRIN_DATATYPE::Undefined; +} + +int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + if(v.label != _vp->label){ + grin_error_code = INVALID_VALUE; + return 0; + } + auto& table = _g->get_vertex_table(_vp->label); + auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); + if(col == nullptr){ + grin_error_code = INVALID_VALUE; + return 0; + } + return col->get_view(v.vid); +} + +unsigned int grin_get_vertex_property_value_of_uint32(GRIN_GRAPH g, + GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + grin_error_code = INVALID_VALUE; + return 0; +} + +long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, + GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + if(v.label != _vp->label){ + grin_error_code = INVALID_VALUE; + return 0; + } + auto& table = _g->get_vertex_table(_vp->label); + auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); + if(col == nullptr){ + grin_error_code = INVALID_VALUE; + return 0; + } + return col->get_view(v.vid); +} + +unsigned long long int grin_get_vertex_property_value_of_uint64( + GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { + grin_error_code = INVALID_VALUE; + return 0; +} + +float grin_get_vertex_property_value_of_float(GRIN_GRAPH g, GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + grin_error_code = INVALID_VALUE; + return 0.0f; +} + +double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + if(v.label != _vp->label){ + grin_error_code = INVALID_VALUE; + return 0.0; + } + auto& table = _g->get_vertex_table(_vp->label); + + auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); + if(col == nullptr){ + grin_error_code = INVALID_VALUE; + return 0.0; + } + return col->get_view(v.vid); +} + +const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, + GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + if(v.label != _vp->label){ + grin_error_code = INVALID_VALUE; + return NULL; + } + auto& table = _g->get_vertex_table(_vp->label); + auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); + if(col == nullptr){ + grin_error_code = INVALID_VALUE; + return NULL; + } + return col->get_view(v.vid).data(); + +} + +int grin_get_vertex_property_value_of_date32(GRIN_GRAPH g, GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + grin_error_code = INVALID_VALUE; + return 0; +} + +int grin_get_vertex_property_value_of_time32(GRIN_GRAPH g, GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + grin_error_code = INVALID_VALUE; + return 0; +} + +long long int grin_get_vertex_property_value_of_timestamp64( + GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + if(v.label != _vp->label){ + grin_error_code = INVALID_VALUE; + return 0; + } + + auto& table = _g->get_vertex_table(_vp->label); + auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); + if(col == nullptr){ + grin_error_code = INVALID_VALUE; + return 0; + } + return col->get_view(v.vid).milli_second; +} + +GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH g, + GRIN_VERTEX_PROPERTY vp) { + auto _vp = static_cast(vp); + return _vp->label; +} +#endif + +#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) +const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto _vp = static_cast(vp); + auto& table = _g->get_vertex_table(_vp->label); + const auto& col = table.get_column(_vp->name); + auto type = grin_get_vertex_property_datatype(g,vp); + switch(type){ + case GRIN_DATATYPE::Int32:{ + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + v.vid; + } + case GRIN_DATATYPE::Int64:{ + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + v.vid; + } + case GRIN_DATATYPE::String:{ + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer()[v.vid].data(); + } + case GRIN_DATATYPE::Timestamp64:{ + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + v.vid; + } + case GRIN_DATATYPE::Double:{ + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + v.vid; + } + default: + grin_error_code = UNKNOWN_DATATYPE; + return NULL; + } +} +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +bool grin_equal_edge_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep1, + GRIN_EDGE_PROPERTY ep2) { + return ep1 == ep2; +} + +void grin_destroy_edge_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep){} + +GRIN_DATATYPE grin_get_edge_property_datatype(GRIN_GRAPH g, + GRIN_EDGE_PROPERTY ep){ + auto _g = static_cast(g); + const auto& type = _g->schema().get_edge_property(ep >> 16, (ep >> 8) & 0xff, ep & 0xff); + return _get_data_type(type); +} + +int grin_get_edge_property_value_of_int32(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + auto _e = static_cast(e); + if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Int32){ + grin_error_code = INVALID_VALUE; + return 0; + } + return _e->data.value.i; +} + +unsigned int grin_get_edge_property_value_of_uint32(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + grin_error_code = INVALID_VALUE; + return 0; +} + +long long int grin_get_edge_property_value_of_int64(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + auto _e = static_cast(e); + if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Int64){ + grin_error_code = INVALID_VALUE; + return 0; + } + return _e->data.value.l; +} + +unsigned long long int grin_get_edge_property_value_of_uint64( + GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep){ + grin_error_code = INVALID_VALUE; + return 0; +} + + +float grin_get_edge_property_value_of_float(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + grin_error_code = INVALID_VALUE; + return 0.0; +} +double grin_get_edge_property_value_of_double(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + auto _e = static_cast(e); + if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Double){ + grin_error_code = INVALID_VALUE; + return 0.0; + } + return _e->data.value.db; +} + +const char* grin_get_edge_property_value_of_string(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + auto _e = static_cast(e); + if(_get_data_type(_e->data.type) != GRIN_DATATYPE::String){ + grin_error_code = INVALID_VALUE; + return NULL; + } + //@TODO 怎么返回? + return NULL; +} + +int grin_get_edge_property_value_of_date32(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + grin_error_code = INVALID_VALUE; + return 0; +} +int grin_get_edge_property_value_of_time32(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + grin_error_code = INVALID_VALUE; + return 0; +} + +long long int grin_get_edge_property_value_of_timestamp64( + GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep){ + auto _e = static_cast(e); + if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Timestamp64){ + grin_error_code = INVALID_VALUE; + return 0; + } + return _e->data.value.d.milli_second; + } + +GRIN_EDGE_TYPE grin_get_edge_type_from_property(GRIN_GRAPH g, + GRIN_EDGE_PROPERTY ep){ + return ep; +} +#endif + +#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) +const void* grin_get_edge_property_value(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep){ + return NULL; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/property/propertylist.cc b/flex/grin/src/property/propertylist.cc new file mode 100644 index 000000000000..c4e3520abd3b --- /dev/null +++ b/flex/grin/src/property/propertylist.cc @@ -0,0 +1,148 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/property/propertylist.h" + +#ifdef GRIN_WITH_VERTEX_PROPERTY +GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type( + GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { + auto _g = static_cast(g); + auto &table = _g->get_vertex_table(vt); + + auto vertex_prop_num = table.col_num(); + GRIN_VERTEX_PROPERTY_LIST_T* vpl = new GRIN_VERTEX_PROPERTY_LIST_T(); + const auto& prop_names = table.column_names(); + for(size_t i = 0; i < vertex_prop_num; ++i){ + GRIN_VERTEX_PROPERTY_T vpt; + vpt.name = prop_names[i]; + vpt.label = vt; + vpl->emplace_back(vpt); + } + return vpl; +} + +size_t grin_get_vertex_property_list_size(GRIN_GRAPH g, + GRIN_VERTEX_PROPERTY_LIST vpl) { + auto _vpl = static_cast(vpl); + return _vpl->size(); +} + +GRIN_VERTEX_PROPERTY grin_get_vertex_property_from_list( + GRIN_GRAPH g, GRIN_VERTEX_PROPERTY_LIST vpl, size_t idx) { + auto _vpl = static_cast(vpl); + GRIN_VERTEX_PROPERTY_T* vp = new GRIN_VERTEX_PROPERTY_T(); + *vp = (*_vpl)[idx]; + return vp; +} + +GRIN_VERTEX_PROPERTY_LIST grin_create_vertex_property_list(GRIN_GRAPH g) { + return new GRIN_VERTEX_PROPERTY_LIST_T(); +} + +void grin_destroy_vertex_property_list(GRIN_GRAPH g, + GRIN_VERTEX_PROPERTY_LIST vpl) { + auto _vpl = static_cast(vpl); + delete _vpl; +} + +bool grin_insert_vertex_property_to_list(GRIN_GRAPH g, + GRIN_VERTEX_PROPERTY_LIST vpl, + GRIN_VERTEX_PROPERTY vp) { + auto _vp = static_cast(vp); + auto p = *_vp; + auto _vpl = static_cast(vpl); + _vpl->push_back(p); + return true; +} +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id( + GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX_PROPERTY_ID pid) { + auto _g = static_cast(g); + + auto& table = _g->get_vertex_table(vt); + auto vertex_prop_num = table.col_num(); + + if (pid >= vertex_prop_num) { + return GRIN_NULL_VERTEX_PROPERTY; + } + const auto& prop_names = table.column_names(); + GRIN_VERTEX_PROPERTY_T* vpt = new GRIN_VERTEX_PROPERTY_T(); + vpt->name = prop_names[pid]; + vpt->label = vt; + return vpt; +} + +GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH g, + GRIN_VERTEX_TYPE vt, + GRIN_VERTEX_PROPERTY vp) { + auto _g = static_cast(g); + auto& table = _g->get_vertex_table(vt); + const auto& prop_names = table.column_names(); + auto _vp = static_cast(vp); + for(size_t i = 0; i < prop_names.size(); ++i){ + if(prop_names.at(i) == _vp->name){ + return i; + } + } + return GRIN_NULL_VERTEX_PROPERTY_ID; +} +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH g, + GRIN_EDGE_TYPE et){ + return et; +} + +size_t grin_get_edge_property_list_size(GRIN_GRAPH g, + GRIN_EDGE_PROPERTY_LIST epl){ + return 1; +} + +GRIN_EDGE_PROPERTY grin_get_edge_property_from_list(GRIN_GRAPH g, + GRIN_EDGE_PROPERTY_LIST epl, + size_t idx){ + if(idx > 0){ + return GRIN_NULL_EDGE_PROPERTY; + } + return epl; +} + +GRIN_EDGE_PROPERTY_LIST grin_create_edge_property_list(GRIN_GRAPH g){ + return GRIN_NULL_EDGE_PROPERTY; +} + +void grin_destroy_edge_property_list(GRIN_GRAPH g, + GRIN_EDGE_PROPERTY_LIST epl){} + +bool grin_insert_edge_property_to_list(GRIN_GRAPH g, + GRIN_EDGE_PROPERTY_LIST epl, + GRIN_EDGE_PROPERTY ep){ + return false; +} +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +GRIN_EDGE_PROPERTY grin_get_edge_property_by_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et, + GRIN_EDGE_PROPERTY_ID pid){ + return NULL; +} + +GRIN_EDGE_PROPERTY_ID grin_get_edge_property_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et, + GRIN_EDGE_PROPERTY ep){ + return 0; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/property/row.cc b/flex/grin/src/property/row.cc new file mode 100644 index 000000000000..eae1bbcb66d4 --- /dev/null +++ b/flex/grin/src/property/row.cc @@ -0,0 +1,227 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/property/row.h" + +#ifdef GRIN_ENABLE_ROW +void grin_destroy_row(GRIN_GRAPH g, GRIN_ROW r) { + auto _r = static_cast(r); + delete _r; +} + +int grin_get_int32_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +unsigned int grin_get_uint32_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +long long int grin_get_int64_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +unsigned long long int grin_get_uint64_from_row(GRIN_GRAPH g, GRIN_ROW r, + size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +float grin_get_float_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +double grin_get_double_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +const char* grin_get_string_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + auto s = static_cast((*_r)[idx]); + return s; +} + +int grin_get_date32_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +int grin_get_time32_from_row(GRIN_GRAPH g, GRIN_ROW r, size_t idx) { + auto _r = static_cast(r); + return *static_cast((*_r)[idx]); +} + +long long int grin_get_timestamp64_from_row(GRIN_GRAPH g, GRIN_ROW r, + size_t idx) { + auto _r = static_cast(r); + return (*static_cast((*_r)[idx])); +} + +GRIN_ROW grin_create_row(GRIN_GRAPH g) { + auto r = new GRIN_ROW_T(); + return r; +} + +bool grin_insert_int32_to_row(GRIN_GRAPH g, GRIN_ROW r, int value) { + auto _r = static_cast(r); + _r->push_back(new int32_t(value)); + return true; +} + +bool grin_insert_uint32_to_row(GRIN_GRAPH g, GRIN_ROW r, unsigned int value) { + auto _r = static_cast(r); + _r->push_back(new uint32_t(value)); + return true; +} + +bool grin_insert_int64_to_row(GRIN_GRAPH g, GRIN_ROW r, long long int value) { + auto _r = static_cast(r); + _r->push_back(new int64_t(value)); + return true; +} + +bool grin_insert_uint64_to_row(GRIN_GRAPH g, GRIN_ROW r, + unsigned long long int value) { + auto _r = static_cast(r); + _r->push_back(new uint64_t(value)); + return true; +} + +bool grin_insert_float_to_row(GRIN_GRAPH g, GRIN_ROW r, float value) { + auto _r = static_cast(r); + _r->push_back(new float(value)); + return true; +} + +bool grin_insert_double_to_row(GRIN_GRAPH g, GRIN_ROW r, double value) { + auto _r = static_cast(r); + _r->push_back(new double(value)); + return true; +} + +bool grin_insert_string_to_row(GRIN_GRAPH g, GRIN_ROW r, const char* value) { + auto _r = static_cast(r); + _r->push_back(value); + return true; +} + +bool grin_insert_date32_to_row(GRIN_GRAPH g, GRIN_ROW r, int value) { + auto _r = static_cast(r); + _r->push_back(new int32_t(value)); + return true; +} + +bool grin_insert_time32_to_row(GRIN_GRAPH g, GRIN_ROW r, int value) { + auto _r = static_cast(r); + _r->push_back(new int32_t(value)); + return true; +} + +bool grin_insert_timestamp64_to_row(GRIN_GRAPH g, GRIN_ROW r, + long long int value) { + auto _r = static_cast(r); + _r->push_back(new int64_t(value)); + return true; +} +#endif + +#if defined(GRIN_ENABLE_ROW) && defined(GRIN_TRAIT_CONST_VALUE_PTR) +/** @brief the value of a property from row by its position in row */ +const void* grin_get_value_from_row(GRIN_GRAPH g, GRIN_ROW r, GRIN_DATATYPE dt, + size_t idx) { + auto _r = static_cast(r); + switch (dt) { + case GRIN_DATATYPE::Int32: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::UInt32: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::Int64: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::UInt64: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::Float: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::Double: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::String: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::Date32: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::Time32: + return static_cast((*_r)[idx]); + case GRIN_DATATYPE::Timestamp64: + return static_cast((*_r)[idx]); + default: + return NULL; + } + return NULL; +} +#endif +///@} + +#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_ENABLE_ROW) +GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { + auto _g = static_cast(g); + auto& table = _g->get_vertex_table(v.label); + auto prop_size = table.col_num(); + const auto& types = table.column_types(); + auto r = new GRIN_ROW_T(); + for (size_t prop_id = 0; prop_id < prop_size; prop_id++) { + auto col = table.get_column_by_id(prop_id); + auto type = _get_data_type(types[prop_id]); + switch(type){ + case GRIN_DATATYPE::Int32:{ + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data()+ v.vid); + break; + } + case GRIN_DATATYPE::Int64:{ + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data()+ v.vid); + break; + } + case GRIN_DATATYPE::String:{ + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer()[v.vid].data()); + break; + } + case GRIN_DATATYPE::Timestamp64:{ + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data()+ v.vid); + break; + } + case GRIN_DATATYPE::Double:{ + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data() + v.vid); + break; + } + default: + r->emplace_back(static_cast(NULL)); + + } + } + return r; +} +#endif + +#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_ENABLE_ROW) +GRIN_ROW grin_get_edge_row(GRIN_GRAPH g, GRIN_EDGE e){ + return NULL; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/property/topology.cc b/flex/grin/src/property/topology.cc new file mode 100644 index 000000000000..d530702218c1 --- /dev/null +++ b/flex/grin/src/property/topology.cc @@ -0,0 +1,84 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/property/topology.h" + +#ifdef GRIN_WITH_VERTEX_PROPERTY +size_t grin_get_vertex_num_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { + auto _g = static_cast(g); + return _g->vertex_num(vt); +} +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et){ + return 0; +} +#endif + +#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_VERTEX_LIST grin_get_vertex_list_by_type(GRIN_GRAPH g, + GRIN_VERTEX_TYPE vt) { + GRIN_VERTEX_LIST gvl; + gvl.label = vt; + auto _g = static_cast(g); + gvl.vertex_num = _g->vertex_num(vt); + return gvl; +} +#endif + +#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); +#endif + +#if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type(GRIN_GRAPH g, + GRIN_DIRECTION dir, + GRIN_VERTEX v, + GRIN_EDGE_TYPE et) { + GRIN_ADJACENT_LIST_T* adj_list = new GRIN_ADJACENT_LIST_T(); + adj_list->v = v; + adj_list->dir = dir; + auto _g = static_cast(g); + + const auto &schema = _g->schema(); + if(dir == GRIN_DIRECTION::OUT){ + std::string src_label = + schema.get_vertex_label_name(v.label); + std::string edge_label = schema.get_edge_label_name(et); + for(size_t dst_label_i = 0; dst_label_i != schema.vertex_label_num(); ++dst_label_i){ + std::string dst_label = schema.get_vertex_label_name(static_cast(dst_label_i)); + if (!schema.exist(src_label, dst_label, edge_label)) { + continue; + } + auto label = (static_cast(et) << 16) + dst_label_i; + adj_list->edges_label.emplace_back(label); + } + } else{ + std::string dst_label = + schema.get_vertex_label_name(v.label); + std::string edge_label = schema.get_edge_label_name(et); + for(size_t src_label_i = 0; src_label_i != schema.vertex_label_num(); ++src_label_i){ + std::string src_label = schema.get_vertex_label_name(static_cast(src_label_i)); + if (!schema.exist(src_label, dst_label, edge_label)) { + continue; + } + auto label = (static_cast(et) << 16) + src_label_i; + adj_list->edges_label.emplace_back(label); + } + } + + return adj_list; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/property/type.cc b/flex/grin/src/property/type.cc new file mode 100644 index 000000000000..c538214e1370 --- /dev/null +++ b/flex/grin/src/property/type.cc @@ -0,0 +1,270 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/property/type.h" + +#ifdef GRIN_WITH_VERTEX_PROPERTY +// Vertex type +bool grin_equal_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt1, + GRIN_VERTEX_TYPE vt2) { + return (vt1 == vt2); +} + +GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH g, GRIN_VERTEX v) { + return v.label; +} + +void grin_destroy_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) {} + +// Vertex type list +GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list(GRIN_GRAPH g) { + auto _g = static_cast(g); + auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); + auto vertex_label_num = _g->schema().vertex_label_num(); + for (size_t idx = 0; idx < vertex_label_num; ++idx) { + vtl->push_back(idx); + } + return vtl; +} + +void grin_destroy_vertex_type_list(GRIN_GRAPH g, GRIN_VERTEX_TYPE_LIST vtl) { + auto _vtl = static_cast(vtl); + delete _vtl; +} + +GRIN_VERTEX_TYPE_LIST grin_create_vertex_type_list(GRIN_GRAPH g) { + auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); + return vtl; +} + +bool grin_insert_vertex_type_to_list(GRIN_GRAPH g, GRIN_VERTEX_TYPE_LIST vtl, + GRIN_VERTEX_TYPE vt) { + auto _vtl = static_cast(vtl); + _vtl->push_back(vt); + return true; +} + +size_t grin_get_vertex_type_list_size(GRIN_GRAPH g, GRIN_VERTEX_TYPE_LIST vtl) { + auto _vtl = static_cast(vtl); + return _vtl->size(); +} + +GRIN_VERTEX_TYPE grin_get_vertex_type_from_list(GRIN_GRAPH g, + GRIN_VERTEX_TYPE_LIST vtl, + size_t idx) { + auto _vtl = static_cast(vtl); + return (*_vtl)[idx]; +} +#endif + +#ifdef GRIN_WITH_VERTEX_TYPE_NAME +const char* grin_get_vertex_type_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { + auto _g = static_cast(g); + std::string type_name = _g->schema().get_vertex_label_name(vt); + auto len = type_name.length() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", type_name.c_str()); + return out; +} + +GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH g, const char* name) { + auto _g = static_cast(g); + std::string type_name(name); + if((!_g->schema().contains_vertex_label(type_name))){ + return GRIN_NULL_VERTEX_TYPE; + } + auto type = _g->schema().get_vertex_label_id(type_name); + return type; +} +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +GRIN_VERTEX_TYPE_ID grin_get_vertex_type_id(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { + return vt; +} + +GRIN_VERTEX_TYPE grin_get_vertex_type_by_id(GRIN_GRAPH g, + GRIN_VERTEX_TYPE_ID tid) { + return tid; +} +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +// Edge type +bool grin_equal_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et1, + GRIN_EDGE_TYPE et2) { + return (et1 == et2); +} + +GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH g, GRIN_EDGE e) { + auto _e = static_cast(e); + return _e->label; +} + +void grin_destroy_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { + // do nothing +} + +// Edge type list +GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH g) { + auto _g = static_cast(g); + auto etl = new GRIN_EDGE_TYPE_LIST_T(); + auto edge_label_num = _g->edge_label_num_; + for (auto idx = 0; idx < edge_label_num; ++idx) { + etl->push_back(idx); + } + return etl; +} + +void grin_destroy_edge_type_list(GRIN_GRAPH g, GRIN_EDGE_TYPE_LIST etl) { + auto _etl = static_cast(etl); + delete _etl; +} + +GRIN_EDGE_TYPE_LIST grin_create_edge_type_list(GRIN_GRAPH g) { + auto etl = new GRIN_EDGE_TYPE_LIST_T(); + return etl; +} + +bool grin_insert_edge_type_to_list(GRIN_GRAPH g, GRIN_EDGE_TYPE_LIST etl, + GRIN_EDGE_TYPE et) { + auto _etl = static_cast(etl); + _etl->push_back(et); + return true; +} + +size_t grin_get_edge_type_list_size(GRIN_GRAPH g, GRIN_EDGE_TYPE_LIST etl) { + auto _etl = static_cast(etl); + return _etl->size(); +} + +GRIN_EDGE_TYPE grin_get_edge_type_from_list(GRIN_GRAPH g, + GRIN_EDGE_TYPE_LIST etl, + size_t idx) { + auto _etl = static_cast(etl); + return (*_etl)[idx]; +} +#endif + +#ifdef GRIN_WITH_EDGE_TYPE_NAME +const char* grin_get_edge_type_name(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { + auto _g = static_cast(g); + const auto& schema = _g->schema(); + std::string label = schema.get_edge_label_name(static_cast(et)); + auto len = label.length() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", label.c_str()); + return out; +} + +GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH g, const char* name) { + auto _g = static_cast(g); + const auto& schema = _g->schema(); + if(!schema.contains_edge_label(name)){ + return GRIN_NULL_EDGE_TYPE; + } + GRIN_EDGE_TYPE type = schema.get_edge_label_id(name); + return type; +} +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +GRIN_EDGE_TYPE_ID grin_get_edge_type_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { + return et; +} + +GRIN_EDGE_TYPE grin_get_edge_type_by_id(GRIN_GRAPH g, GRIN_EDGE_TYPE_ID etid) { + return etid; +} +#endif + +#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_WITH_EDGE_PROPERTY) +/** @brief the src vertex type list */ +GRIN_VERTEX_TYPE_LIST grin_get_src_types_by_edge_type(GRIN_GRAPH g, + GRIN_EDGE_TYPE et) { + auto _g = static_cast(g); + + auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); + const auto& schema = _g->schema(); + auto vertex_label_num = _g->vertex_label_num_; + std::string edge_label = + schema.get_edge_label_name(static_cast(et)); + for (size_t src_label_i = 0; src_label_i != vertex_label_num; + ++src_label_i) { + std::string src_label = + schema.get_vertex_label_name(static_cast(src_label_i)); + for (size_t dst_label_i = 0; dst_label_i != vertex_label_num; + ++dst_label_i) { + std::string dst_label = + schema.get_vertex_label_name(static_cast(dst_label_i)); + + if (schema.exist(src_label, dst_label, edge_label)) { + vtl->push_back(src_label_i); + } + } + } + return vtl; +} + +/** @brief get the dst vertex type list */ +GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH g, + GRIN_EDGE_TYPE et) { + auto _g = static_cast(g); + + auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); + const auto& schema = _g->schema(); + auto vertex_label_num = _g->vertex_label_num_; + std::string edge_label = + schema.get_edge_label_name(static_cast(et)); + for (size_t src_label_i = 0; src_label_i != vertex_label_num; + ++src_label_i) { + std::string src_label = + schema.get_vertex_label_name(static_cast(src_label_i)); + for (size_t dst_label_i = 0; dst_label_i != vertex_label_num; + ++dst_label_i) { + std::string dst_label = + schema.get_vertex_label_name(static_cast(dst_label_i)); + + if (schema.exist(src_label, dst_label, edge_label)) { + vtl->push_back(dst_label_i); + } + } + } + return vtl; +} + +/** @brief get the edge type list related to a given pair of vertex types */ +GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair( + GRIN_GRAPH g, GRIN_VERTEX_TYPE vt1, GRIN_VERTEX_TYPE vt2) { + auto _g = static_cast(g); + + auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); + const auto& schema = _g->schema(); + auto edge_label_num = _g->edge_label_num_; + std::string src_label = + schema.get_vertex_label_name(static_cast(vt1)); + std::string dst_label = + schema.get_vertex_label_name(static_cast(vt2)); + for (size_t edge_label_i = 0; edge_label_i != edge_label_num; + ++edge_label_i) { + std::string edge_label = + schema.get_vertex_label_name(static_cast(edge_label_i)); + if(schema.exist(src_label,dst_label,edge_label)){ + vtl->push_back(edge_label_i); + } + } + return vtl; +} +#endif +///@} diff --git a/flex/grin/src/topology/adjacentlist.cc b/flex/grin/src/topology/adjacentlist.cc new file mode 100644 index 000000000000..8340f4f0db78 --- /dev/null +++ b/flex/grin/src/topology/adjacentlist.cc @@ -0,0 +1,112 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/topology/adjacentlist.h" + +#if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_ENABLE_EDGE_PROPERTY) +GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH g, GRIN_DIRECTION dir, + GRIN_VERTEX v){ + auto _g = static_cast(g); + auto& schema = _g->schema(); + GRIN_ADJACENT_LIST_T* alt = new GRIN_ADJACENT_LIST_T(); + alt->dir = dir; + alt->v = v; + if(dir == GRIN_DIRECTION::OUT){ + std::string src_label = schema.get_vertex_label_name(v.label); + for(size_t edge_label_i = 0; edge_label_i < _g->edge_label_num_; ++edge_label_i){ + std::string edge_label = schema.get_edge_label_name(edge_label_i); + for(size_t dst_label_i = 0; dst_label_i < _g->vertex_label_num_; ++dst_label_i){ + std::string dst_label = schema.get_vertex_label_name(dst_label_i); + if(schema.exist(src_label,dst_label,edge_label)){ + alt->edges_label.emplace_back((edge_label_i << 16) + dst_label_i); + } + } + } + }else{ + std::string dst_label = schema.get_vertex_label_name(v.label); + for(size_t edge_label_i = 0; edge_label_i < _g->edge_label_num_; ++edge_label_i){ + std::string edge_label = schema.get_edge_label_name(edge_label_i); + for(size_t src_label_i = 0; src_label_i < _g->vertex_label_num_; ++src_label_i){ + std::string src_label = schema.get_vertex_label_name(src_label_i); + if(schema.exist(src_label,dst_label,edge_label)){ + alt->edges_label.emplace_back((edge_label_i << 16) + src_label_i); + } + } + } + } + return alt; +} +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST +void grin_destroy_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) { + auto adj = static_cast(adj_list); + delete adj; +} +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( + GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) { + auto _g = static_cast(g); + auto _adj_list = static_cast(adj_list); + auto iter = new GRIN_ADJACENT_LIST_ITERATOR_T(_adj_list); + iter->get_cur_edge_iter(_g); + return iter; +} + +void grin_destroy_adjacent_list_iter(GRIN_GRAPH g, + GRIN_ADJACENT_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + delete _iter; +} + +void grin_get_next_adjacent_list_iter(GRIN_GRAPH g, + GRIN_ADJACENT_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + auto _g = static_cast(g); + _iter->next(_g); +} + +bool grin_is_adjacent_list_end(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + return !_iter->is_valid(); +} + +GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter( + GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + return _iter->neighbor(); +} + +GRIN_EDGE grin_get_edge_from_adjacent_list_iter( + GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + GRIN_EDGE_T* edge = new GRIN_EDGE_T(); + if (_iter->adj_list.dir == GRIN_DIRECTION::IN) { + edge->src = _iter->neighbor(); + edge->dst = _iter->adj_list.v; + } else { + edge->src = _iter->adj_list.v; + edge->dst = _iter->neighbor(); + } + edge->dir = _iter->adj_list.dir; + edge->data = _iter->cur_edge_iter->get_data(); + edge->label = _iter->edge_type(); + return edge; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/topology/structure.cc b/flex/grin/src/topology/structure.cc new file mode 100644 index 000000000000..5afb0f033236 --- /dev/null +++ b/flex/grin/src/topology/structure.cc @@ -0,0 +1,144 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/topology/structure.h" +#include +GRIN_GRAPH grin_get_graph_from_storage(const char* uri){ + + std::string _uri(uri); + std::string::size_type pos = _uri.find("://"); + if (pos == std::string::npos) { + return GRIN_NULL_GRAPH; + } + auto protocol = _uri.substr(0, pos); + if(protocol != "flex"){ + return GRIN_NULL_GRAPH; + } + _uri = _uri.substr(pos + 3); + std::string graph_schema_path = _uri + "/modern_graph.yaml"; + std::string data_path = uri; + std::string bulk_load_config_path = _uri + "/bulk_load.yaml"; + auto ret = gs::Schema::LoadFromYaml(graph_schema_path, bulk_load_config_path); + const auto& schema = std::get<0>(ret); + auto& vertex_files = std::get<1>(ret); + + auto& edge_files = std::get<2>(ret); + + GRIN_GRAPH_T* g = new GRIN_GRAPH_T(); + g->Init(schema, vertex_files, edge_files); + return g; +} + +void grin_destroy_graph(GRIN_GRAPH g) { + auto _g = static_cast(g); + delete _g; +} + + +// Graph +#if defined(GRIN_ASSUME_HAS_DIRECTED_GRAPH) && \ + defined(GRIN_ASSUME_HAS_UNDIRECTED_GRAPH) +bool grin_is_directed(GRIN_GRAPH g) { + return true; +} +#endif + + +#ifdef GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +bool grin_is_multigraph(GRIN_GRAPH){ + return true; +} +#endif + +#ifndef GRIN_WITH_VERTEX_PROPERTY +size_t grin_get_vertex_num(GRIN_GRAPH); +#endif + +#ifndef GRIN_WITH_EDGE_PROPERTY +size_t grin_get_edge_num(GRIN_GRAPH); +#endif + + +// Vertex +void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX) {} + +bool grin_equal_vertex(GRIN_GRAPH g, GRIN_VERTEX v1, GRIN_VERTEX v2) { + return v1.label == v2.label && v1.vid == v2.vid; +} + +// Data +#ifdef GRIN_WITH_VERTEX_DATA +GRIN_DATATYPE grin_get_vertex_data_datatype(GRIN_GRAPH, GRIN_VERTEX); + +const void* grin_get_vertex_data_value(GRIN_GRAPH, GRIN_VERTEX); +#endif + +// Edge +void grin_destroy_edge(GRIN_GRAPH, GRIN_EDGE e) { + auto _e = static_cast(e); + delete _e; +} + +GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e){ + auto _e = static_cast(e); + return _e->src; +} + + +GRIN_VERTEX grin_get_dst_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e) { + auto _e = static_cast(e); + return _e->dst; +} + +#ifdef GRIN_WITH_EDGE_DATA +GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE e){ + auto _e = static_cast(e); + auto type = _e->data.type; + return _get_data_type(type); +} + +const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE e){ + auto _e = static_cast(e); + //new 返回? + auto type = _e->data.type; + switch(_get_data_type(type)){ + case GRIN_DATATYPE::Int32:{ + return new int32_t(_e->data.value.i); + } + case GRIN_DATATYPE::Int64:{ + return new int64_t(_e->data.value.l); + } + case GRIN_DATATYPE::Double:{ + return new double(_e->data.value.db); + } + case GRIN_DATATYPE::String:{ + auto s = _e->data.value.s; + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); + return out; + } + case GRIN_DATATYPE::Timestamp64:{ + return new int64_t(_e->data.value.d.milli_second); + } + default: + return GRIN_NULL_EDGE_DATA; + } + + +} +#endif \ No newline at end of file diff --git a/flex/grin/src/topology/vertexlist.cc b/flex/grin/src/topology/vertexlist.cc new file mode 100644 index 000000000000..1b7de42108ca --- /dev/null +++ b/flex/grin/src/topology/vertexlist.cc @@ -0,0 +1,65 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/topology/vertexlist.h" + + +#if defined(GRIN_ENABLE_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH g) {} +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +void grin_destroy_vertex_list(GRIN_GRAPH g, GRIN_VERTEX_LIST vl) {} +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH g, + GRIN_VERTEX_LIST vl) { + GRIN_VERTEX_LIST_ITERATOR_T *vlt = new GRIN_VERTEX_LIST_ITERATOR_T(); + vlt->cur_vid = 0; + vlt->vertex_list = vl; + return vlt; +} + +void grin_destroy_vertex_list_iter(GRIN_GRAPH g, + GRIN_VERTEX_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + delete _iter; +} + +void grin_get_next_vertex_list_iter(GRIN_GRAPH g, + GRIN_VERTEX_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + if(_iter->cur_vid < _iter->vertex_list.vertex_num) + ++_iter->cur_vid; +} + +bool grin_is_vertex_list_end(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { + auto _iter = static_cast(iter); + return _iter->cur_vid == _iter->vertex_list.vertex_num; +} + +GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH g, + GRIN_VERTEX_LIST_ITERATOR iter) { + GRIN_VERTEX v; + auto _iter = static_cast(iter); + + v.label = _iter->vertex_list.label; + v.vid = _iter->cur_vid; + return v; +} +#endif \ No newline at end of file diff --git a/flex/grin/test/test.cc b/flex/grin/test/test.cc new file mode 100644 index 000000000000..c6fe3e445ebc --- /dev/null +++ b/flex/grin/test/test.cc @@ -0,0 +1,1058 @@ +#include +#include +#include +#include +#include "grin/src/predefine.h" +#include "../include/include/common/error.h" +#include "../include/include/index/internal_id.h" +#include "../include/include/index/label.h" +#include "../include/include/index/order.h" +#include "../include/include/index/pk.h" +#include "../include/include/partition/partition.h" +#include "../include/include/partition/reference.h" +#include "../include/include/partition/topology.h" +#include "../include/include/property/partition.h" +#include "../include/include/property/primarykey.h" +#include "../include/include/property/property.h" +#include "../include/include/property/propertylist.h" +#include "../include/include/property/row.h" +#include "../include/include/property/topology.h" +#include "../include/include/property/type.h" +#include "../include/include/topology/adjacentlist.h" +#include "../include/include/topology/edgelist.h" +#include "../include/include/topology/structure.h" +#include "../include/include/topology/vertexlist.h" +#include + +#define FOR_VERTEX_BEGIN(g, vl, v) \ + GRIN_VERTEX_LIST_ITERATOR __vli = grin_get_vertex_list_begin(g, vl); \ + unsigned __vcnt = 0; \ + while (!grin_is_vertex_list_end(g, __vli)) { \ + GRIN_VERTEX v = grin_get_vertex_from_iter(g, __vli); \ + +#ifdef GRIN_WITH_VERTEX_PROPERTY +#define FOR_VERTEX_END(g, vl, v) \ + grin_destroy_vertex(g, v); \ + __vcnt++; \ + grin_get_next_vertex_list_iter(g, __vli); \ + } \ + printf("vertex type %s, checked: %u\n", vt_names[__vtl_i], __vcnt); + +#define FOR_VERTEX_LIST_BEGIN(g, vl) \ +{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ +{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ +{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_mirror(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_END(g, vl) \ + grin_destroy_vertex_list(g, vl); \ + } \ + grin_destroy_vertex_type_list(g, __vtl);} +#else +#define FOR_VERTEX_END(g, vl) \ + grin_destroy_vertex(g, v); \ + __vcnt++; \ + grin_get_next_vertex_list_iter(g, __vli); \ + } \ + printf("vertex checked: %u\n", __vcnt); + +#define FOR_VERTEX_LIST_BEGIN(g, vl) \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list(g); + +#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_master(g); + +#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_mirror(g); + +#define FOR_VERTEX_LIST_END(g, vl) \ + grin_destroy_vertex_list(g, vl); +#endif + + + +#ifdef GRIN_WITH_EDGE_PROPERTY +#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ +{ GRIN_EDGE_TYPE_LIST __etl = grin_get_edge_type_list(g); \ + size_t __etl_size = grin_get_edge_type_list_size(g, __etl); \ + for (size_t __etl_i = 0; __etl_i < __etl_size; ++__etl_i) { \ + GRIN_EDGE_TYPE __et = grin_get_edge_type_from_list(g, __etl, __etl_i); \ + GRIN_ADJACENT_LIST al = grin_get_adjacent_list_by_edge_type(g, dir, v, __et); \ + grin_destroy_edge_type(g, __et); +#define FOR_ADJ_LIST_END(g, al) \ + grin_destroy_adjacent_list(g, al); \ + } \ + grin_destroy_edge_type_list(g, __etl);} +#else +#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ + GRIN_ADJACENT_LIST al = grin_get_adjacent_list(g, dir, v); +#define FOR_ADJ_LIST_END(g, al) \ + grin_destroy_adjacent_list(g, al); +#endif + + +const char *vt_names[] = {"person", "software"}; +const char *et_names[] = {"created", "knows"}; + +const char *v_names[][4] = { + {"josh", "vadas", "peter", "marko"}, + {"lop", "ripple", "wrong", "wrong"} +}; // TODO align with order in local graph + +GRIN_GRAPH get_graph(const char* uri_str, int p) { +#ifdef GRIN_ENABLE_GRAPH_PARTITION + GRIN_PARTITIONED_GRAPH pg = + grin_get_partitioned_graph_from_storage(argv[1]); + GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); + assert(p < grin_get_partition_list_size(pg, local_partitions)); + GRIN_PARTITION partition = + grin_get_partition_from_list(pg, local_partitions, p); + GRIN_PARTITION_ID partition_id = grin_get_partition_id(pg, partition); + GRIN_PARTITION p1 = grin_get_partition_by_id(pg, partition_id); + if (!grin_equal_partition(pg, partition, p1)) { + printf("partition not match\n"); + } + grin_destroy_partition(pg, p1); + GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition); + grin_destroy_partition(pg, partition); + grin_destroy_partition_list(pg, local_partitions); + grin_destroy_partitioned_graph(pg); +#else + GRIN_GRAPH g = grin_get_graph_from_storage(uri_str); +#endif + return g; +} + + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +GRIN_VERTEX get_one_master_person(GRIN_GRAPH g) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, vt); + grin_destroy_vertex_type(g, vt); + GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin(g, vl); + GRIN_VERTEX v = grin_get_vertex_from_iter(g, vli); + grin_destroy_vertex_list_iter(g, vli); + grin_destroy_vertex_list(g, vl); +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); +#endif + return v; +} +#endif + + +GRIN_VERTEX get_one_person(GRIN_GRAPH g) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, vt); + grin_destroy_vertex_type(g, vt); + GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin(g, vl); + GRIN_VERTEX v = grin_get_vertex_from_iter(g, vli); + grin_destroy_vertex_list_iter(g, vli); + grin_destroy_vertex_list(g, vl); +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); +#endif + return v; +} + + +void test_property_type(const char* uri_str) { + printf("+++++++++++++++++++++ Test property/type +++++++++++++++++++++\n"); + + GRIN_GRAPH g = get_graph(uri_str, 0); + + printf("------------ Vertex Type ------------\n"); + GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); + size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); + printf("vertex type list size: %zu\n", vtl_size); + + for (size_t i = 0; i < vtl_size; ++i) { + printf("------------ Iterate the %zu-th vertex type ------------\n", i); + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); +#ifdef GRIN_WITH_VERTEX_TYPE_NAME + const char* vt_name = grin_get_vertex_type_name(g, vt); + printf("vertex type name: %s\n", vt_name); + GRIN_VERTEX_TYPE vt0 = grin_get_vertex_type_by_name(g, vt_name); + if (!grin_equal_vertex_type(g, vt, vt0)) { + printf("vertex type name not match\n"); + } + grin_destroy_vertex_type(g, vt0); +#endif +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE + printf("vertex type id: %u\n", grin_get_vertex_type_id(g, vt)); + GRIN_VERTEX_TYPE vt1 = + grin_get_vertex_type_by_id(g, grin_get_vertex_type_id(g, vt)); + if (!grin_equal_vertex_type(g, vt, vt1)) { + printf("vertex type id not match\n"); + } + grin_destroy_vertex_type(g, vt1); +#endif + } + grin_destroy_vertex_type_list(g, vtl); + + printf( + "------------ Create a vertex type list of one type \"person\" " + "------------\n"); + GRIN_VERTEX_TYPE_LIST vtl2 = grin_create_vertex_type_list(g); +#ifdef GRIN_WITH_VERTEX_TYPE_NAME + GRIN_VERTEX_TYPE vt2_w = grin_get_vertex_type_by_name(g, "knows"); + if (vt2_w == GRIN_NULL_VERTEX_TYPE) { + printf("(Correct) vertex type of knows does not exists\n"); + } + + GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "person"); + if (vt2 == GRIN_NULL_VERTEX_TYPE) { + printf("(Wrong) vertex type of person can not be found\n"); + } else { + const char* vt2_name = grin_get_vertex_type_name(g, vt2); + printf("vertex type name: %s\n", vt2_name); + } +#else + GRIN_VERTEX_TYPE vt2 = get_one_vertex_type(g); +#endif + grin_insert_vertex_type_to_list(g, vtl2, vt2); + size_t vtl2_size = grin_get_vertex_type_list_size(g, vtl2); + printf("created vertex type list size: %zu\n", vtl2_size); + GRIN_VERTEX_TYPE vt3 = grin_get_vertex_type_from_list(g, vtl2, 0); + if (!grin_equal_vertex_type(g, vt2, vt3)) { + printf("vertex type not match\n"); + } + grin_destroy_vertex_type(g, vt2); + grin_destroy_vertex_type(g, vt3); + grin_destroy_vertex_type_list(g, vtl2); + + // edge + printf("------------ Edge Type ------------\n"); + GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); + size_t etl_size = grin_get_edge_type_list_size(g, etl); + printf("edge type list size: %zu\n", etl_size); + + for (size_t i = 0; i < etl_size; ++i) { + printf("------------ Iterate the %zu-th edge type ------------\n", i); + GRIN_EDGE_TYPE et = grin_get_edge_type_from_list(g, etl, i); +#ifdef GRIN_WITH_EDGE_TYPE_NAME + const char* et_name = grin_get_edge_type_name(g, et); + printf("edge type name: %s\n", et_name); + GRIN_EDGE_TYPE et0 = grin_get_edge_type_by_name(g, et_name); + if (!grin_equal_edge_type(g, et, et0)) { + printf("edge type name not match\n"); + } + grin_destroy_edge_type(g, et0); +#endif +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE + printf("edge type id: %u\n", grin_get_edge_type_id(g, et)); + GRIN_EDGE_TYPE et1 = + grin_get_edge_type_by_id(g, grin_get_edge_type_id(g, et)); + if (!grin_equal_edge_type(g, et, et1)) { + printf("edge type id not match\n"); + } + grin_destroy_edge_type(g, et1); +#endif + // relation + GRIN_VERTEX_TYPE_LIST src_vtl = grin_get_src_types_by_edge_type(g, et); + size_t src_vtl_size = grin_get_vertex_type_list_size(g, src_vtl); + printf("source vertex type list size: %zu\n", src_vtl_size); + + GRIN_VERTEX_TYPE_LIST dst_vtl = grin_get_dst_types_by_edge_type(g, et); + + size_t dst_vtl_size = grin_get_vertex_type_list_size(g, dst_vtl); + printf("destination vertex type list size: %zu\n", dst_vtl_size); + + if (src_vtl_size != dst_vtl_size) { + printf("source and destination vertex type list size not match\n"); + } + for (size_t j = 0; j < src_vtl_size; ++j) { + GRIN_VERTEX_TYPE src_vt = grin_get_vertex_type_from_list(g, src_vtl, j); + GRIN_VERTEX_TYPE dst_vt = grin_get_vertex_type_from_list(g, dst_vtl, j); + const char* src_vt_name = grin_get_vertex_type_name(g, src_vt); + const char* dst_vt_name = grin_get_vertex_type_name(g, dst_vt); + const char* et_name = grin_get_edge_type_name(g, et); + printf("edge type name: %s-%s-%s\n", src_vt_name, et_name, dst_vt_name); + grin_destroy_vertex_type(g, src_vt); + grin_destroy_vertex_type(g, dst_vt); + } + grin_destroy_vertex_type_list(g, src_vtl); + grin_destroy_vertex_type_list(g, dst_vtl); + } + grin_destroy_edge_type_list(g, etl); + + printf( + "------------ Create an edge type list of one type \"created\" " + "------------\n"); + GRIN_EDGE_TYPE_LIST etl2 = grin_create_edge_type_list(g); +#ifdef GRIN_WITH_EDGE_TYPE_NAME + GRIN_EDGE_TYPE et2_w = grin_get_edge_type_by_name(g, "person"); + if (et2_w == GRIN_NULL_EDGE_TYPE) { + printf("(Correct) edge type of person does not exists\n"); + } + GRIN_EDGE_TYPE et2 = grin_get_edge_type_by_name(g, "created"); + if (et2 == GRIN_NULL_EDGE_TYPE) { + printf("(Wrong) edge type of created can not be found\n"); + } else { + const char* et2_name = grin_get_edge_type_name(g, et2); + printf("edge type name: %s\n", et2_name); + } +#else + GRIN_EDGE_TYPE et2 = get_one_edge_type(g); +#endif + grin_insert_edge_type_to_list(g, etl2, et2); + size_t etl2_size = grin_get_edge_type_list_size(g, etl2); + printf("created edge type list size: %zu\n", etl2_size); + GRIN_EDGE_TYPE et3 = grin_get_edge_type_from_list(g, etl2, 0); + if (!grin_equal_edge_type(g, et2, et3)) { + printf("edge type not match\n"); + } + grin_destroy_edge_type(g, et2); + grin_destroy_edge_type(g, et3); + grin_destroy_edge_type_list(g, etl2); + + grin_destroy_graph(g); +} + +void test_property_vertex_property_value(const char* uri_str) { + printf("------------ Test Vertex property value ------------\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + +// value check + printf("------ check value ------\n"); +FOR_VERTEX_LIST_BEGIN(g, vl) + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, __vt); + size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + #else + long long int vid = __vcnt; + #endif + #ifdef GRIN_ENABLE_ROW + GRIN_ROW row = grin_get_vertex_row(g, v); + #endif + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); + if (dt == Int64) { + long long int pv = + grin_get_vertex_property_value_of_int64(g, v, vp); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + long long int rv = grin_get_int64_from_row(g, row, j); + assert(pv == rv); + #endif + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + printf("%s %s: %lld\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); + #else + printf("%s %zu: %lld\n", v_names[__vt][vid], j, pv); + #endif + } else if (dt == String) { + const char* pv = + grin_get_vertex_property_value_of_string(g, v, vp); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + const char* rv = grin_get_string_from_row(g, row, j); + assert(strcmp(pv, rv) == 0); + #endif + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + printf("%s %s: %s\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); + #else + printf("%s %zu: %s\n", v_names[__vt][vid], j, pv); + #endif + grin_destroy_string_value(g, pv); + grin_destroy_string_value(g, rv); + } + grin_destroy_vertex_property(g, vp); + } + #ifdef GRIN_ENABLE_ROW + grin_destroy_row(g, row); + #endif + FOR_VERTEX_END(g, vl, v) + grin_destroy_vertex_property_list(g, vpl); +FOR_VERTEX_LIST_END(g, vl) + +// check schema + printf("------ check schema ------\n"); + GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); + size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); + for (size_t i = 0; i < vtl_size; ++i) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, vt); + size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_from_property(g, vp); + assert(grin_equal_vertex_type(g, vt, vt1)); + grin_destroy_vertex_type(g, vt1); + + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY + unsigned int id = grin_get_vertex_property_id(g, vt, vp); + GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id); + assert(grin_equal_vertex_property(g, vp, vp1)); + grin_destroy_vertex_property(g, vp1); + #else + unsigned int id = i; + #endif + + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + const char* vp_name = grin_get_vertex_property_name(g, vt, vp); + GRIN_VERTEX_PROPERTY vp2 = + grin_get_vertex_property_by_name(g, vt, vp_name); + assert(grin_equal_vertex_property(g, vp, vp2)); + #else + const char* vp_name = "unknown"; + #endif + printf("%s %u %s checked\n", vt_names[i], id, vp_name); + } + grin_destroy_vertex_property_list(g, vpl); + + // corner case + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY + GRIN_VERTEX_PROPERTY vp3 = grin_get_vertex_property_by_id(g, vt, vpl_size); + assert(vp3 == GRIN_NULL_VERTEX_PROPERTY); + #endif + + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + GRIN_VERTEX_PROPERTY vp4 = + grin_get_vertex_property_by_name(g, vt, "unknown"); + assert(vp4 == GRIN_NULL_VERTEX_PROPERTY); + #endif + grin_destroy_vertex_type(g, vt); + } + grin_destroy_vertex_type_list(g, vtl); + + // corner case +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + GRIN_VERTEX_PROPERTY_LIST vpl1 = + grin_get_vertex_properties_by_name(g, "unknown"); + assert(vpl1 == GRIN_NULL_VERTEX_PROPERTY_LIST); + + GRIN_VERTEX_PROPERTY_LIST vpl2 = + grin_get_vertex_properties_by_name(g, "name"); + assert(vpl2 != GRIN_NULL_VERTEX_PROPERTY_LIST); + + size_t vpl2_size = grin_get_vertex_property_list_size(g, vpl2); + for (size_t i = 0; i < vpl2_size; ++i) { + GRIN_VERTEX_PROPERTY vp5 = + grin_get_vertex_property_from_list(g, vpl2, i); + GRIN_VERTEX_TYPE vt5 = grin_get_vertex_type_from_property(g, vp5); + const char* vp5_name = grin_get_vertex_property_name(g, vt5, vp5); + assert(strcmp(vp5_name, "name") == 0); + } + grin_destroy_vertex_property_list(g, vpl2); +#endif + + grin_destroy_graph(g); +} + +void test_property_edge_property_value(const char* uri_str, GRIN_DIRECTION dir) { + printf("------------ Test Edge property value ------------\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + +// value check + printf("------ check value ------\n"); +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + FOR_ADJ_LIST_BEGIN(g, dir, v, al) + GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, __et); + size_t epl_size = grin_get_edge_property_list_size(g, epl); + + GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); + size_t acnt = 0; + while (!grin_is_adjacent_list_end(g, ali)) { + GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); + GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); + #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + GRIN_VERTEX_TYPE ut = grin_get_vertex_type(g, u); + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + long long int uid = grin_get_vertex_internal_id_by_type(g, ut, u); + grin_destroy_vertex_type(g, ut); + #else + long long int vid = __vcnt; + long long int uid = acnt; + #endif + #ifdef GRIN_ENABLE_ROW + GRIN_ROW row = grin_get_edge_row(g, e); + #endif + for (size_t j = 0; j < epl_size; ++j) { + GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); + GRIN_DATATYPE dt = grin_get_edge_property_datatype(g, ep); + if (dt == Int64) { + long long int pv = + grin_get_edge_property_value_of_int64(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + long long int rv = grin_get_int64_from_row(g, row, j); + assert(pv == rv); + #endif + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %lld\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); + #else + printf("%s %zu %lld: %lld\n", v_names[__vt][vid], j, uid, pv); + #endif + } else if (dt == Double) { + double pv = grin_get_edge_property_value_of_double(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + double rv = grin_get_double_from_row(g, row, j); + assert(pv == rv); + #endif + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %lf\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); + #else + printf("%s %zu %lld: %lf\n", v_names[__vt][vid], j, uid, pv); + #endif + } else if (dt == String) { + const char* pv = grin_get_edge_property_value_of_string(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + const char* rv = grin_get_string_from_row(g, row, j); + assert(strcmp(pv, rv) == 0); + #endif + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %s\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); + #else + printf("%s %zu %lld: %s\n", v_names[__vt][vid], j, uid, pv); + #endif + } + } + #ifdef GRIN_ENABLE_ROW + grin_destroy_row(g, row); + #endif + grin_destroy_edge(g, e); + grin_destroy_vertex(g, u); + acnt++; + grin_get_next_adjacent_list_iter(g, ali); + } + grin_destroy_adjacent_list_iter(g, ali); + grin_destroy_edge_property_list(g, epl); + FOR_ADJ_LIST_END(g, al) + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + +// check schema + printf("------ check schema ------\n"); + GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); + size_t etl_size = grin_get_edge_type_list_size(g, etl); + for (size_t i = 0; i < etl_size; ++i) { + GRIN_EDGE_TYPE et = grin_get_edge_type_from_list(g, etl, i); + GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, et); + size_t epl_size = grin_get_edge_property_list_size(g, epl); + for (size_t j = 0; j < epl_size; ++j) { + GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); + GRIN_EDGE_TYPE et1 = grin_get_edge_type_from_property(g, ep); + assert(grin_equal_edge_type(g, et, et1)); + grin_destroy_edge_type(g, et1); + + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY + unsigned int id = grin_get_edge_property_id(g, et, ep); + GRIN_EDGE_PROPERTY ep1 = grin_get_edge_property_by_id(g, et, id); + assert(grin_equal_edge_property(g, ep, ep1)); + grin_destroy_edge_property(g, ep1); + #else + unsigned int id = i; + #endif + + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + const char* ep_name = grin_get_edge_property_name(g, et, ep); + GRIN_EDGE_PROPERTY ep2 = + grin_get_edge_property_by_name(g, et, ep_name); + assert(grin_equal_edge_property(g, ep, ep2)); + #else + const char* ep_name = "unknown"; + #endif + printf("%s %u %s checked\n", et_names[i], id, ep_name); + } + grin_destroy_edge_property_list(g, epl); + + // corner case + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY + GRIN_EDGE_PROPERTY ep3 = grin_get_edge_property_by_id(g, et, epl_size); + assert(ep3 == GRIN_NULL_EDGE_PROPERTY); + #endif + + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + GRIN_EDGE_PROPERTY ep4 = + grin_get_edge_property_by_name(g, et, "unknown"); + assert(ep4 == GRIN_NULL_EDGE_PROPERTY); + #endif + grin_destroy_edge_type(g, et); + } + grin_destroy_edge_type_list(g, etl); + + // corner case +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME + GRIN_EDGE_PROPERTY_LIST epl1 = + grin_get_edge_properties_by_name(g, "unknown"); + assert(epl1 == GRIN_NULL_EDGE_PROPERTY_LIST); + + GRIN_EDGE_PROPERTY_LIST epl2 = + grin_get_edge_properties_by_name(g, "weight"); + assert(epl2 != GRIN_NULL_EDGE_PROPERTY_LIST); + + size_t epl2_size = grin_get_edge_property_list_size(g, epl2); + for (size_t i = 0; i < epl2_size; ++i) { + GRIN_EDGE_PROPERTY ep5 = + grin_get_edge_property_from_list(g, epl2, i); + GRIN_EDGE_TYPE et5 = grin_get_edge_type_from_property(g, ep5); + const char* ep5_name = grin_get_edge_property_name(g, et5, ep5); + assert(strcmp(ep5_name, "weight") == 0); + } + grin_destroy_edge_property_list(g, epl2); +#endif + + grin_destroy_graph(g); +} + + + +#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS +void test_property_primary_key(const char* uri_str) { + printf( + "+++++++++++++++++++++ Test property/primary key " + "+++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_types_with_primary_keys(g); + size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); + printf("vertex type num with primary key: %zu\n", vtl_size); + + unsigned id_type[7] = {~0, 0, 0, 1, 0, 1, 0}; + + for (size_t i = 0; i < vtl_size; ++i) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); + const char* vt_name = grin_get_vertex_type_name(g, vt); + printf("vertex type name: %s\n", vt_name); + + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_primary_keys_by_vertex_type(g, vt); + size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); + assert(vpl_size == 1); + + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + const char* vp_name = grin_get_vertex_property_name(g, vt, vp); + printf("primary key name: %s\n", vp_name); + grin_destroy_vertex_property(g, vp); + } + + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, 0); + GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); + + for (size_t j = 1; j <= 6; ++j) { + GRIN_ROW r = grin_create_row(g); + assert(dt == Int64); + grin_insert_int64_to_row(g, r, j); +#ifdef GRIN_ENABLE_VERTEX_PK_INDEX + GRIN_VERTEX v = grin_get_vertex_by_primary_keys_row(g, vt, r); + if (v != GRIN_NULL_VERTEX && id_type[j] == i) { + GRIN_ROW nr = grin_get_vertex_primary_keys_row(g, v); + long long int k = grin_get_int64_from_row(g, nr, 0); + assert(k == j); + grin_destroy_row(g, nr); + grin_destroy_vertex(g, v); + } +#endif + grin_destroy_row(g, r); + } + + grin_destroy_vertex_property(g, vp); + grin_destroy_vertex_property_list(g, vpl); + grin_destroy_vertex_type(g, vt); + } + + grin_destroy_vertex_type_list(g, vtl); + grin_destroy_graph(g); +} +#endif + +void test_error_code(const char* uri_str) { + printf("+++++++++++++++++++++ Test error code +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + + GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "software"); + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt2, "lang"); +#ifdef GRIN_ENABLE_GRAPH_PARTITION + GRIN_VERTEX v = get_one_master_person(g); +#else + GRIN_VERTEX v = get_one_person(g); +#endif + + const char* value = grin_get_vertex_property_value_of_string(g, v, vp); + assert(grin_get_last_error_code() == INVALID_VALUE); +} + + +void test_property(const char* uri_str) { + test_property_type(uri_str); + test_property_vertex_property_value(uri_str); + test_property_edge_property_value(uri_str, OUT); + test_property_edge_property_value(uri_str, IN); +#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS + test_property_primary_key(uri_str); +#endif +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + test_error_code(uri_str); +#endif +} + +/** +void test_partition_reference(const char* uri_str) { + printf("+++++++++++++++++++++ Test partition/reference +++++++++++++++++++++\n"); + GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(argv[1]); + GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); + assert(grin_get_partition_list_size(pg, local_partitions) >= 2); + + GRIN_PARTITION p0 = grin_get_partition_from_list(pg, local_partitions, 0); + GRIN_PARTITION p1 = grin_get_partition_from_list(pg, local_partitions, 1); + GRIN_GRAPH g0 = grin_get_local_graph_by_partition(pg, p0); + GRIN_GRAPH g1 = grin_get_local_graph_by_partition(pg, p1); + +FOR_VERTEX_LIST_BEGIN(g0, vl0) + size_t mcnt = 0; + FOR_VERTEX_BEGIN(g0, vl0, v0) + GRIN_VERTEX_REF vref0 = grin_get_vertex_ref_by_vertex(g0, v0); + if (grin_is_master_vertex(g0, v0)) { + mcnt++; +#ifdef GRIN_TRAIT_FAST_VERTEX_REF + long long int sref = grin_serialize_vertex_ref_as_int64(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_int64_to_vertex_ref(g0, sref); +#else + const char* sref = grin_serialize_vertex_ref(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_vertex_ref(g0, sref); + grin_destroy_string_value(g0, sref); +#endif + GRIN_VERTEX v1 = grin_get_vertex_from_vertex_ref(g0, vref1); + if (!grin_equal_vertex(g0, v0, v1)) { + printf("vertex not match after deserialize\n"); + } + GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); + if (!grin_equal_partition(g0, p, p0)) { + printf("(Wrong) partition not match in vertex ref\n"); + } + grin_destroy_partition(pg, p); + grin_destroy_vertex(g0, v1); + grin_destroy_vertex_ref(g0, vref1); + } else if (grin_is_mirror_vertex(g0, v0)) { +#ifdef GRIN_TRAIT_FAST_VERTEX_REF + long long int sref = grin_serialize_vertex_ref_as_int64(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_int64_to_vertex_ref(g1, sref); +#else + const char* sref = grin_serialize_vertex_ref(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_vertex_ref(g1, sref); + grin_destroy_string_value(g0, sref); +#endif + GRIN_VERTEX v1 = grin_get_vertex_from_vertex_ref(g1, vref1); + if (!grin_is_master_vertex(g1, v1)) { + printf("(Wrong) vertex not master after deserialize\n"); + } + GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); + if (!grin_equal_partition(g0, p, p1)) { + printf("(Wrong) partition not match in vertex ref\n"); + } + grin_destroy_partition(pg, p); + grin_destroy_vertex(g1, v1); + grin_destroy_vertex_ref(g1, vref1); + } else { + printf("(Wrong) vertex other than master or mirror\n"); + } + grin_destroy_vertex_ref(g0, vref0); + FOR_VERTEX_END(g0, vl0, v0) + printf("master checked: %zu\n", mcnt); +FOR_VERTEX_LIST_END(g0, vl0) + + grin_destroy_partition(pg, p0); + grin_destroy_partition(pg, p1); + grin_destroy_graph(g0); + grin_destroy_graph(g1); + grin_destroy_partition_list(pg, local_partitions); + grin_destroy_partitioned_graph(pg); +} + + +void test_partition_topology(const char* uri_str) { + printf("+++++++++++++++++++++ Test partition/topology +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + + printf("----- check master ----- \n"); +FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + #endif + assert(grin_is_master_vertex(g, v)); + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + printf("----- check mirror ----- \n"); +FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + #endif + assert(grin_is_mirror_vertex(g, v)); + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} + +void test_partition(const char* uri_str) { +#ifdef GRIN_ENABLE_GRAPH_PARTITION + test_partition_reference(uri_str); + test_partition_topology(uri_str); +#endif +}*/ + + +void test_topology_structure(const char* uri_str) { + printf("+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); +#ifndef GRIN_WITH_VERTEX_PROPERTY + printf("vertex num: %zu\n", grin_get_vertex_num(g)); +#endif + +#ifndef GRIN_WITH_EDGE_PROPERTY + printf("edge num: %zu\n", grin_get_edge_num(g)); +#endif + grin_destroy_graph(g); +} + + +void test_topology_vertex_list(const char* uri_str) { + printf("+++++++++++++++++++++ Test topology/vertex_list +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + #endif + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} + + +void test_topology_adjacent_list(const char* uri_str, GRIN_DIRECTION dir) { + if (dir == IN) { + printf("+++++++++++++++++++++ Test topology/adjacent_list IN +++++++++++++++++++++\n"); + } else { + printf("+++++++++++++++++++++ Test topology/adjacent_list OUT +++++++++++++++++++++\n"); + } + + GRIN_GRAPH g = get_graph(uri_str, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + #else + long long int vid = __vcnt; + #endif + #ifdef GRIN_ENABLE_GRAPH_PARTITION + if (!grin_is_master_vertex(g, v)) { + grin_destroy_vertex(g, v); + grin_get_next_vertex_list_iter(g, __vli); + continue; + } + #endif + FOR_ADJ_LIST_BEGIN(g, dir, v, al) + GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); + size_t acnt = 0; + while (!grin_is_adjacent_list_end(g, ali)) { + GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); + GRIN_VERTEX v1 = grin_get_src_vertex_from_edge(g, e); + GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge(g, e); + GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); + + #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY + GRIN_EDGE e1 = grin_get_edge_from_adjacent_list(g, al, acnt); + GRIN_VERTEX e1v1 = grin_get_src_vertex_from_edge(g, e1); + GRIN_VERTEX e1v2 = grin_get_dst_vertex_from_edge(g, e1); + assert(grin_equal_vertex(g, v1, e1v1)); + assert(grin_equal_vertex(g, v2, e1v2)); + grin_destroy_edge(g, e1); + grin_destroy_vertex(g, e1v1); + grin_destroy_vertex(g, e1v2); + #endif + + if (dir == OUT) { + assert(grin_equal_vertex(g, v, v1)); + assert(grin_equal_vertex(g, v2, u)); + } else { + assert(grin_equal_vertex(g, v, v2)); + assert(grin_equal_vertex(g, v1, u)); + } + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v2); + grin_destroy_vertex(g, u); + grin_destroy_edge(g, e); + + acnt++; + grin_get_next_adjacent_list_iter(g, ali); + } + #ifdef GRIN_ENABLE_ADJAECENT_LIST_ARRAY + assert(acnt == grin_get_adjacent_list_size(g, al)); + #endif + grin_destroy_adjacent_list_iter(g, ali); + #ifdef GRIN_WITH_EDGE_PROPERTY + printf("vertex %s adjlist, edgetype: %s, checked num: %zu\n", v_names[__vt][vid], et_names[__etl_i], acnt); + #else + printf("vertex %s adjlist, checked num: %zu\n", v_names[__vt][vid], acnt); + #endif + FOR_ADJ_LIST_END(g, al) + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + grin_destroy_graph(g); +} + + +void test_topology(const char* uri_str) { + test_topology_structure(uri_str); + test_topology_vertex_list(uri_str); + test_topology_adjacent_list(uri_str, OUT); + test_topology_adjacent_list(uri_str, IN); +} + +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) +void test_index_order(const char* uri_str) { + printf("+++++++++++++++++++++ Test index order +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + assert(pos == __vcnt); + FOR_VERTEX_END(g, vl, v) + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +{ + GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_master(g, __vt); + size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); + for (size_t i = 0; i < mvlist_sz; ++i) { + GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); + assert(pos == i); + size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v); + } + grin_destroy_vertex_list(g, mvlist); +} +{ + GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_mirror(g, __vt); + size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); + for (size_t i = 0; i < mvlist_sz; ++i) { + GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); + assert(pos == i); + size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v); + } + grin_destroy_vertex_list(g, mvlist); +} +#endif +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} +#endif + +void test_index_internal_id(const char* uri_str) { + printf("+++++++++++++++++++++ Test index internal id +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(uri_str, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + long long int min = grin_get_vertex_internal_id_lower_bound_by_type(g, __vt); + long long int max = grin_get_vertex_internal_id_upper_bound_by_type(g, __vt); + FOR_VERTEX_BEGIN(g, vl, v) +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int oid = grin_get_vertex_internal_id_by_type(g, __vt, v); + assert(oid >= min && oid < max); + GRIN_VERTEX v1 = grin_get_vertex_by_internal_id_by_type(g, __vt, oid); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); +#endif + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} + + +void test_index(const char* uri_str) { +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) + test_index_order(uri_str); +#endif +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + test_index_internal_id(uri_str); +#endif +} + +void test_vertex_property_value(const char* uri_str) { + GRIN_GRAPH g = get_graph(uri_str, 0); + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt, "age"); + GRIN_VERTEX v = get_one_person(g); + + struct timeval t1, t2; + gettimeofday(&t1, NULL); + for (int i = 0; i < 1000000; ++i) { + long long int age = grin_get_vertex_property_value_of_int32(g, v, vp); + } + gettimeofday(&t2, NULL); + double elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; + elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; + printf("%f ms.\n", elapsedTime); + grin_destroy_vertex(g, v); + grin_destroy_vertex_property(g, vp); + grin_destroy_vertex_type(g, vt); + grin_destroy_graph(g); +} + +void test_perf(const char* uri_str) { + test_vertex_property_value(uri_str); +} + +int main(int argc, char** argv) { + const char* uri_str = + "flex://" + "/Users/liulx/Downloads/code/GraphScope/flex/storages/rt_mutable_graph/modern_graph"; + + test_index(uri_str); + test_property(uri_str); + //test_partition(uri_str); + test_topology(uri_str); + test_perf(uri_str); + return 0; +} diff --git a/flex/storages/rt_mutable_graph/mutable_csr.cc b/flex/storages/rt_mutable_graph/mutable_csr.cc index c499453eb5db..8b84f9fd4461 100644 --- a/flex/storages/rt_mutable_graph/mutable_csr.cc +++ b/flex/storages/rt_mutable_graph/mutable_csr.cc @@ -170,4 +170,7 @@ template class MutableCsr; template class SingleMutableCsr; template class MutableCsr; +template class SingleMutableCsr; +template class MutableCsr; + } // namespace gs diff --git a/flex/storages/rt_mutable_graph/mutable_csr.h b/flex/storages/rt_mutable_graph/mutable_csr.h index 469b62613c4d..793145afa48c 100644 --- a/flex/storages/rt_mutable_graph/mutable_csr.h +++ b/flex/storages/rt_mutable_graph/mutable_csr.h @@ -34,7 +34,7 @@ template struct MutableNbr { MutableNbr() = default; MutableNbr(const MutableNbr& rhs) - : neighbor(rhs.neighbor), timestamp(rhs.timestamp.load()), data(data) {} + : neighbor(rhs.neighbor), timestamp(rhs.timestamp.load()), data(rhs.data) {} ~MutableNbr() = default; vid_t neighbor; diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index 65dd00c6f2bc..5742eee06aa5 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -46,6 +46,7 @@ void MutablePropertyFragment::initVertices( auto& table = vertex_data_[v_label_i]; auto& property_types = schema_.get_vertex_properties(v_label_name); size_t col_num = property_types.size(); + std::vector col_names; for (size_t col_i = 0; col_i < col_num; ++col_i) { col_names.push_back("col_" + std::to_string(col_i)); @@ -270,6 +271,17 @@ void MutablePropertyFragment::initEdges( } else { LOG(FATAL) << "Unsupported edge property type."; } + } else if (property_types[0] == PropertyType::kDouble) { + if (filenames.empty()) { + std::tie(ie_[index], oe_[index]) = + construct_empty_csr(ie_strtagy, oe_strtagy); + } else { + std::tie(ie_[index], oe_[index]) = construct_csr( + filenames, property_types, ie_strtagy, oe_strtagy, + lf_indexers_[src_label_i], lf_indexers_[dst_label_i]); + +// LOG(FATAL) << "Unsupported edge property type."; + } } else { LOG(FATAL) << "Unsupported edge property type."; } diff --git a/flex/storages/rt_mutable_graph/schema.cc b/flex/storages/rt_mutable_graph/schema.cc index 0c9bf25b6a03..099c9f5c4cc1 100644 --- a/flex/storages/rt_mutable_graph/schema.cc +++ b/flex/storages/rt_mutable_graph/schema.cc @@ -358,7 +358,9 @@ static PropertyType StringToPropertyType(const std::string& str) { return PropertyType::kEmpty; } else if (str == "int64") { return PropertyType::kInt64; - } else { + } else if (str == "double"){ + return PropertyType::kDouble; + }else { return PropertyType::kEmpty; } } diff --git a/flex/utils/property/column.h b/flex/utils/property/column.h index 2101ef8b2da5..9bd073cefc6e 100644 --- a/flex/utils/property/column.h +++ b/flex/utils/property/column.h @@ -96,6 +96,7 @@ using IntColumn = TypedColumn; using LongColumn = TypedColumn; using DateColumn = TypedColumn; using StringColumn = TypedColumn; +using DoubleColumn = TypedColumn; std::shared_ptr CreateColumn( PropertyType type, StorageStrategy strategy = StorageStrategy::kMem); diff --git a/flex/utils/property/types.cc b/flex/utils/property/types.cc index dd6e68a4216f..68a4f72812d0 100644 --- a/flex/utils/property/types.cc +++ b/flex/utils/property/types.cc @@ -40,6 +40,10 @@ inline void ParseString(const std::string_view& str, std::string_view& val) { val = str; } +inline void ParseDouble(const std::string_view& str, double& val){ + sscanf(str.data(), "%lf", &val); +} + void ParseRecord(const char* line, std::vector& rec) { const char* cur = line; for (auto& item : rec) { @@ -56,6 +60,8 @@ void ParseRecord(const char* line, std::vector& rec) { ParseDate(sv, item.value.d); } else if (item.type == PropertyType::kString) { ParseString(sv, item.value.s); + } else if (item.type == PropertyType::kDouble) { + ParseDouble(sv,item.value.db); } cur = ptr + 1; } @@ -102,6 +108,10 @@ void ParseRecordX(const char* line, int64_t& src, int64_t& dst, #endif } +void ParseRecordX(const char* line, int64_t& src, int64_t& dst, double& prop) { + sscanf(line, "%lld|%lld|%lf", &src, &dst, &prop); +} + grape::InArchive& operator<<(grape::InArchive& in_archive, const Any& value) { switch (value.type) { case PropertyType::kInt32: @@ -116,6 +126,9 @@ grape::InArchive& operator<<(grape::InArchive& in_archive, const Any& value) { case PropertyType::kString: in_archive << value.type << value.value.s; break; + case PropertyType::kDouble: + in_archive << value.type << value.value.db; + break; default: in_archive << PropertyType::kEmpty; break; @@ -139,6 +152,9 @@ grape::OutArchive& operator>>(grape::OutArchive& out_archive, Any& value) { case PropertyType::kString: out_archive >> value.value.s; break; + case PropertyType::kDouble: + out_archive >> value.value.db; + break; default: break; } diff --git a/flex/utils/property/types.h b/flex/utils/property/types.h index 2835a1eda7a5..51d9b3ffcb6d 100644 --- a/flex/utils/property/types.h +++ b/flex/utils/property/types.h @@ -38,6 +38,7 @@ enum class PropertyType { kString, kEmpty, kInt64, + kDouble, }; struct Date { @@ -60,6 +61,7 @@ union AnyValue { int64_t l; Date d; std::string_view s; + double db; }; template struct AnyConverter; @@ -97,6 +99,11 @@ struct Any { value.s = v; } + void set_double(double db){ + type = PropertyType::kDouble; + value.db = db; + } + std::string to_string() const { if (type == PropertyType::kInt32) { return std::to_string(value.i); @@ -109,6 +116,8 @@ struct Any { return value.d.to_string(); } else if (type == PropertyType::kEmpty) { return "NULL"; + } else if (type == PropertyType::kDouble){ + return std::to_string(value.db); } else { LOG(FATAL) << "Unexpected property type: " << static_cast(type); return ""; @@ -125,6 +134,11 @@ struct Any { return value.l; } + double AsDouble() const { + assert(type == PropertyType::kDouble); + return value.db; + } + const std::string_view &AsStringView() const { assert(type == PropertyType::kString); return value.s; @@ -156,6 +170,7 @@ template <> struct ConvertAny { } }; + template <> struct ConvertAny { static void to(const Any &value, int64_t &out) { CHECK(value.type == PropertyType::kInt64); @@ -183,6 +198,13 @@ template <> struct ConvertAny { } }; +template <> struct ConvertAny { + static void to(const Any& value, double& out){ + CHECK(value.type == PropertyType::kDouble); + out = value.value.db; + } +}; + template struct AnyConverter {}; template <> struct AnyConverter { @@ -329,6 +351,31 @@ template <> struct AnyConverter { } }; +template <> struct AnyConverter { + static constexpr PropertyType type = PropertyType::kDouble; + + static Any to_any(const double &value) { + Any ret; + ret.set_long(value); + return ret; + } + + static AnyValue to_any_value(const double &value) { + AnyValue ret; + ret.db = value; + return ret; + } + + static const double &from_any(const Any &value) { + CHECK(value.type == PropertyType::kDouble); + return value.value.db; + } + + static const double &from_any_value(const AnyValue &value) { + return value.db; + } +}; + void ParseRecord(const char *line, std::vector &rec); void ParseRecord(const char *line, int64_t &id, std::vector &rec); @@ -339,6 +386,7 @@ void ParseRecordX(const char *line, int64_t &src, int64_t &dst, Date &prop); void ParseRecordX(const char *line, int64_t &src, int64_t &dst, grape::EmptyType &prop); +void ParseRecordX(const char* line, int64_t& src, int64_t& dst, double& prop); grape::InArchive &operator<<(grape::InArchive &in_archive, const Any &value); grape::OutArchive &operator>>(grape::OutArchive &out_archive, Any &value); @@ -369,6 +417,9 @@ inline ostream &operator<<(ostream &os, gs::PropertyType pt) { case gs::PropertyType::kEmpty: os << "Empty"; break; + case gs::PropertyType::kDouble: + os << "double"; + break; default: os << "Unknown"; break; From e877065153af8e940ea37ada518471a4a150450d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Thu, 13 Jul 2023 18:08:22 +0800 Subject: [PATCH 02/30] add pk interfaces --- .../graph_db/database/transaction_utils.h | 6 + flex/grin/predefine.h | 102 ++- flex/grin/src/index/internal_id.cc | 9 +- flex/grin/src/index/pk.cc | 45 ++ flex/grin/src/predefine.cc | 29 +- flex/grin/src/predefine.h | 76 +- flex/grin/src/property/primarykey.cc | 66 ++ flex/grin/src/property/property.cc | 300 +++---- flex/grin/src/property/propertylist.cc | 69 +- flex/grin/src/property/row.cc | 53 +- flex/grin/src/property/topology.cc | 44 +- flex/grin/src/property/type.cc | 112 +-- flex/grin/src/topology/adjacentlist.cc | 93 ++- flex/grin/src/topology/structure.cc | 152 ++-- flex/grin/src/topology/vertexlist.cc | 22 +- flex/grin/test/test.cc | 756 +++++++++--------- flex/storages/rt_mutable_graph/mutable_csr.h | 4 +- .../mutable_property_fragment.cc | 4 +- flex/storages/rt_mutable_graph/schema.cc | 4 +- flex/utils/property/types.h | 162 ++-- 20 files changed, 1134 insertions(+), 974 deletions(-) create mode 100644 flex/grin/src/index/pk.cc create mode 100644 flex/grin/src/property/primarykey.cc diff --git a/flex/engines/graph_db/database/transaction_utils.h b/flex/engines/graph_db/database/transaction_utils.h index 68aa215bca64..f219414f15ec 100644 --- a/flex/engines/graph_db/database/transaction_utils.h +++ b/flex/engines/graph_db/database/transaction_utils.h @@ -39,6 +39,9 @@ inline void serialize_field(grape::InArchive& arc, const Any& prop) { case PropertyType::kInt64: arc << prop.value.l; break; + case PropertyType::kDouble: + arc << prop.value.db; + break; default: LOG(FATAL) << "Unexpected property type"; } @@ -60,6 +63,9 @@ inline void deserialize_field(grape::OutArchive& arc, Any& prop) { case PropertyType::kInt64: arc >> prop.value.l; break; + case PropertyType::kDouble: + arc >> prop.value.db; + break; default: LOG(FATAL) << "Unexpected property type"; } diff --git a/flex/grin/predefine.h b/flex/grin/predefine.h index 5d2b9a5aaa1a..f5a5aa6c48e6 100644 --- a/flex/grin/predefine.h +++ b/flex/grin/predefine.h @@ -35,32 +35,32 @@ extern "C" { /* 1. Predefined enumerate types of GRIN */ /// Enumerates the directions of edges with respect to a certain vertex typedef enum { - IN = 0, ///< incoming - OUT = 1, ///< outgoing - BOTH = 2, ///< incoming & outgoing + IN = 0, ///< incoming + OUT = 1, ///< outgoing + BOTH = 2, ///< incoming & outgoing } GRIN_DIRECTION; /// Enumerates the datatype supported in the storage typedef enum { - Undefined = 0, ///< other unknown types - Int32 = 1, ///< int - UInt32 = 2, ///< unsigned int - Int64 = 3, ///< long int - UInt64 = 4, ///< unsigned long int - Float = 5, ///< float - Double = 6, ///< double - String = 7, ///< string - Date32 = 8, ///< date - Time32 = 9, ///< Time32 - Timestamp64 = 10, ///< Timestamp + Undefined = 0, ///< other unknown types + Int32 = 1, ///< int + UInt32 = 2, ///< unsigned int + Int64 = 3, ///< long int + UInt64 = 4, ///< unsigned long int + Float = 5, ///< float + Double = 6, ///< double + String = 7, ///< string + Date32 = 8, ///< date + Time32 = 9, ///< Time32 + Timestamp64 = 10, ///< Timestamp } GRIN_DATATYPE; /// Enumerates the error codes of grin typedef enum { - NO_ERROR = 0, ///< success - UNKNOWN_ERROR = 1, ///< unknown error - INVALID_VALUE = 2, ///< invalid value - UNKNOWN_DATATYPE = 3, ///< unknown datatype + NO_ERROR = 0, ///< success + UNKNOWN_ERROR = 1, ///< unknown error + INVALID_VALUE = 2, ///< invalid value + UNKNOWN_DATATYPE = 3, ///< unknown datatype } GRIN_ERROR_CODE; /* 2. Define supported macros based on storage features */ @@ -68,16 +68,16 @@ typedef enum { #define GRIN_ASSUME_HAS_DIRECTED_GRAPH #define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH #define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -//#define GRIN_WITH_VERTEX_DATA +// #define GRIN_WITH_VERTEX_DATA #define GRIN_WITH_EDGE_DATA #define GRIN_ENABLE_VERTEX_LIST -//#define GRIN_ENABLE_VERTEX_LIST_ARRAY +// #define GRIN_ENABLE_VERTEX_LIST_ARRAY #define GRIN_ENABLE_VERTEX_LIST_ITERATOR #define GRIN_ENABLE_EDGE_LIST -//#define GRIN_ENABLE_EDGE_LIST_ARRAY +// #define GRIN_ENABLE_EDGE_LIST_ARRAY #define GRIN_ENABLE_EDGE_LIST_ITERATOR #define GRIN_ENABLE_ADJACENT_LIST -//#define GRIN_ENABLE_ADJACENT_LIST_ARRAY +// #define GRIN_ENABLE_ADJACENT_LIST_ARRAY #define GRIN_ENABLE_ADJACENT_LIST_ITERATOR // Partition @@ -115,43 +115,38 @@ typedef enum { #define GRIN_WITH_VERTEX_PROPERTY_NAME #define GRIN_WITH_VERTEX_TYPE_NAME #define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -//#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS +#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS #define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY #define GRIN_WITH_EDGE_PROPERTY -//#define GRIN_WITH_EDGE_PROPERTY_NAME +// #define GRIN_WITH_EDGE_PROPERTY_NAME #define GRIN_WITH_EDGE_TYPE_NAME #define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -//#define GRIN_ENABLE_EDGE_PRIMARY_KEYS -//#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -//#define GRIN_TRAIT_SPECIFIC_VEV_RELATION -//#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY -//#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY -//#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY -//#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY -//#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY -//#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY -// Index +// #define GRIN_ENABLE_EDGE_PRIMARY_KEYS +// #define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +// #define GRIN_TRAIT_SPECIFIC_VEV_RELATION +// #define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY +// #define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +// #define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +// #define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY +// #define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +// #define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +// Index #define GRIN_WITH_VERTEX_LABEL #define GRIN_WITH_EDGE_LABEL -///#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED +/// #define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED #define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX -//#define GRIN_ENABLE_VERTEX_PK_INDEX -//#define GRIN_ENABLE_EDGE_PK_INDEX +#define GRIN_ENABLE_VERTEX_PK_INDEX +// #define GRIN_ENABLE_EDGE_PK_INDEX /* 3. Define the handles using typedef */ typedef void* GRIN_GRAPH; -typedef struct GRIN_VERTEX{ - uint8_t label; - uint32_t vid; -} GRIN_VERTEX; // vid? -//typedef void* GRIN_EDGE; +typedef void* GRIN_VERTEX; typedef void* GRIN_EDGE; #ifdef GRIN_WITH_VERTEX_DATA typedef void* GRIN_VERTEX_DATA; #endif - #ifdef GRIN_WITH_VERTEX_PROPERTY typedef unsigned GRIN_VERTEX_TYPE; typedef void* GRIN_VERTEX_TYPE_LIST; @@ -160,7 +155,7 @@ typedef void* GRIN_VERTEX_PROPERTY_LIST; #endif #ifdef GRIN_ENABLE_VERTEX_LIST -typedef struct{ +typedef struct GRIN_VERTEX_LIST { size_t vertex_num; GRIN_VERTEX_TYPE label; } GRIN_VERTEX_LIST; @@ -210,7 +205,6 @@ typedef void* GRIN_VERTEX_REF; typedef void* GRIN_EDGE_REF; #endif - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE typedef GRIN_VERTEX_TYPE GRIN_VERTEX_TYPE_ID; #endif @@ -218,14 +212,14 @@ typedef GRIN_VERTEX_TYPE GRIN_VERTEX_TYPE_ID; #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY typedef unsigned GRIN_VERTEX_PROPERTY_ID; #endif -typedef unsigned GRIN_EDGE_TYPE; + #ifdef GRIN_WITH_EDGE_PROPERTY typedef unsigned GRIN_EDGE_TYPE; typedef void* GRIN_EDGE_TYPE_LIST; typedef void* GRIN_VEV_TYPE; typedef void* GRIN_VEV_TYPE_LIST; typedef unsigned GRIN_EDGE_PROPERTY; -typedef unsigned GRIN_EDGE_PROPERTY_LIST; +typedef void* GRIN_EDGE_PROPERTY_LIST; #endif #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE @@ -260,27 +254,27 @@ typedef void* GRIN_LABEL_LIST; #define GRIN_NULL_PARTITIONED_GRAPH NULL #define GRIN_NULL_PARTITION NULL #define GRIN_NULL_PARTITION_LIST NULL -#define GRIN_NULL_PARTITION_ID (unsigned)~0 +#define GRIN_NULL_PARTITION_ID (unsigned) ~0 #define GRIN_NULL_VERTEX_REF NULL #define GRIN_NULL_EDGE_REF NULL #define GRIN_NULL_VERTEX_TYPE (unsigned) ~0 #define GRIN_NULL_VERTEX_TYPE_LIST NULL #define GRIN_NULL_VERTEX_PROPERTY NULL #define GRIN_NULL_VERTEX_PROPERTY_LIST NULL -#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_EDGE_TYPE (unsigned)~0 +#define GRIN_NULL_VERTEX_TYPE_ID (unsigned) ~0 +#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned) ~0 +#define GRIN_NULL_EDGE_TYPE (unsigned) ~0 #define GRIN_NULL_EDGE_TYPE_LIST NULL #define GRIN_NULL_VEV_TYPE NULL #define GRIN_NULL_VEV_TYPE_LIST NULL #define GRIN_NULL_EDGE_PROPERTY NULL #define GRIN_NULL_EDGE_PROPERTY_LIST NULL -#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 -#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE_ID (unsigned) ~0 +#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned) ~0 #define GRIN_NULL_ROW NULL #define GRIN_NULL_LABEL NULL #define GRIN_NULL_LABEL_LIST NULL -#define GRIN_NULL_SIZE (unsigned)~0 +#define GRIN_NULL_SIZE (unsigned) ~0 #define GRIN_NULL_NAME NULL #ifdef __cplusplus diff --git a/flex/grin/src/index/internal_id.cc b/flex/grin/src/index/internal_id.cc index f5ae9e286d30..400f6174471d 100644 --- a/flex/grin/src/index/internal_id.cc +++ b/flex/grin/src/index/internal_id.cc @@ -59,7 +59,8 @@ long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH); long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX v) { - return v.vid; + auto _v = static_cast(v); + return _v->vid; } /** @@ -72,9 +73,9 @@ long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH g, GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, long long int id) { - GRIN_VERTEX v; - v.label = vt; - v.vid = id; + GRIN_VERTEX_T* v = new GRIN_VERTEX_T(); + v->label = vt; + v->vid = id; return v; } diff --git a/flex/grin/src/index/pk.cc b/flex/grin/src/index/pk.cc new file mode 100644 index 000000000000..196185d85df5 --- /dev/null +++ b/flex/grin/src/index/pk.cc @@ -0,0 +1,45 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include "grin/src/predefine.h" + +#include "grin/include/include/index/pk.h" + +#if defined(GRIN_ENABLE_VERTEX_PK_INDEX) && \ + defined(GRIN_ENABLE_VERTEX_PRIMARY_KEYS) +/** + * @brief Get the vertex by primary keys row. + * The values in the row must be in the same order as the primary keys + * properties, which can be obtained by + * ``grin_get_primary_keys_by_vertex_type``. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @param GRIN_ROW The values row of primary keys properties. + * @return The vertex. + */ +GRIN_VERTEX grin_get_vertex_by_primary_keys_row(GRIN_GRAPH g, + GRIN_VERTEX_TYPE label, + GRIN_ROW r) { + auto _r = static_cast(r); + auto _g = static_cast(g); + auto oid = *static_cast((*_r)[0]); + uint32_t vid; + + if (!_g->get_lid(label, oid, vid)) { + return GRIN_NULL_VERTEX; + } + GRIN_VERTEX_T* v = new GRIN_VERTEX_T(); + v->label = label; + v->vid = vid; + return v; +} +#endif \ No newline at end of file diff --git a/flex/grin/src/predefine.cc b/flex/grin/src/predefine.cc index bc75aba091a9..8afdc169258e 100644 --- a/flex/grin/src/predefine.cc +++ b/flex/grin/src/predefine.cc @@ -1,18 +1,17 @@ #include "grin/src/predefine.h" -GRIN_DATATYPE _get_data_type(const gs::PropertyType& type){ - if(type == gs::PropertyType::kInt32){ - return GRIN_DATATYPE::Int32; - }else if(type == gs::PropertyType::kInt64){ - return GRIN_DATATYPE::Int64; - }else if(type == gs::PropertyType::kString){ - return GRIN_DATATYPE::String; - }else if(type == gs::PropertyType::kDate){ - return GRIN_DATATYPE::Timestamp64; - }else if(type == gs::PropertyType::kDouble){ - return GRIN_DATATYPE::Double; - }else { - return GRIN_DATATYPE::Undefined; - } - +GRIN_DATATYPE _get_data_type(const gs::PropertyType& type) { + if (type == gs::PropertyType::kInt32) { + return GRIN_DATATYPE::Int32; + } else if (type == gs::PropertyType::kInt64) { + return GRIN_DATATYPE::Int64; + } else if (type == gs::PropertyType::kString) { + return GRIN_DATATYPE::String; + } else if (type == gs::PropertyType::kDate) { + return GRIN_DATATYPE::Timestamp64; + } else if (type == gs::PropertyType::kDouble) { + return GRIN_DATATYPE::Double; + } else { + return GRIN_DATATYPE::Undefined; + } } \ No newline at end of file diff --git a/flex/grin/src/predefine.h b/flex/grin/src/predefine.h index ab5e17e535dc..47a86a956005 100644 --- a/flex/grin/src/predefine.h +++ b/flex/grin/src/predefine.h @@ -7,79 +7,40 @@ typedef gs::vid_t GRIN_VID_T; typedef gs::MutablePropertyFragment GRIN_GRAPH_T; -typedef struct GRIN_EDGE_T{ - GRIN_VERTEX dst; - GRIN_VERTEX src; - GRIN_DIRECTION dir; - gs::label_t label; - gs::Any data; -} GRIN_EDGE_T; +typedef struct GRIN_VERTEX_T { + uint8_t label; + uint32_t vid; +} GRIN_VERTEX_T; +typedef struct GRIN_EDGE_T { + GRIN_VERTEX_T dst; + GRIN_VERTEX_T src; + GRIN_DIRECTION dir; + gs::label_t label; + gs::Any data; +} GRIN_EDGE_T; #ifdef GRIN_ENABLE_ADJACENT_LIST typedef struct GRIN_ADJACENT_LIST_T { - GRIN_VERTEX v; + GRIN_VERTEX_T v; GRIN_DIRECTION dir; - //gs::label_t elabel; - std::vector edges_label; + GRIN_EDGE_TYPE edge_label; } GRIN_ADJACENT_LIST_T; #endif #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR struct GRIN_ADJACENT_LIST_ITERATOR_T { - GRIN_ADJACENT_LIST_ITERATOR_T(GRIN_ADJACENT_LIST_T* adj_list):cur_edge_iter(nullptr),cur_label_idx(0),adj_list(*adj_list){} - void get_cur_edge_iter(GRIN_GRAPH_T* g){ - if(cur_label_idx == adj_list.edges_label.size()){ - return; - } - do{ - auto label = adj_list.edges_label[cur_label_idx]; - auto elabel = label >> 16; - auto vlabel = (label & 0xffff); - if(adj_list.dir == GRIN_DIRECTION::OUT){ - cur_edge_iter = g->get_outgoing_edges(adj_list.v.label, adj_list.v.vid, - vlabel, elabel); - } else{ - cur_edge_iter = g->get_incoming_edges(adj_list.v.label,adj_list.v.vid, - vlabel, elabel); - } - ++cur_label_idx; - }while(((cur_edge_iter == nullptr)||(!cur_edge_iter->is_valid())) && cur_label_idx < adj_list.edges_label.size()); - } - void next(GRIN_GRAPH_T* g){ - cur_edge_iter->next(); - if(!cur_edge_iter->is_valid()){ - get_cur_edge_iter(g); - } - } - bool is_valid(){ - if(cur_edge_iter == nullptr){ - return false; - } - return cur_edge_iter->is_valid(); - } - - GRIN_VERTEX neighbor(){ - GRIN_VERTEX v; - v.label = (adj_list.edges_label[cur_label_idx - 1]) &(0xffff); - v.vid = cur_edge_iter->get_neighbor(); - return v; - } - GRIN_EDGE_TYPE edge_type(){ - auto elabel = (adj_list.edges_label[cur_label_idx - 1]) >> 16; - return elabel; - } - std::shared_ptr cur_edge_iter; - gs::label_t cur_label_idx; - const GRIN_ADJACENT_LIST_T& adj_list; + std::shared_ptr edge_iter; + GRIN_ADJACENT_LIST_T* adj_list; }; #endif #ifdef GRIN_WITH_VERTEX_PROPERTY typedef std::vector GRIN_VERTEX_TYPE_LIST_T; -typedef struct GRIN_VERTEX_PROPERTY_T{ +typedef struct GRIN_VERTEX_PROPERTY_T { std::string name; + GRIN_DATATYPE dt; GRIN_VERTEX_TYPE label; } GRIN_VERTEX_PROPERTY_T; @@ -91,7 +52,8 @@ typedef std::vector GRIN_ROW_T; #endif #ifdef GRIN_WITH_EDGE_PROPERTY -typedef std::vector GRIN_EDGE_TYPE_LIST_T; +typedef std::vector GRIN_EDGE_TYPE_LIST_T; +typedef std::vector GRIN_EDGE_PROPERTY_LIST_T; #endif #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR diff --git a/flex/grin/src/property/primarykey.cc b/flex/grin/src/property/primarykey.cc new file mode 100644 index 000000000000..9e501ac2b0d2 --- /dev/null +++ b/flex/grin/src/property/primarykey.cc @@ -0,0 +1,66 @@ +#include "grin/src/predefine.h" + +#include "grin/include/include/common/error.h" +#include "grin/include/include/property/primarykey.h" +#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS +/** + * @brief Get the vertex types that have primary keys + * In some graph, not every vertex type has primary keys. + * @param GRIN_GRAPH The graph + * @return The vertex type list of types that have primary keys + */ +GRIN_VERTEX_TYPE_LIST grin_get_vertex_types_with_primary_keys(GRIN_GRAPH g) { + auto _g = static_cast(g); + GRIN_VERTEX_TYPE_LIST_T* vtl = new GRIN_VERTEX_TYPE_LIST_T(); + for (size_t idx = 0; idx < _g->vertex_label_num_; ++idx) { + vtl->push_back(idx); + } + return vtl; +} + +/** + * @brief Get the primary keys properties of a vertex type + * The primary keys properties are the properties that can be used to identify a + * vertex. They are a subset of the properties of a vertex type. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @return The primary keys properties list + */ +GRIN_VERTEX_PROPERTY_LIST grin_get_primary_keys_by_vertex_type( + GRIN_GRAPH, GRIN_VERTEX_TYPE label) { + GRIN_VERTEX_PROPERTY_LIST_T* vpl = new GRIN_VERTEX_PROPERTY_LIST_T(); + GRIN_VERTEX_PROPERTY_T vp; + vp.name = "oid"; + vp.label = label; + vp.dt = GRIN_DATATYPE::Int64; + vpl->emplace_back(vp); + return vpl; +} + +/** + * @brief Get the primary keys values row of a vertex + * The values in the row are in the same order as the primary keys properties. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The primary keys values row + */ +GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH g, GRIN_VERTEX v) { + GRIN_ROW_T* row = new GRIN_ROW_T(); + auto _g = static_cast(g); + auto _v = static_cast(v); + auto vid = _v->vid; + auto oid = _g->get_oid(_v->label, vid); + auto p = new gs::oid_t(oid); + row->emplace_back(p); + return row; +} +#endif + +#ifdef GRIN_ENABLE_EDGE_PRIMARY_KEYS +GRIN_EDGE_TYPE_LIST grin_get_edge_types_with_primary_keys(GRIN_GRAPH); + +GRIN_EDGE_PROPERTY_LIST grin_get_primary_keys_by_edge_type(GRIN_GRAPH, + GRIN_EDGE_TYPE); + +GRIN_ROW grin_get_edge_primary_keys_row(GRIN_GRAPH, GRIN_EDGE); +#endif diff --git a/flex/grin/src/property/property.cc b/flex/grin/src/property/property.cc index 1ce8e7b2ad35..826bec89af7c 100644 --- a/flex/grin/src/property/property.cc +++ b/flex/grin/src/property/property.cc @@ -15,8 +15,9 @@ limitations under the License. #include "grin/include/include/common/error.h" #include "grin/include/include/property/property.h" - -void grin_destroy_string_value(GRIN_GRAPH g, const char* value) {} +void grin_destroy_string_value(GRIN_GRAPH g, const char* value) { + delete value; +} #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME const char* grin_get_vertex_property_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype, @@ -34,13 +35,15 @@ GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH g, const char* name) { auto _g = static_cast(g); auto& table = _g->get_vertex_table(vt); - if(table.get_column(name) == nullptr){ + auto col = table.get_column(name); + if (col == nullptr) { return GRIN_NULL_VERTEX_PROPERTY; } - auto gvp = new GRIN_VERTEX_PROPERTY_T(); - gvp->name = std::string(name); - gvp->label = vt; - return gvp; + auto vp = new GRIN_VERTEX_PROPERTY_T(); + vp->name = std::string(name); + vp->label = vt; + vp->dt = _get_data_type(col->type()); + return vp; } GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, @@ -51,13 +54,15 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, std::string _name = std::string(name); for (auto idx = 0; idx < _g->schema().vertex_label_num(); idx++) { auto& table = _g->get_vertex_table(static_cast(idx)); - + auto col = table.get_column(name); + if (col != nullptr) { - GRIN_VERTEX_PROPERTY_T gvp; - gvp.name = _name; - gvp.label = idx; - vps->emplace_back(gvp); + GRIN_VERTEX_PROPERTY_T vp; + vp.name = _name; + vp.label = idx; + vp.dt = _get_data_type(col->type()); + vps->emplace_back(vp); } } if (vps->size() == 0) { @@ -91,45 +96,41 @@ bool grin_equal_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp1, GRIN_VERTEX_PROPERTY vp2) { auto _vp1 = static_cast(vp1); auto _vp2 = static_cast(vp2); - return (_vp1->name == _vp2->name) && (_vp1->label == _vp2->label); + return (_vp1->name == _vp2->name) && (_vp1->label == _vp2->label) && + (_vp1->dt == _vp2->dt); } void grin_destroy_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { - auto _vp = static_cast(vp); - delete _vp; + auto _vp = static_cast(vp); + delete _vp; } +/** + * @TODO add type for GRIN_VERTEX_PROPERTY_T + */ GRIN_DATATYPE grin_get_vertex_property_datatype(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { - auto _g = static_cast(g); auto _vp = static_cast(vp); - auto& table = _g->get_vertex_table(_vp->label); - const auto& property_names = table.column_names(); - const auto& property_types = table.column_types(); - for(size_t i = 0; i < property_names.size(); ++i){ - if(property_names.at(i) == _vp->name){ - return _get_data_type(property_types.at(i)); - } - } - grin_error_code = UNKNOWN_DATATYPE; - return GRIN_DATATYPE::Undefined; + return _vp->dt; } int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - if(v.label != _vp->label){ + auto _v = static_cast(v); + if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Int32) { grin_error_code = INVALID_VALUE; return 0; } auto& table = _g->get_vertex_table(_vp->label); - auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); - if(col == nullptr){ + auto col = + std::dynamic_pointer_cast(table.get_column(_vp->name)); + if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0; } - return col->get_view(v.vid); + return col->get_view(_v->vid); } unsigned int grin_get_vertex_property_value_of_uint32(GRIN_GRAPH g, @@ -144,17 +145,19 @@ long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - if(v.label != _vp->label){ + auto _v = static_cast(v); + if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Int64) { grin_error_code = INVALID_VALUE; return 0; } auto& table = _g->get_vertex_table(_vp->label); - auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); - if(col == nullptr){ + auto col = + std::dynamic_pointer_cast(table.get_column(_vp->name)); + if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0; } - return col->get_view(v.vid); + return col->get_view(_v->vid); } unsigned long long int grin_get_vertex_property_value_of_uint64( @@ -173,18 +176,20 @@ double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - if(v.label != _vp->label){ + auto _v = static_cast(v); + if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Double) { grin_error_code = INVALID_VALUE; return 0.0; } auto& table = _g->get_vertex_table(_vp->label); - - auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); - if(col == nullptr){ + + auto col = + std::dynamic_pointer_cast(table.get_column(_vp->name)); + if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0.0; } - return col->get_view(v.vid); + return col->get_view(_v->vid); } const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, @@ -192,18 +197,23 @@ const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - if(v.label != _vp->label){ + auto _v = static_cast(v); + if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::String) { grin_error_code = INVALID_VALUE; return NULL; } auto& table = _g->get_vertex_table(_vp->label); - auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); - if(col == nullptr){ + auto col = + std::dynamic_pointer_cast(table.get_column(_vp->name)); + if (col == nullptr) { grin_error_code = INVALID_VALUE; return NULL; } - return col->get_view(v.vid).data(); - + auto s = col->get_view(_v->vid); + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); + return out; } int grin_get_vertex_property_value_of_date32(GRIN_GRAPH g, GRIN_VERTEX v, @@ -222,18 +232,20 @@ long long int grin_get_vertex_property_value_of_timestamp64( GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - if(v.label != _vp->label){ + auto _v = static_cast(v); + if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Timestamp64) { grin_error_code = INVALID_VALUE; return 0; } - + auto& table = _g->get_vertex_table(_vp->label); - auto col = std::dynamic_pointer_cast(table.get_column(_vp->name)); - if(col == nullptr){ + auto col = + std::dynamic_pointer_cast(table.get_column(_vp->name)); + if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0; } - return col->get_view(v.vid).milli_second; + return col->get_view(_v->vid).milli_second; } GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH g, @@ -247,34 +259,35 @@ GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH g, const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto _vp = static_cast(vp); + auto _vp = static_cast(vp); auto& table = _g->get_vertex_table(_vp->label); const auto& col = table.get_column(_vp->name); - auto type = grin_get_vertex_property_datatype(g,vp); - switch(type){ - case GRIN_DATATYPE::Int32:{ - auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + v.vid; - } - case GRIN_DATATYPE::Int64:{ - auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + v.vid; - } - case GRIN_DATATYPE::String:{ - auto _col = std::dynamic_pointer_cast(col); - return _col->buffer()[v.vid].data(); - } - case GRIN_DATATYPE::Timestamp64:{ - auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + v.vid; - } - case GRIN_DATATYPE::Double:{ - auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + v.vid; - } - default: - grin_error_code = UNKNOWN_DATATYPE; - return NULL; + auto type = grin_get_vertex_property_datatype(g, vp); + auto _v = static_cast(v); + switch (type) { + case GRIN_DATATYPE::Int32: { + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + _v->vid; + } + case GRIN_DATATYPE::Int64: { + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + _v->vid; + } + case GRIN_DATATYPE::String: { + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer()[_v->vid].data(); + } + case GRIN_DATATYPE::Timestamp64: { + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + _v->vid; + } + case GRIN_DATATYPE::Double: { + auto _col = std::dynamic_pointer_cast(col); + return _col->buffer().data() + _v->vid; + } + default: + grin_error_code = UNKNOWN_DATATYPE; + return NULL; } } #endif @@ -282,107 +295,122 @@ const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, #ifdef GRIN_WITH_EDGE_PROPERTY bool grin_equal_edge_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep1, GRIN_EDGE_PROPERTY ep2) { - return ep1 == ep2; + return ep1 == ep2; } -void grin_destroy_edge_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep){} +void grin_destroy_edge_property(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep) {} GRIN_DATATYPE grin_get_edge_property_datatype(GRIN_GRAPH g, - GRIN_EDGE_PROPERTY ep){ - auto _g = static_cast(g); - const auto& type = _g->schema().get_edge_property(ep >> 16, (ep >> 8) & 0xff, ep & 0xff); - return _get_data_type(type); + GRIN_EDGE_PROPERTY ep) { + auto _g = static_cast(g); + auto src_label_i = (ep >> 16) & 0xff; + const auto& src_label = _g->schema().get_vertex_label_name(src_label_i); + auto dst_label_i = (ep >> 8) & 0xff; + const auto& dst_label = _g->schema().get_vertex_label_name(dst_label_i); + auto edge_label_i = ep & 0xff; + const auto& edge_label = _g->schema().get_edge_label_name(edge_label_i); + const auto& type = + _g->schema().get_edge_properties(src_label, dst_label, edge_label); + auto idx = ep >> 24; + return _get_data_type(type[idx]); } int grin_get_edge_property_value_of_int32(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - auto _e = static_cast(e); - if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Int32){ - grin_error_code = INVALID_VALUE; - return 0; - } - return _e->data.value.i; -} - -unsigned int grin_get_edge_property_value_of_uint32(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ + GRIN_EDGE_PROPERTY ep) { + auto _e = static_cast(e); + auto idx = ep >> 24; + if (idx > 0 || _get_data_type(_e->data.type) != GRIN_DATATYPE::Int32) { grin_error_code = INVALID_VALUE; return 0; + } + return _e->data.value.i; } -long long int grin_get_edge_property_value_of_int64(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - auto _e = static_cast(e); - if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Int64){ - grin_error_code = INVALID_VALUE; - return 0; - } - return _e->data.value.l; +unsigned int grin_get_edge_property_value_of_uint32(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep) { + grin_error_code = INVALID_VALUE; + return 0; } -unsigned long long int grin_get_edge_property_value_of_uint64( - GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep){ +long long int grin_get_edge_property_value_of_int64(GRIN_GRAPH g, GRIN_EDGE e, + GRIN_EDGE_PROPERTY ep) { + auto _e = static_cast(e); + auto idx = ep >> 24; + if (idx > 0 || _get_data_type(_e->data.type) != GRIN_DATATYPE::Int64) { grin_error_code = INVALID_VALUE; return 0; + } + return _e->data.value.l; } +unsigned long long int grin_get_edge_property_value_of_uint64( + GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep) { + grin_error_code = INVALID_VALUE; + return 0; +} float grin_get_edge_property_value_of_float(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - grin_error_code = INVALID_VALUE; - return 0.0; + GRIN_EDGE_PROPERTY ep) { + grin_error_code = INVALID_VALUE; + return 0.0; } double grin_get_edge_property_value_of_double(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - auto _e = static_cast(e); - if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Double){ - grin_error_code = INVALID_VALUE; - return 0.0; - } - return _e->data.value.db; + GRIN_EDGE_PROPERTY ep) { + auto _e = static_cast(e); + auto idx = ep >> 24; + if (idx > 0 || _get_data_type(_e->data.type) != GRIN_DATATYPE::Double) { + grin_error_code = INVALID_VALUE; + return 0.0; + } + return _e->data.value.db; } const char* grin_get_edge_property_value_of_string(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - auto _e = static_cast(e); - if(_get_data_type(_e->data.type) != GRIN_DATATYPE::String){ - grin_error_code = INVALID_VALUE; - return NULL; - } - //@TODO 怎么返回? + GRIN_EDGE_PROPERTY ep) { + auto _e = static_cast(e); + auto idx = ep >> 24; + if (idx > 0 || _get_data_type(_e->data.type) != GRIN_DATATYPE::String) { + grin_error_code = INVALID_VALUE; return NULL; + } + auto s = _e->data.value.s; + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); + return out; } int grin_get_edge_property_value_of_date32(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - grin_error_code = INVALID_VALUE; - return 0; + GRIN_EDGE_PROPERTY ep) { + grin_error_code = INVALID_VALUE; + return 0; } int grin_get_edge_property_value_of_time32(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - grin_error_code = INVALID_VALUE; - return 0; + GRIN_EDGE_PROPERTY ep) { + grin_error_code = INVALID_VALUE; + return 0; } long long int grin_get_edge_property_value_of_timestamp64( - GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep){ - auto _e = static_cast(e); - if(_get_data_type(_e->data.type) != GRIN_DATATYPE::Timestamp64){ - grin_error_code = INVALID_VALUE; - return 0; - } - return _e->data.value.d.milli_second; + GRIN_GRAPH g, GRIN_EDGE e, GRIN_EDGE_PROPERTY ep) { + auto _e = static_cast(e); + auto idx = ep >> 24; + if (idx > 0 || _get_data_type(_e->data.type) != GRIN_DATATYPE::Timestamp64) { + grin_error_code = INVALID_VALUE; + return 0; } + return _e->data.value.d.milli_second; +} GRIN_EDGE_TYPE grin_get_edge_type_from_property(GRIN_GRAPH g, - GRIN_EDGE_PROPERTY ep){ - return ep; + GRIN_EDGE_PROPERTY ep) { + return ep & (~0xff000000); } #endif #if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) const void* grin_get_edge_property_value(GRIN_GRAPH g, GRIN_EDGE e, - GRIN_EDGE_PROPERTY ep){ - return NULL; + GRIN_EDGE_PROPERTY ep) { + return NULL; } #endif \ No newline at end of file diff --git a/flex/grin/src/property/propertylist.cc b/flex/grin/src/property/propertylist.cc index c4e3520abd3b..c23715758f4f 100644 --- a/flex/grin/src/property/propertylist.cc +++ b/flex/grin/src/property/propertylist.cc @@ -18,15 +18,17 @@ limitations under the License. GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type( GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { auto _g = static_cast(g); - auto &table = _g->get_vertex_table(vt); - + auto& table = _g->get_vertex_table(vt); + auto vertex_prop_num = table.col_num(); GRIN_VERTEX_PROPERTY_LIST_T* vpl = new GRIN_VERTEX_PROPERTY_LIST_T(); const auto& prop_names = table.column_names(); - for(size_t i = 0; i < vertex_prop_num; ++i){ + const auto& prop_types = table.column_types(); + for (size_t i = 0; i < vertex_prop_num; ++i) { GRIN_VERTEX_PROPERTY_T vpt; vpt.name = prop_names[i]; vpt.label = vt; + vpt.dt = _get_data_type(prop_types[i]); vpl->emplace_back(vpt); } return vpl; @@ -53,7 +55,7 @@ GRIN_VERTEX_PROPERTY_LIST grin_create_vertex_property_list(GRIN_GRAPH g) { void grin_destroy_vertex_property_list(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY_LIST vpl) { auto _vpl = static_cast(vpl); - delete _vpl; + delete _vpl; } bool grin_insert_vertex_property_to_list(GRIN_GRAPH g, @@ -74,14 +76,16 @@ GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id( auto& table = _g->get_vertex_table(vt); auto vertex_prop_num = table.col_num(); - + if (pid >= vertex_prop_num) { return GRIN_NULL_VERTEX_PROPERTY; } const auto& prop_names = table.column_names(); + const auto& prop_types = table.column_types(); GRIN_VERTEX_PROPERTY_T* vpt = new GRIN_VERTEX_PROPERTY_T(); vpt->name = prop_names[pid]; vpt->label = vt; + vpt->dt = _get_data_type(prop_types[pid]); return vpt; } @@ -92,8 +96,8 @@ GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH g, auto& table = _g->get_vertex_table(vt); const auto& prop_names = table.column_names(); auto _vp = static_cast(vp); - for(size_t i = 0; i < prop_names.size(); ++i){ - if(prop_names.at(i) == _vp->name){ + for (size_t i = 0; i < prop_names.size(); ++i) { + if (prop_names.at(i) == _vp->name) { return i; } } @@ -103,46 +107,67 @@ GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH g, #ifdef GRIN_WITH_EDGE_PROPERTY GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH g, - GRIN_EDGE_TYPE et){ - return et; + GRIN_EDGE_TYPE et) { + GRIN_EDGE_PROPERTY_LIST_T* p = new GRIN_EDGE_PROPERTY_LIST_T(); + + auto _g = static_cast(g); + auto src_label_i = et >> 16; + auto src_label = _g->schema().get_vertex_label_name(src_label_i); + auto dst_label_i = (et >> 8) & (0xff); + auto dst_label = _g->schema().get_vertex_label_name(dst_label_i); + auto edge_label_i = et & 0xff; + auto edge_label = _g->schema().get_edge_label_name(edge_label_i); + auto sz = + _g->schema().get_edge_properties(src_label, dst_label, edge_label).size(); + for (auto i = 0; i < sz; ++i) { + p->emplace_back(et + (i << 24)); + } + return p; } size_t grin_get_edge_property_list_size(GRIN_GRAPH g, - GRIN_EDGE_PROPERTY_LIST epl){ - return 1; + GRIN_EDGE_PROPERTY_LIST epl) { + auto _epl = static_cast(epl); + return _epl->size(); } GRIN_EDGE_PROPERTY grin_get_edge_property_from_list(GRIN_GRAPH g, GRIN_EDGE_PROPERTY_LIST epl, - size_t idx){ - if(idx > 0){ + size_t idx) { + auto _epl = static_cast(epl); + if (_epl->size() <= idx) { return GRIN_NULL_EDGE_PROPERTY; - } - return epl; + } + return (*_epl)[idx]; } -GRIN_EDGE_PROPERTY_LIST grin_create_edge_property_list(GRIN_GRAPH g){ - return GRIN_NULL_EDGE_PROPERTY; +GRIN_EDGE_PROPERTY_LIST grin_create_edge_property_list(GRIN_GRAPH g) { + return new GRIN_EDGE_PROPERTY_LIST_T(); } void grin_destroy_edge_property_list(GRIN_GRAPH g, - GRIN_EDGE_PROPERTY_LIST epl){} + GRIN_EDGE_PROPERTY_LIST epl) { + auto _epl = static_cast(epl); + delete _epl; +} bool grin_insert_edge_property_to_list(GRIN_GRAPH g, GRIN_EDGE_PROPERTY_LIST epl, - GRIN_EDGE_PROPERTY ep){ - return false; + GRIN_EDGE_PROPERTY ep) { + auto _epl = static_cast(epl); + _epl->emplace_back(ep); + return true; } #endif #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY GRIN_EDGE_PROPERTY grin_get_edge_property_by_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et, - GRIN_EDGE_PROPERTY_ID pid){ + GRIN_EDGE_PROPERTY_ID pid) { return NULL; } GRIN_EDGE_PROPERTY_ID grin_get_edge_property_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et, - GRIN_EDGE_PROPERTY ep){ + GRIN_EDGE_PROPERTY ep) { return 0; } #endif \ No newline at end of file diff --git a/flex/grin/src/property/row.cc b/flex/grin/src/property/row.cc index eae1bbcb66d4..8d5296e33989 100644 --- a/flex/grin/src/property/row.cc +++ b/flex/grin/src/property/row.cc @@ -178,7 +178,8 @@ const void* grin_get_value_from_row(GRIN_GRAPH g, GRIN_ROW r, GRIN_DATATYPE dt, #if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_ENABLE_ROW) GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { auto _g = static_cast(g); - auto& table = _g->get_vertex_table(v.label); + auto _v = static_cast(v); + auto& table = _g->get_vertex_table(_v->label); auto prop_size = table.col_num(); const auto& types = table.column_types(); auto r = new GRIN_ROW_T(); @@ -188,27 +189,32 @@ GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { switch(type){ case GRIN_DATATYPE::Int32:{ auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data()+ v.vid); + r->emplace_back(_col->buffer().data()+ _v->vid); break; } case GRIN_DATATYPE::Int64:{ auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data()+ v.vid); + r->emplace_back(_col->buffer().data()+ _v->vid); break; } case GRIN_DATATYPE::String:{ auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer()[v.vid].data()); + auto s = _col->get_view(_v->vid); + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); + + r->emplace_back(out); break; } case GRIN_DATATYPE::Timestamp64:{ auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data()+ v.vid); + r->emplace_back(_col->buffer().data()+ _v->vid); break; } case GRIN_DATATYPE::Double:{ auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data() + v.vid); + r->emplace_back(_col->buffer().data() + _v->vid); break; } default: @@ -222,6 +228,39 @@ GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { #if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_ENABLE_ROW) GRIN_ROW grin_get_edge_row(GRIN_GRAPH g, GRIN_EDGE e){ - return NULL; + auto _e = static_cast(e); + auto type = _get_data_type(_e->data.type); + GRIN_ROW_T* r = new GRIN_ROW_T(); + switch(type){ + case GRIN_DATATYPE::Int32:{ + r->emplace_back(new int(_e->data.value.i)); + break; + } + case GRIN_DATATYPE::Int64:{ + r->emplace_back(new int64_t(_e->data.value.l)); + break; + } + case GRIN_DATATYPE::String:{ + auto s = _e->data.value.s; + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); + + r->emplace_back(out); + break; + } + case GRIN_DATATYPE::Timestamp64:{ + r->emplace_back(new int64_t(_e->data.value.d.milli_second)); + break; + } + case GRIN_DATATYPE::Double:{ + r->emplace_back(new double(_e->data.value.db)); + break; + } + default: + r->emplace_back(static_cast(NULL)); + + } + return r; } #endif \ No newline at end of file diff --git a/flex/grin/src/property/topology.cc b/flex/grin/src/property/topology.cc index d530702218c1..e32ff7754380 100644 --- a/flex/grin/src/property/topology.cc +++ b/flex/grin/src/property/topology.cc @@ -22,19 +22,17 @@ size_t grin_get_vertex_num_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { #endif #ifdef GRIN_WITH_EDGE_PROPERTY -size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et){ - return 0; -} +size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { return 0; } #endif #if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) GRIN_VERTEX_LIST grin_get_vertex_list_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { - GRIN_VERTEX_LIST gvl; - gvl.label = vt; + GRIN_VERTEX_LIST vl; + vl.label = vt; auto _g = static_cast(g); - gvl.vertex_num = _g->vertex_num(vt); - return gvl; + vl.vertex_num = _g->vertex_num(vt); + return vl; } #endif @@ -48,37 +46,9 @@ GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_EDGE_TYPE et) { GRIN_ADJACENT_LIST_T* adj_list = new GRIN_ADJACENT_LIST_T(); - adj_list->v = v; + adj_list->v = *static_cast(v); adj_list->dir = dir; - auto _g = static_cast(g); - - const auto &schema = _g->schema(); - if(dir == GRIN_DIRECTION::OUT){ - std::string src_label = - schema.get_vertex_label_name(v.label); - std::string edge_label = schema.get_edge_label_name(et); - for(size_t dst_label_i = 0; dst_label_i != schema.vertex_label_num(); ++dst_label_i){ - std::string dst_label = schema.get_vertex_label_name(static_cast(dst_label_i)); - if (!schema.exist(src_label, dst_label, edge_label)) { - continue; - } - auto label = (static_cast(et) << 16) + dst_label_i; - adj_list->edges_label.emplace_back(label); - } - } else{ - std::string dst_label = - schema.get_vertex_label_name(v.label); - std::string edge_label = schema.get_edge_label_name(et); - for(size_t src_label_i = 0; src_label_i != schema.vertex_label_num(); ++src_label_i){ - std::string src_label = schema.get_vertex_label_name(static_cast(src_label_i)); - if (!schema.exist(src_label, dst_label, edge_label)) { - continue; - } - auto label = (static_cast(et) << 16) + src_label_i; - adj_list->edges_label.emplace_back(label); - } - } - + adj_list->edge_label = et; return adj_list; } #endif \ No newline at end of file diff --git a/flex/grin/src/property/type.cc b/flex/grin/src/property/type.cc index c538214e1370..80ef8ff2237a 100644 --- a/flex/grin/src/property/type.cc +++ b/flex/grin/src/property/type.cc @@ -22,7 +22,8 @@ bool grin_equal_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt1, } GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH g, GRIN_VERTEX v) { - return v.label; + auto _v = static_cast(v); + return _v->label; } void grin_destroy_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) {} @@ -81,7 +82,7 @@ const char* grin_get_vertex_type_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH g, const char* name) { auto _g = static_cast(g); std::string type_name(name); - if((!_g->schema().contains_vertex_label(type_name))){ + if ((!_g->schema().contains_vertex_label(type_name))) { return GRIN_NULL_VERTEX_TYPE; } auto type = _g->schema().get_vertex_label_id(type_name); @@ -107,9 +108,9 @@ bool grin_equal_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et1, return (et1 == et2); } -GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH g, GRIN_EDGE e) { +GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH g, GRIN_EDGE e) { auto _e = static_cast(e); - return _e->label; + return _e->label + (_e->src.label << 16) + (_e->dst.label << 8); } void grin_destroy_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { @@ -121,8 +122,20 @@ GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH g) { auto _g = static_cast(g); auto etl = new GRIN_EDGE_TYPE_LIST_T(); auto edge_label_num = _g->edge_label_num_; - for (auto idx = 0; idx < edge_label_num; ++idx) { - etl->push_back(idx); + auto vertex_label_num = _g->vertex_label_num_; + for (auto src_label_i = 0; src_label_i < vertex_label_num; ++src_label_i) { + const auto& src_label = _g->schema().get_vertex_label_name(src_label_i); + for (auto dst_label_i = 0; dst_label_i < vertex_label_num; ++dst_label_i) { + const auto& dst_label = _g->schema().get_vertex_label_name(dst_label_i); + for (auto edge_label_i = 0; edge_label_i < edge_label_num; + ++edge_label_i) { + const auto& edge_label = _g->schema().get_edge_label_name(edge_label_i); + if (_g->schema().exist(src_label, dst_label, edge_label)) { + auto label = (src_label_i << 16) + (dst_label_i << 8) + edge_label_i; + etl->push_back(label); + } + } + } } return etl; } @@ -161,7 +174,13 @@ GRIN_EDGE_TYPE grin_get_edge_type_from_list(GRIN_GRAPH g, const char* grin_get_edge_type_name(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { auto _g = static_cast(g); const auto& schema = _g->schema(); - std::string label = schema.get_edge_label_name(static_cast(et)); + auto edge_label_i = et & 0xff; + auto src_label_i = et >> 16; + auto dst_label_i = (et >> 8) & 0xff; + const auto& edge_label = schema.get_edge_label_name(edge_label_i); + const auto& src_label = schema.get_vertex_label_name(src_label_i); + const auto& dst_label = schema.get_vertex_label_name(dst_label_i); + auto label = src_label + "#" + dst_label + "#" + edge_label; auto len = label.length() + 1; char* out = new char[len]; snprintf(out, len, "%s", label.c_str()); @@ -170,12 +189,32 @@ const char* grin_get_edge_type_name(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH g, const char* name) { auto _g = static_cast(g); + const auto& schema = _g->schema(); - if(!schema.contains_edge_label(name)){ + std::vector vec; + size_t len = strlen(name); + std::string ss{}; + for (size_t i = 0; i <= len; ++i) { + if (name[i] == '#' || name[i] == '\0') { + vec.emplace_back(ss); + ss = ""; + } else { + ss += name[i]; + } + } + + if (vec.size() != 3) { return GRIN_NULL_EDGE_TYPE; } - GRIN_EDGE_TYPE type = schema.get_edge_label_id(name); - return type; + if ((!schema.contains_vertex_label(vec[0])) || + (!schema.contains_vertex_label(vec[1])) || + (!schema.contains_edge_label(vec[2]))) { + return GRIN_NULL_EDGE_TYPE; + } + auto src_label = schema.get_vertex_label_id(vec[0]); + auto dst_label = schema.get_vertex_label_id(vec[1]); + auto edge_label = schema.get_edge_label_id(vec[2]); + return (src_label << 16) + (dst_label << 8) + edge_label; } #endif @@ -193,54 +232,16 @@ GRIN_EDGE_TYPE grin_get_edge_type_by_id(GRIN_GRAPH g, GRIN_EDGE_TYPE_ID etid) { /** @brief the src vertex type list */ GRIN_VERTEX_TYPE_LIST grin_get_src_types_by_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { - auto _g = static_cast(g); - auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); - const auto& schema = _g->schema(); - auto vertex_label_num = _g->vertex_label_num_; - std::string edge_label = - schema.get_edge_label_name(static_cast(et)); - for (size_t src_label_i = 0; src_label_i != vertex_label_num; - ++src_label_i) { - std::string src_label = - schema.get_vertex_label_name(static_cast(src_label_i)); - for (size_t dst_label_i = 0; dst_label_i != vertex_label_num; - ++dst_label_i) { - std::string dst_label = - schema.get_vertex_label_name(static_cast(dst_label_i)); - - if (schema.exist(src_label, dst_label, edge_label)) { - vtl->push_back(src_label_i); - } - } - } + vtl->emplace_back(et >> 16); return vtl; } /** @brief get the dst vertex type list */ GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { - auto _g = static_cast(g); - auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); - const auto& schema = _g->schema(); - auto vertex_label_num = _g->vertex_label_num_; - std::string edge_label = - schema.get_edge_label_name(static_cast(et)); - for (size_t src_label_i = 0; src_label_i != vertex_label_num; - ++src_label_i) { - std::string src_label = - schema.get_vertex_label_name(static_cast(src_label_i)); - for (size_t dst_label_i = 0; dst_label_i != vertex_label_num; - ++dst_label_i) { - std::string dst_label = - schema.get_vertex_label_name(static_cast(dst_label_i)); - - if (schema.exist(src_label, dst_label, edge_label)) { - vtl->push_back(dst_label_i); - } - } - } + vtl->emplace_back((et >> 8) & (0xff)); return vtl; } @@ -248,20 +249,21 @@ GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair( GRIN_GRAPH g, GRIN_VERTEX_TYPE vt1, GRIN_VERTEX_TYPE vt2) { auto _g = static_cast(g); - + auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); const auto& schema = _g->schema(); auto edge_label_num = _g->edge_label_num_; std::string src_label = - schema.get_vertex_label_name(static_cast(vt1)); + schema.get_vertex_label_name(static_cast(vt1)); std::string dst_label = - schema.get_vertex_label_name(static_cast(vt2)); + schema.get_vertex_label_name(static_cast(vt2)); + auto label = (vt1 << 16) + (vt2 << 8); for (size_t edge_label_i = 0; edge_label_i != edge_label_num; ++edge_label_i) { std::string edge_label = schema.get_vertex_label_name(static_cast(edge_label_i)); - if(schema.exist(src_label,dst_label,edge_label)){ - vtl->push_back(edge_label_i); + if (schema.exist(src_label, dst_label, edge_label)) { + vtl->push_back(label + edge_label_i); } } return vtl; diff --git a/flex/grin/src/topology/adjacentlist.cc b/flex/grin/src/topology/adjacentlist.cc index 8340f4f0db78..6e6fd932ba8f 100644 --- a/flex/grin/src/topology/adjacentlist.cc +++ b/flex/grin/src/topology/adjacentlist.cc @@ -19,36 +19,11 @@ limitations under the License. #if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_ENABLE_EDGE_PROPERTY) GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH g, GRIN_DIRECTION dir, - GRIN_VERTEX v){ - auto _g = static_cast(g); - auto& schema = _g->schema(); - GRIN_ADJACENT_LIST_T* alt = new GRIN_ADJACENT_LIST_T(); - alt->dir = dir; - alt->v = v; - if(dir == GRIN_DIRECTION::OUT){ - std::string src_label = schema.get_vertex_label_name(v.label); - for(size_t edge_label_i = 0; edge_label_i < _g->edge_label_num_; ++edge_label_i){ - std::string edge_label = schema.get_edge_label_name(edge_label_i); - for(size_t dst_label_i = 0; dst_label_i < _g->vertex_label_num_; ++dst_label_i){ - std::string dst_label = schema.get_vertex_label_name(dst_label_i); - if(schema.exist(src_label,dst_label,edge_label)){ - alt->edges_label.emplace_back((edge_label_i << 16) + dst_label_i); - } - } - } - }else{ - std::string dst_label = schema.get_vertex_label_name(v.label); - for(size_t edge_label_i = 0; edge_label_i < _g->edge_label_num_; ++edge_label_i){ - std::string edge_label = schema.get_edge_label_name(edge_label_i); - for(size_t src_label_i = 0; src_label_i < _g->vertex_label_num_; ++src_label_i){ - std::string src_label = schema.get_vertex_label_name(src_label_i); - if(schema.exist(src_label,dst_label,edge_label)){ - alt->edges_label.emplace_back((edge_label_i << 16) + src_label_i); - } - } - } - } - return alt; + GRIN_VERTEX v) { + GRIN_ADJACENT_LIST_T* alt = new GRIN_ADJACENT_LIST_T(); + alt->dir = dir; + alt->v = *static_cast(v); + return alt; } #endif @@ -64,8 +39,28 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) { auto _g = static_cast(g); auto _adj_list = static_cast(adj_list); - auto iter = new GRIN_ADJACENT_LIST_ITERATOR_T(_adj_list); - iter->get_cur_edge_iter(_g); + auto iter = new GRIN_ADJACENT_LIST_ITERATOR_T(); + auto& v = _adj_list->v; + iter->adj_list = _adj_list; + auto label = _adj_list->edge_label; + auto src_label = label >> 16; + auto dst_label = (label >> 8) & 0xff; + auto edge_label = label & 0xff; + if (_adj_list->dir == GRIN_DIRECTION::OUT) { + if (src_label == v.label) { + iter->edge_iter = + _g->get_outgoing_edges(src_label, v.vid, dst_label, edge_label); + } else { + iter->edge_iter = nullptr; + } + } else { + if (dst_label == v.label) { + iter->edge_iter = + _g->get_incoming_edges(dst_label, v.vid, src_label, edge_label); + } else { + iter->edge_iter = nullptr; + } + } return iter; } @@ -78,35 +73,45 @@ void grin_destroy_adjacent_list_iter(GRIN_GRAPH g, void grin_get_next_adjacent_list_iter(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); - auto _g = static_cast(g); - _iter->next(_g); + _iter->edge_iter->next(); } bool grin_is_adjacent_list_end(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); - return !_iter->is_valid(); + return _iter->edge_iter == nullptr || !_iter->edge_iter->is_valid(); } GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter( GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); - return _iter->neighbor(); + auto v = new GRIN_VERTEX_T(); + v->vid = _iter->edge_iter->get_neighbor(); + auto label = _iter->adj_list->edge_label; + if (_iter->adj_list->dir == GRIN_DIRECTION::OUT) { + v->label = (label >> 8) & 0xff; + } else { + v->label = label >> 16; + } + return v; } GRIN_EDGE grin_get_edge_from_adjacent_list_iter( GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); GRIN_EDGE_T* edge = new GRIN_EDGE_T(); - if (_iter->adj_list.dir == GRIN_DIRECTION::IN) { - edge->src = _iter->neighbor(); - edge->dst = _iter->adj_list.v; + auto nbr = *static_cast( + grin_get_neighbor_from_adjacent_list_iter(g, iter)); + if (_iter->adj_list->dir == GRIN_DIRECTION::IN) { + edge->src = nbr; + edge->dst = _iter->adj_list->v; } else { - edge->src = _iter->adj_list.v; - edge->dst = _iter->neighbor(); + edge->src = _iter->adj_list->v; + edge->dst = nbr; } - edge->dir = _iter->adj_list.dir; - edge->data = _iter->cur_edge_iter->get_data(); - edge->label = _iter->edge_type(); + edge->dir = _iter->adj_list->dir; + edge->data = _iter->edge_iter->get_data(); + auto label = _iter->adj_list->edge_label; + edge->label = label & 0xff; return edge; } #endif \ No newline at end of file diff --git a/flex/grin/src/topology/structure.cc b/flex/grin/src/topology/structure.cc index 5afb0f033236..d20d073f39ea 100644 --- a/flex/grin/src/topology/structure.cc +++ b/flex/grin/src/topology/structure.cc @@ -15,32 +15,31 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/topology/structure.h" #include -GRIN_GRAPH grin_get_graph_from_storage(const char* uri){ - - std::string _uri(uri); - std::string::size_type pos = _uri.find("://"); - if (pos == std::string::npos) { - return GRIN_NULL_GRAPH; - } - auto protocol = _uri.substr(0, pos); - if(protocol != "flex"){ - return GRIN_NULL_GRAPH; - } - _uri = _uri.substr(pos + 3); - std::string graph_schema_path = _uri + "/modern_graph.yaml"; - std::string data_path = uri; - std::string bulk_load_config_path = _uri + "/bulk_load.yaml"; - auto ret = gs::Schema::LoadFromYaml(graph_schema_path, bulk_load_config_path); - const auto& schema = std::get<0>(ret); - auto& vertex_files = std::get<1>(ret); - - auto& edge_files = std::get<2>(ret); - - GRIN_GRAPH_T* g = new GRIN_GRAPH_T(); - g->Init(schema, vertex_files, edge_files); - return g; +#include "grin/include/include/topology/structure.h" +GRIN_GRAPH grin_get_graph_from_storage(const char* uri) { + std::string _uri(uri); + std::string::size_type pos = _uri.find("://"); + if (pos == std::string::npos) { + return GRIN_NULL_GRAPH; + } + auto protocol = _uri.substr(0, pos); + if (protocol != "flex") { + return GRIN_NULL_GRAPH; + } + _uri = _uri.substr(pos + 3); + std::string graph_schema_path = _uri + "/modern_graph.yaml"; + std::string data_path = uri; + std::string bulk_load_config_path = _uri + "/bulk_load.yaml"; + auto ret = gs::Schema::LoadFromYaml(graph_schema_path, bulk_load_config_path); + const auto& schema = std::get<0>(ret); + auto& vertex_files = std::get<1>(ret); + + auto& edge_files = std::get<2>(ret); + + GRIN_GRAPH_T* g = new GRIN_GRAPH_T(); + g->Init(schema, vertex_files, edge_files); + return g; } void grin_destroy_graph(GRIN_GRAPH g) { @@ -48,20 +47,14 @@ void grin_destroy_graph(GRIN_GRAPH g) { delete _g; } - // Graph #if defined(GRIN_ASSUME_HAS_DIRECTED_GRAPH) && \ defined(GRIN_ASSUME_HAS_UNDIRECTED_GRAPH) -bool grin_is_directed(GRIN_GRAPH g) { - return true; -} +bool grin_is_directed(GRIN_GRAPH g) { return true; } #endif - #ifdef GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -bool grin_is_multigraph(GRIN_GRAPH){ - return true; -} +bool grin_is_multigraph(GRIN_GRAPH) { return true; } #endif #ifndef GRIN_WITH_VERTEX_PROPERTY @@ -72,12 +65,16 @@ size_t grin_get_vertex_num(GRIN_GRAPH); size_t grin_get_edge_num(GRIN_GRAPH); #endif - // Vertex -void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX) {} +void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX v) { + auto _v = static_cast(v); + delete _v; +} bool grin_equal_vertex(GRIN_GRAPH g, GRIN_VERTEX v1, GRIN_VERTEX v2) { - return v1.label == v2.label && v1.vid == v2.vid; + auto _v1 = static_cast(v1); + auto _v2 = static_cast(v2); + return _v1->label == _v2->label && _v1->vid == _v2->vid; } // Data @@ -89,56 +86,57 @@ const void* grin_get_vertex_data_value(GRIN_GRAPH, GRIN_VERTEX); // Edge void grin_destroy_edge(GRIN_GRAPH, GRIN_EDGE e) { - auto _e = static_cast(e); - delete _e; + auto _e = static_cast(e); + delete _e; } -GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e){ - auto _e = static_cast(e); - return _e->src; +GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e) { + auto _e = static_cast(e); + auto v = new GRIN_VERTEX_T(); + memcpy(v, &(_e->src), sizeof(GRIN_VERTEX_T)); + return v; } - GRIN_VERTEX grin_get_dst_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e) { - auto _e = static_cast(e); - return _e->dst; + auto _e = static_cast(e); + auto v = new GRIN_VERTEX_T(); + memcpy(v, &(_e->dst), sizeof(GRIN_VERTEX_T)); + return v; } #ifdef GRIN_WITH_EDGE_DATA -GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE e){ - auto _e = static_cast(e); - auto type = _e->data.type; - return _get_data_type(type); +GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE e) { + auto _e = static_cast(e); + auto type = _e->data.type; + return _get_data_type(type); } -const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE e){ - auto _e = static_cast(e); - //new 返回? - auto type = _e->data.type; - switch(_get_data_type(type)){ - case GRIN_DATATYPE::Int32:{ - return new int32_t(_e->data.value.i); - } - case GRIN_DATATYPE::Int64:{ - return new int64_t(_e->data.value.l); - } - case GRIN_DATATYPE::Double:{ - return new double(_e->data.value.db); - } - case GRIN_DATATYPE::String:{ - auto s = _e->data.value.s; - auto len = s.size() + 1; - char* out = new char[len]; - snprintf(out, len, "%s", s.data()); - return out; - } - case GRIN_DATATYPE::Timestamp64:{ - return new int64_t(_e->data.value.d.milli_second); - } - default: - return GRIN_NULL_EDGE_DATA; - } - - +const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE e) { + auto _e = static_cast(e); + // new 返回? + auto type = _e->data.type; + switch (_get_data_type(type)) { + case GRIN_DATATYPE::Int32: { + return new int32_t(_e->data.value.i); + } + case GRIN_DATATYPE::Int64: { + return new int64_t(_e->data.value.l); + } + case GRIN_DATATYPE::Double: { + return new double(_e->data.value.db); + } + case GRIN_DATATYPE::String: { + auto s = _e->data.value.s; + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); + return out; + } + case GRIN_DATATYPE::Timestamp64: { + return new int64_t(_e->data.value.d.milli_second); + } + default: + return GRIN_NULL_EDGE_DATA; + } } #endif \ No newline at end of file diff --git a/flex/grin/src/topology/vertexlist.cc b/flex/grin/src/topology/vertexlist.cc index 1b7de42108ca..c3d43053e82b 100644 --- a/flex/grin/src/topology/vertexlist.cc +++ b/flex/grin/src/topology/vertexlist.cc @@ -17,7 +17,6 @@ limitations under the License. #include "grin/include/include/topology/vertexlist.h" - #if defined(GRIN_ENABLE_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH g) {} #endif @@ -29,7 +28,7 @@ void grin_destroy_vertex_list(GRIN_GRAPH g, GRIN_VERTEX_LIST vl) {} #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH g, GRIN_VERTEX_LIST vl) { - GRIN_VERTEX_LIST_ITERATOR_T *vlt = new GRIN_VERTEX_LIST_ITERATOR_T(); + GRIN_VERTEX_LIST_ITERATOR_T* vlt = new GRIN_VERTEX_LIST_ITERATOR_T(); vlt->cur_vid = 0; vlt->vertex_list = vl; return vlt; @@ -37,29 +36,28 @@ GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH g, void grin_destroy_vertex_list_iter(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - delete _iter; + auto _iter = static_cast(iter); + delete _iter; } void grin_get_next_vertex_list_iter(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - if(_iter->cur_vid < _iter->vertex_list.vertex_num) + auto _iter = static_cast(iter); + if (_iter->cur_vid < _iter->vertex_list.vertex_num) ++_iter->cur_vid; } bool grin_is_vertex_list_end(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); + auto _iter = static_cast(iter); return _iter->cur_vid == _iter->vertex_list.vertex_num; } GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - GRIN_VERTEX v; - auto _iter = static_cast(iter); - - v.label = _iter->vertex_list.label; - v.vid = _iter->cur_vid; + auto v = new GRIN_VERTEX_T(); + auto _iter = static_cast(iter); + v->label = _iter->vertex_list.label; + v->vid = _iter->cur_vid; return v; } #endif \ No newline at end of file diff --git a/flex/grin/test/test.cc b/flex/grin/test/test.cc index c6fe3e445ebc..ac40ae80b295 100644 --- a/flex/grin/test/test.cc +++ b/flex/grin/test/test.cc @@ -1,8 +1,8 @@ #include #include #include -#include -#include "grin/src/predefine.h" +#include +#include #include "../include/include/common/error.h" #include "../include/include/index/internal_id.h" #include "../include/include/index/label.h" @@ -22,56 +22,65 @@ #include "../include/include/topology/edgelist.h" #include "../include/include/topology/structure.h" #include "../include/include/topology/vertexlist.h" -#include - -#define FOR_VERTEX_BEGIN(g, vl, v) \ +#include "grin/src/predefine.h" +#define eps (1e-8) +#define FOR_VERTEX_BEGIN(g, vl, v) \ GRIN_VERTEX_LIST_ITERATOR __vli = grin_get_vertex_list_begin(g, vl); \ - unsigned __vcnt = 0; \ - while (!grin_is_vertex_list_end(g, __vli)) { \ - GRIN_VERTEX v = grin_get_vertex_from_iter(g, __vli); \ + unsigned __vcnt = 0; \ + while (!grin_is_vertex_list_end(g, __vli)) { \ + GRIN_VERTEX v = grin_get_vertex_from_iter(g, __vli); #ifdef GRIN_WITH_VERTEX_PROPERTY -#define FOR_VERTEX_END(g, vl, v) \ - grin_destroy_vertex(g, v); \ - __vcnt++; \ - grin_get_next_vertex_list_iter(g, __vli); \ - } \ +#define FOR_VERTEX_END(g, vl, v) \ + grin_destroy_vertex(g, v); \ + __vcnt++; \ + grin_get_next_vertex_list_iter(g, __vli); \ + } \ printf("vertex type %s, checked: %u\n", vt_names[__vtl_i], __vcnt); -#define FOR_VERTEX_LIST_BEGIN(g, vl) \ -{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ - size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ - for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ - GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, __vt); \ - grin_destroy_vertex_type(g, __vt); - -#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ -{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ - size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ - for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ - GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, __vt); \ - grin_destroy_vertex_type(g, __vt); - -#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ -{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ - size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ - for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ - GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_mirror(g, __vt); \ - grin_destroy_vertex_type(g, __vt); - -#define FOR_VERTEX_LIST_END(g, vl) \ - grin_destroy_vertex_list(g, vl); \ - } \ - grin_destroy_vertex_type_list(g, __vtl);} +#define FOR_VERTEX_LIST_BEGIN(g, vl) \ + { \ + GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = \ + grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ + { \ + GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = \ + grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = \ + grin_get_vertex_list_by_type_select_master(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ + { \ + GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = \ + grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = \ + grin_get_vertex_list_by_type_select_mirror(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_END(g, vl) \ + grin_destroy_vertex_list(g, vl); \ + } \ + grin_destroy_vertex_type_list(g, __vtl); \ + } #else -#define FOR_VERTEX_END(g, vl) \ - grin_destroy_vertex(g, v); \ - __vcnt++; \ - grin_get_next_vertex_list_iter(g, __vli); \ - } \ +#define FOR_VERTEX_END(g, vl) \ + grin_destroy_vertex(g, v); \ + __vcnt++; \ + grin_get_next_vertex_list_iter(g, __vli); \ + } \ printf("vertex checked: %u\n", __vcnt); #define FOR_VERTEX_LIST_BEGIN(g, vl) \ @@ -83,44 +92,40 @@ #define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_mirror(g); -#define FOR_VERTEX_LIST_END(g, vl) \ - grin_destroy_vertex_list(g, vl); +#define FOR_VERTEX_LIST_END(g, vl) grin_destroy_vertex_list(g, vl); #endif - - #ifdef GRIN_WITH_EDGE_PROPERTY -#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ -{ GRIN_EDGE_TYPE_LIST __etl = grin_get_edge_type_list(g); \ - size_t __etl_size = grin_get_edge_type_list_size(g, __etl); \ - for (size_t __etl_i = 0; __etl_i < __etl_size; ++__etl_i) { \ - GRIN_EDGE_TYPE __et = grin_get_edge_type_from_list(g, __etl, __etl_i); \ - GRIN_ADJACENT_LIST al = grin_get_adjacent_list_by_edge_type(g, dir, v, __et); \ - grin_destroy_edge_type(g, __et); -#define FOR_ADJ_LIST_END(g, al) \ - grin_destroy_adjacent_list(g, al); \ - } \ - grin_destroy_edge_type_list(g, __etl);} +#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ + { \ + GRIN_EDGE_TYPE_LIST __etl = grin_get_edge_type_list(g); \ + size_t __etl_size = grin_get_edge_type_list_size(g, __etl); \ + for (size_t __etl_i = 0; __etl_i < __etl_size; ++__etl_i) { \ + GRIN_EDGE_TYPE __et = grin_get_edge_type_from_list(g, __etl, __etl_i); \ + GRIN_ADJACENT_LIST al = \ + grin_get_adjacent_list_by_edge_type(g, dir, v, __et); \ + grin_destroy_edge_type(g, __et); +#define FOR_ADJ_LIST_END(g, al) \ + grin_destroy_adjacent_list(g, al); \ + } \ + grin_destroy_edge_type_list(g, __etl); \ + } #else #define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ - GRIN_ADJACENT_LIST al = grin_get_adjacent_list(g, dir, v); -#define FOR_ADJ_LIST_END(g, al) \ - grin_destroy_adjacent_list(g, al); + GRIN_ADJACENT_LIST al = grin_get_adjacent_list(g, dir, v); +#define FOR_ADJ_LIST_END(g, al) grin_destroy_adjacent_list(g, al); #endif +const char* vt_names[] = {"person", "software"}; +const char* et_names[] = {"knows", "created"}; -const char *vt_names[] = {"person", "software"}; -const char *et_names[] = {"created", "knows"}; - -const char *v_names[][4] = { - {"josh", "vadas", "peter", "marko"}, - {"lop", "ripple", "wrong", "wrong"} -}; // TODO align with order in local graph +const char* v_names[][4] = {{"josh", "vadas", "peter", "marko"}, + {"lop", "ripple", "wrong", + "wrong"}}; // TODO align with order in local graph GRIN_GRAPH get_graph(const char* uri_str, int p) { #ifdef GRIN_ENABLE_GRAPH_PARTITION - GRIN_PARTITIONED_GRAPH pg = - grin_get_partitioned_graph_from_storage(argv[1]); + GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(argv[1]); GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); assert(p < grin_get_partition_list_size(pg, local_partitions)); GRIN_PARTITION partition = @@ -141,7 +146,6 @@ GRIN_GRAPH get_graph(const char* uri_str, int p) { return g; } - #ifdef GRIN_ENABLE_GRAPH_PARTITION GRIN_VERTEX get_one_master_person(GRIN_GRAPH g) { GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); @@ -152,13 +156,13 @@ GRIN_VERTEX get_one_master_person(GRIN_GRAPH g) { grin_destroy_vertex_list_iter(g, vli); grin_destroy_vertex_list(g, vl); #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); + printf("Got vertex %s\n", + v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); #endif return v; } #endif - GRIN_VERTEX get_one_person(GRIN_GRAPH g) { GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, vt); @@ -168,12 +172,12 @@ GRIN_VERTEX get_one_person(GRIN_GRAPH g) { grin_destroy_vertex_list_iter(g, vli); grin_destroy_vertex_list(g, vl); #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); + printf("Got vertex %s\n", + v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); #endif return v; } - void test_property_type(const char* uri_str) { printf("+++++++++++++++++++++ Test property/type +++++++++++++++++++++\n"); @@ -272,7 +276,7 @@ void test_property_type(const char* uri_str) { printf("source vertex type list size: %zu\n", src_vtl_size); GRIN_VERTEX_TYPE_LIST dst_vtl = grin_get_dst_types_by_edge_type(g, et); - + size_t dst_vtl_size = grin_get_vertex_type_list_size(g, dst_vtl); printf("destination vertex type list size: %zu\n", dst_vtl_size); @@ -331,68 +335,70 @@ void test_property_vertex_property_value(const char* uri_str) { printf("------------ Test Vertex property value ------------\n"); GRIN_GRAPH g = get_graph(uri_str, 0); -// value check + // value check printf("------ check value ------\n"); -FOR_VERTEX_LIST_BEGIN(g, vl) - GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, __vt); + FOR_VERTEX_LIST_BEGIN(g, vl) + GRIN_VERTEX_PROPERTY_LIST vpl = + grin_get_vertex_property_list_by_type(g, __vt); size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); - #else - long long int vid = __vcnt; - #endif - #ifdef GRIN_ENABLE_ROW - GRIN_ROW row = grin_get_vertex_row(g, v); - #endif - for (size_t j = 0; j < vpl_size; ++j) { - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); - GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); - if (dt == Int64) { - long long int pv = - grin_get_vertex_property_value_of_int64(g, v, vp); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - long long int rv = grin_get_int64_from_row(g, row, j); - assert(pv == rv); - #endif - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - printf("%s %s: %lld\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); - #else - printf("%s %zu: %lld\n", v_names[__vt][vid], j, pv); - #endif - } else if (dt == String) { - const char* pv = - grin_get_vertex_property_value_of_string(g, v, vp); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - const char* rv = grin_get_string_from_row(g, row, j); - assert(strcmp(pv, rv) == 0); - #endif - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - printf("%s %s: %s\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); - #else - printf("%s %zu: %s\n", v_names[__vt][vid], j, pv); - #endif - grin_destroy_string_value(g, pv); - grin_destroy_string_value(g, rv); - } - grin_destroy_vertex_property(g, vp); +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); +#else + long long int vid = __vcnt; +#endif +#ifdef GRIN_ENABLE_ROW + GRIN_ROW row = grin_get_vertex_row(g, v); +#endif + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); + if (dt == Int64) { + long long int pv = grin_get_vertex_property_value_of_int64(g, v, vp); + assert(grin_get_last_error_code() == NO_ERROR); +#ifdef GRIN_ENABLE_ROW + long long int rv = grin_get_int64_from_row(g, row, j); + assert(pv == rv); +#endif +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + printf("%s %s: %lld\n", v_names[__vt][vid], + grin_get_vertex_property_name(g, __vt, vp), pv); +#else + printf("%s %zu: %lld\n", v_names[__vt][vid], j, pv); +#endif + } else if (dt == String) { + const char* pv = grin_get_vertex_property_value_of_string(g, v, vp); + assert(grin_get_last_error_code() == NO_ERROR); +#ifdef GRIN_ENABLE_ROW + const char* rv = grin_get_string_from_row(g, row, j); + assert(strcmp(pv, rv) == 0); +#endif +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + printf("%s %s: %s\n", v_names[__vt][vid], + grin_get_vertex_property_name(g, __vt, vp), pv); +#else + printf("%s %zu: %s\n", v_names[__vt][vid], j, pv); +#endif + grin_destroy_string_value(g, pv); + grin_destroy_string_value(g, rv); } - #ifdef GRIN_ENABLE_ROW - grin_destroy_row(g, row); - #endif + grin_destroy_vertex_property(g, vp); + } +#ifdef GRIN_ENABLE_ROW + grin_destroy_row(g, row); +#endif FOR_VERTEX_END(g, vl, v) grin_destroy_vertex_property_list(g, vpl); -FOR_VERTEX_LIST_END(g, vl) + FOR_VERTEX_LIST_END(g, vl) -// check schema + // check schema printf("------ check schema ------\n"); GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); for (size_t i = 0; i < vtl_size; ++i) { GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); - GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, vt); + GRIN_VERTEX_PROPERTY_LIST vpl = + grin_get_vertex_property_list_by_type(g, vt); size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); for (size_t j = 0; j < vpl_size; ++j) { GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); @@ -400,38 +406,38 @@ FOR_VERTEX_LIST_END(g, vl) assert(grin_equal_vertex_type(g, vt, vt1)); grin_destroy_vertex_type(g, vt1); - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY unsigned int id = grin_get_vertex_property_id(g, vt, vp); GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id); assert(grin_equal_vertex_property(g, vp, vp1)); grin_destroy_vertex_property(g, vp1); - #else +#else unsigned int id = i; - #endif +#endif - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME const char* vp_name = grin_get_vertex_property_name(g, vt, vp); GRIN_VERTEX_PROPERTY vp2 = grin_get_vertex_property_by_name(g, vt, vp_name); assert(grin_equal_vertex_property(g, vp, vp2)); - #else - const char* vp_name = "unknown"; - #endif +#else + const char* vp_name = "unknown"; +#endif printf("%s %u %s checked\n", vt_names[i], id, vp_name); } grin_destroy_vertex_property_list(g, vpl); // corner case - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY GRIN_VERTEX_PROPERTY vp3 = grin_get_vertex_property_by_id(g, vt, vpl_size); assert(vp3 == GRIN_NULL_VERTEX_PROPERTY); - #endif +#endif - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME GRIN_VERTEX_PROPERTY vp4 = grin_get_vertex_property_by_name(g, vt, "unknown"); assert(vp4 == GRIN_NULL_VERTEX_PROPERTY); - #endif +#endif grin_destroy_vertex_type(g, vt); } grin_destroy_vertex_type_list(g, vtl); @@ -445,11 +451,10 @@ FOR_VERTEX_LIST_END(g, vl) GRIN_VERTEX_PROPERTY_LIST vpl2 = grin_get_vertex_properties_by_name(g, "name"); assert(vpl2 != GRIN_NULL_VERTEX_PROPERTY_LIST); - + size_t vpl2_size = grin_get_vertex_property_list_size(g, vpl2); for (size_t i = 0; i < vpl2_size; ++i) { - GRIN_VERTEX_PROPERTY vp5 = - grin_get_vertex_property_from_list(g, vpl2, i); + GRIN_VERTEX_PROPERTY vp5 = grin_get_vertex_property_from_list(g, vpl2, i); GRIN_VERTEX_TYPE vt5 = grin_get_vertex_type_from_property(g, vp5); const char* vp5_name = grin_get_vertex_property_name(g, vt5, vp5); assert(strcmp(vp5_name, "name") == 0); @@ -460,95 +465,95 @@ FOR_VERTEX_LIST_END(g, vl) grin_destroy_graph(g); } -void test_property_edge_property_value(const char* uri_str, GRIN_DIRECTION dir) { +void test_property_edge_property_value(const char* uri_str, + GRIN_DIRECTION dir) { printf("------------ Test Edge property value ------------\n"); GRIN_GRAPH g = get_graph(uri_str, 0); -// value check + // value check printf("------ check value ------\n"); -FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_LIST_BEGIN(g, vl) FOR_VERTEX_BEGIN(g, vl, v) - FOR_ADJ_LIST_BEGIN(g, dir, v, al) - GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, __et); - size_t epl_size = grin_get_edge_property_list_size(g, epl); - - GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); - size_t acnt = 0; - while (!grin_is_adjacent_list_end(g, ali)) { - GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); - GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); - #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - GRIN_VERTEX_TYPE ut = grin_get_vertex_type(g, u); - long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); - long long int uid = grin_get_vertex_internal_id_by_type(g, ut, u); - grin_destroy_vertex_type(g, ut); - #else - long long int vid = __vcnt; - long long int uid = acnt; - #endif - #ifdef GRIN_ENABLE_ROW - GRIN_ROW row = grin_get_edge_row(g, e); - #endif - for (size_t j = 0; j < epl_size; ++j) { - GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); - GRIN_DATATYPE dt = grin_get_edge_property_datatype(g, ep); - if (dt == Int64) { - long long int pv = - grin_get_edge_property_value_of_int64(g, e, ep); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - long long int rv = grin_get_int64_from_row(g, row, j); - assert(pv == rv); - #endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - printf("%s %s %s: %lld\n", v_names[__vt][vid], v_names[ut][uid], - grin_get_edge_property_name(g, __et, ep), pv); - #else - printf("%s %zu %lld: %lld\n", v_names[__vt][vid], j, uid, pv); - #endif - } else if (dt == Double) { - double pv = grin_get_edge_property_value_of_double(g, e, ep); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - double rv = grin_get_double_from_row(g, row, j); - assert(pv == rv); - #endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - printf("%s %s %s: %lf\n", v_names[__vt][vid], v_names[ut][uid], - grin_get_edge_property_name(g, __et, ep), pv); - #else - printf("%s %zu %lld: %lf\n", v_names[__vt][vid], j, uid, pv); - #endif - } else if (dt == String) { - const char* pv = grin_get_edge_property_value_of_string(g, e, ep); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - const char* rv = grin_get_string_from_row(g, row, j); - assert(strcmp(pv, rv) == 0); - #endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - printf("%s %s %s: %s\n", v_names[__vt][vid], v_names[ut][uid], - grin_get_edge_property_name(g, __et, ep), pv); - #else - printf("%s %zu %lld: %s\n", v_names[__vt][vid], j, uid, pv); - #endif - } - } - #ifdef GRIN_ENABLE_ROW - grin_destroy_row(g, row); - #endif - grin_destroy_edge(g, e); - grin_destroy_vertex(g, u); - acnt++; - grin_get_next_adjacent_list_iter(g, ali); + FOR_ADJ_LIST_BEGIN(g, dir, v, al) + GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, __et); + size_t epl_size = grin_get_edge_property_list_size(g, epl); + GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); + size_t acnt = 0; + while (!grin_is_adjacent_list_end(g, ali)) { + GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); + GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + GRIN_VERTEX_TYPE ut = grin_get_vertex_type(g, u); + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + long long int uid = grin_get_vertex_internal_id_by_type(g, ut, u); + grin_destroy_vertex_type(g, ut); +#else + long long int vid = __vcnt; + long long int uid = acnt; +#endif +#ifdef GRIN_ENABLE_ROW + GRIN_ROW row = grin_get_edge_row(g, e); + +#endif + for (size_t j = 0; j < epl_size; ++j) { + GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); + GRIN_DATATYPE dt = grin_get_edge_property_datatype(g, ep); + if (dt == Int64) { + long long int pv = grin_get_edge_property_value_of_int64(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); +#ifdef GRIN_ENABLE_ROW + long long int rv = grin_get_int64_from_row(g, row, j); + assert(pv == rv); +#endif +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %lld\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); +#else + printf("%s %zu %lld: %lld\n", v_names[__vt][vid], j, uid, pv); +#endif + } else if (dt == Double) { + double pv = grin_get_edge_property_value_of_double(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); +#ifdef GRIN_ENABLE_ROW + double rv = grin_get_double_from_row(g, row, j); + assert(abs(pv - rv) < eps); +#endif +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %lf\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); +#else + printf("%s %zu %lld: %lf\n", v_names[__vt][vid], j, uid, pv); +#endif + } else if (dt == String) { + const char* pv = grin_get_edge_property_value_of_string(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); +#ifdef GRIN_ENABLE_ROW + const char* rv = grin_get_string_from_row(g, row, j); + assert(strcmp(pv, rv) == 0); +#endif +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %s\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); +#else + printf("%s %zu %lld: %s\n", v_names[__vt][vid], j, uid, pv); +#endif } - grin_destroy_adjacent_list_iter(g, ali); - grin_destroy_edge_property_list(g, epl); - FOR_ADJ_LIST_END(g, al) + } +#ifdef GRIN_ENABLE_ROW + grin_destroy_row(g, row); +#endif + grin_destroy_edge(g, e); + grin_destroy_vertex(g, u); + acnt++; + grin_get_next_adjacent_list_iter(g, ali); + } + grin_destroy_adjacent_list_iter(g, ali); + grin_destroy_edge_property_list(g, epl); + FOR_ADJ_LIST_END(g, al) FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) + FOR_VERTEX_LIST_END(g, vl) -// check schema + // check schema printf("------ check schema ------\n"); GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); size_t etl_size = grin_get_edge_type_list_size(g, etl); @@ -562,56 +567,51 @@ FOR_VERTEX_LIST_END(g, vl) assert(grin_equal_edge_type(g, et, et1)); grin_destroy_edge_type(g, et1); - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY unsigned int id = grin_get_edge_property_id(g, et, ep); GRIN_EDGE_PROPERTY ep1 = grin_get_edge_property_by_id(g, et, id); assert(grin_equal_edge_property(g, ep, ep1)); grin_destroy_edge_property(g, ep1); - #else +#else unsigned int id = i; - #endif +#endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME const char* ep_name = grin_get_edge_property_name(g, et, ep); - GRIN_EDGE_PROPERTY ep2 = - grin_get_edge_property_by_name(g, et, ep_name); + GRIN_EDGE_PROPERTY ep2 = grin_get_edge_property_by_name(g, et, ep_name); assert(grin_equal_edge_property(g, ep, ep2)); - #else - const char* ep_name = "unknown"; - #endif +#else + const char* ep_name = "unknown"; +#endif printf("%s %u %s checked\n", et_names[i], id, ep_name); } grin_destroy_edge_property_list(g, epl); // corner case - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY GRIN_EDGE_PROPERTY ep3 = grin_get_edge_property_by_id(g, et, epl_size); assert(ep3 == GRIN_NULL_EDGE_PROPERTY); - #endif +#endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - GRIN_EDGE_PROPERTY ep4 = - grin_get_edge_property_by_name(g, et, "unknown"); +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME + GRIN_EDGE_PROPERTY ep4 = grin_get_edge_property_by_name(g, et, "unknown"); assert(ep4 == GRIN_NULL_EDGE_PROPERTY); - #endif +#endif grin_destroy_edge_type(g, et); } grin_destroy_edge_type_list(g, etl); // corner case #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - GRIN_EDGE_PROPERTY_LIST epl1 = - grin_get_edge_properties_by_name(g, "unknown"); + GRIN_EDGE_PROPERTY_LIST epl1 = grin_get_edge_properties_by_name(g, "unknown"); assert(epl1 == GRIN_NULL_EDGE_PROPERTY_LIST); - GRIN_EDGE_PROPERTY_LIST epl2 = - grin_get_edge_properties_by_name(g, "weight"); + GRIN_EDGE_PROPERTY_LIST epl2 = grin_get_edge_properties_by_name(g, "weight"); assert(epl2 != GRIN_NULL_EDGE_PROPERTY_LIST); - + size_t epl2_size = grin_get_edge_property_list_size(g, epl2); for (size_t i = 0; i < epl2_size; ++i) { - GRIN_EDGE_PROPERTY ep5 = - grin_get_edge_property_from_list(g, epl2, i); + GRIN_EDGE_PROPERTY ep5 = grin_get_edge_property_from_list(g, epl2, i); GRIN_EDGE_TYPE et5 = grin_get_edge_type_from_property(g, ep5); const char* ep5_name = grin_get_edge_property_name(g, et5, ep5); assert(strcmp(ep5_name, "weight") == 0); @@ -622,8 +622,6 @@ FOR_VERTEX_LIST_END(g, vl) grin_destroy_graph(g); } - - #ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS void test_property_primary_key(const char* uri_str) { printf( @@ -634,7 +632,7 @@ void test_property_primary_key(const char* uri_str) { size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); printf("vertex type num with primary key: %zu\n", vtl_size); - unsigned id_type[7] = {~0, 0, 0, 1, 0, 1, 0}; + unsigned id_type[7] = {static_cast(~0), 0, 0, 1, 0, 1, 0}; for (size_t i = 0; i < vtl_size; ++i) { GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); @@ -699,7 +697,6 @@ void test_error_code(const char* uri_str) { assert(grin_get_last_error_code() == INVALID_VALUE); } - void test_property(const char* uri_str) { test_property_type(uri_str); test_property_vertex_property_value(uri_str); @@ -715,9 +712,10 @@ void test_property(const char* uri_str) { /** void test_partition_reference(const char* uri_str) { - printf("+++++++++++++++++++++ Test partition/reference +++++++++++++++++++++\n"); - GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(argv[1]); - GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); + printf("+++++++++++++++++++++ Test partition/reference ++++++++++++++++++++++\n"); GRIN_PARTITIONED_GRAPH pg = +grin_get_partitioned_graph_from_storage(argv[1]); GRIN_PARTITION_LIST +local_partitions = grin_get_local_partition_list(pg); assert(grin_get_partition_list_size(pg, local_partitions) >= 2); GRIN_PARTITION p0 = grin_get_partition_from_list(pg, local_partitions, 0); @@ -746,7 +744,7 @@ FOR_VERTEX_LIST_BEGIN(g0, vl0) GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); if (!grin_equal_partition(g0, p, p0)) { printf("(Wrong) partition not match in vertex ref\n"); - } + } grin_destroy_partition(pg, p); grin_destroy_vertex(g0, v1); grin_destroy_vertex_ref(g0, vref1); @@ -788,8 +786,8 @@ FOR_VERTEX_LIST_END(g0, vl0) void test_partition_topology(const char* uri_str) { - printf("+++++++++++++++++++++ Test partition/topology +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(uri_str, 0); + printf("+++++++++++++++++++++ Test partition/topology ++++++++++++++++++++++\n"); GRIN_GRAPH g = get_graph(uri_str, 0); printf("----- check master ----- \n"); FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) @@ -825,9 +823,9 @@ void test_partition(const char* uri_str) { #endif }*/ - void test_topology_structure(const char* uri_str) { - printf("+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n"); + printf( + "+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n"); GRIN_GRAPH g = get_graph(uri_str, 0); #ifndef GRIN_WITH_VERTEX_PROPERTY printf("vertex num: %zu\n", grin_get_vertex_num(g)); @@ -839,99 +837,103 @@ void test_topology_structure(const char* uri_str) { grin_destroy_graph(g); } - void test_topology_vertex_list(const char* uri_str) { - printf("+++++++++++++++++++++ Test topology/vertex_list +++++++++++++++++++++\n"); + printf( + "+++++++++++++++++++++ Test topology/vertex_list " + "+++++++++++++++++++++\n"); GRIN_GRAPH g = get_graph(uri_str, 0); -FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_LIST_BEGIN(g, vl) FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - #endif +#ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); +#endif FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) + FOR_VERTEX_LIST_END(g, vl) grin_destroy_graph(g); } - void test_topology_adjacent_list(const char* uri_str, GRIN_DIRECTION dir) { if (dir == IN) { - printf("+++++++++++++++++++++ Test topology/adjacent_list IN +++++++++++++++++++++\n"); + printf( + "+++++++++++++++++++++ Test topology/adjacent_list IN " + "+++++++++++++++++++++\n"); } else { - printf("+++++++++++++++++++++ Test topology/adjacent_list OUT +++++++++++++++++++++\n"); + printf( + "+++++++++++++++++++++ Test topology/adjacent_list OUT " + "+++++++++++++++++++++\n"); } GRIN_GRAPH g = get_graph(uri_str, 0); -FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_LIST_BEGIN(g, vl) FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); - #else - long long int vid = __vcnt; - #endif - #ifdef GRIN_ENABLE_GRAPH_PARTITION - if (!grin_is_master_vertex(g, v)) { - grin_destroy_vertex(g, v); - grin_get_next_vertex_list_iter(g, __vli); - continue; +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); +#else + long long int vid = __vcnt; +#endif +#ifdef GRIN_ENABLE_GRAPH_PARTITION + if (!grin_is_master_vertex(g, v)) { + grin_destroy_vertex(g, v); + grin_get_next_vertex_list_iter(g, __vli); + continue; + } +#endif + FOR_ADJ_LIST_BEGIN(g, dir, v, al) + GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); + size_t acnt = 0; + while (!grin_is_adjacent_list_end(g, ali)) { + GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); + GRIN_VERTEX v1 = grin_get_src_vertex_from_edge(g, e); + GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge(g, e); + GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY + GRIN_EDGE e1 = grin_get_edge_from_adjacent_list(g, al, acnt); + GRIN_VERTEX e1v1 = grin_get_src_vertex_from_edge(g, e1); + GRIN_VERTEX e1v2 = grin_get_dst_vertex_from_edge(g, e1); + assert(grin_equal_vertex(g, v1, e1v1)); + assert(grin_equal_vertex(g, v2, e1v2)); + grin_destroy_edge(g, e1); + grin_destroy_vertex(g, e1v1); + grin_destroy_vertex(g, e1v2); +#endif + + if (dir == OUT) { + assert(grin_equal_vertex(g, v, v1)); + assert(grin_equal_vertex(g, v2, u)); + } else { + assert(grin_equal_vertex(g, v, v2)); + assert(grin_equal_vertex(g, v1, u)); } - #endif - FOR_ADJ_LIST_BEGIN(g, dir, v, al) - GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); - size_t acnt = 0; - while (!grin_is_adjacent_list_end(g, ali)) { - GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); - GRIN_VERTEX v1 = grin_get_src_vertex_from_edge(g, e); - GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge(g, e); - GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); - - #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY - GRIN_EDGE e1 = grin_get_edge_from_adjacent_list(g, al, acnt); - GRIN_VERTEX e1v1 = grin_get_src_vertex_from_edge(g, e1); - GRIN_VERTEX e1v2 = grin_get_dst_vertex_from_edge(g, e1); - assert(grin_equal_vertex(g, v1, e1v1)); - assert(grin_equal_vertex(g, v2, e1v2)); - grin_destroy_edge(g, e1); - grin_destroy_vertex(g, e1v1); - grin_destroy_vertex(g, e1v2); - #endif - - if (dir == OUT) { - assert(grin_equal_vertex(g, v, v1)); - assert(grin_equal_vertex(g, v2, u)); - } else { - assert(grin_equal_vertex(g, v, v2)); - assert(grin_equal_vertex(g, v1, u)); - } - grin_destroy_vertex(g, v1); - grin_destroy_vertex(g, v2); - grin_destroy_vertex(g, u); - grin_destroy_edge(g, e); - - acnt++; - grin_get_next_adjacent_list_iter(g, ali); - } - #ifdef GRIN_ENABLE_ADJAECENT_LIST_ARRAY - assert(acnt == grin_get_adjacent_list_size(g, al)); - #endif - grin_destroy_adjacent_list_iter(g, ali); - #ifdef GRIN_WITH_EDGE_PROPERTY - printf("vertex %s adjlist, edgetype: %s, checked num: %zu\n", v_names[__vt][vid], et_names[__etl_i], acnt); - #else - printf("vertex %s adjlist, checked num: %zu\n", v_names[__vt][vid], acnt); - #endif - FOR_ADJ_LIST_END(g, al) + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v2); + grin_destroy_vertex(g, u); + grin_destroy_edge(g, e); + + acnt++; + grin_get_next_adjacent_list_iter(g, ali); + } +#ifdef GRIN_ENABLE_ADJAECENT_LIST_ARRAY + assert(acnt == grin_get_adjacent_list_size(g, al)); +#endif + grin_destroy_adjacent_list_iter(g, ali); +#ifdef GRIN_WITH_EDGE_PROPERTY + printf("vertex %s adjlist, edgetype: %s, checked num: %zu\n", + v_names[__vt][vid], et_names[__etl_i], acnt); +#else + printf("vertex %s adjlist, checked num: %zu\n", v_names[__vt][vid], acnt); +#endif + FOR_ADJ_LIST_END(g, al) FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) + FOR_VERTEX_LIST_END(g, vl) grin_destroy_graph(g); } - void test_topology(const char* uri_str) { test_topology_structure(uri_str); test_topology_vertex_list(uri_str); @@ -939,60 +941,63 @@ void test_topology(const char* uri_str) { test_topology_adjacent_list(uri_str, IN); } -#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && \ + defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) void test_index_order(const char* uri_str) { printf("+++++++++++++++++++++ Test index order +++++++++++++++++++++\n"); GRIN_GRAPH g = get_graph(uri_str, 0); -FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_LIST_BEGIN(g, vl) FOR_VERTEX_BEGIN(g, vl, v) - size_t pos = grin_get_position_of_vertex_from_sorted_list(g, vl, v); - assert(pos == __vcnt); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + assert(pos == __vcnt); FOR_VERTEX_END(g, vl, v) - #ifdef GRIN_ENABLE_GRAPH_PARTITION -{ - GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_master(g, __vt); - size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); - for (size_t i = 0; i < mvlist_sz; ++i) { - GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); - size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); - assert(pos == i); - size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - grin_destroy_vertex(g, v); + { + GRIN_VERTEX_LIST mvlist = + grin_get_vertex_list_by_type_select_master(g, __vt); + size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); + for (size_t i = 0; i < mvlist_sz; ++i) { + GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); + assert(pos == i); + size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v); + } + grin_destroy_vertex_list(g, mvlist); } - grin_destroy_vertex_list(g, mvlist); -} -{ - GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_mirror(g, __vt); - size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); - for (size_t i = 0; i < mvlist_sz; ++i) { - GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); - size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); - assert(pos == i); - size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - grin_destroy_vertex(g, v); + { + GRIN_VERTEX_LIST mvlist = + grin_get_vertex_list_by_type_select_mirror(g, __vt); + size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); + for (size_t i = 0; i < mvlist_sz; ++i) { + GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); + assert(pos == i); + size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v); + } + grin_destroy_vertex_list(g, mvlist); } - grin_destroy_vertex_list(g, mvlist); -} #endif -FOR_VERTEX_LIST_END(g, vl) + FOR_VERTEX_LIST_END(g, vl) grin_destroy_graph(g); } #endif void test_index_internal_id(const char* uri_str) { - printf("+++++++++++++++++++++ Test index internal id +++++++++++++++++++++\n"); + printf( + "+++++++++++++++++++++ Test index internal id +++++++++++++++++++++\n"); GRIN_GRAPH g = get_graph(uri_str, 0); -FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_LIST_BEGIN(g, vl) long long int min = grin_get_vertex_internal_id_lower_bound_by_type(g, __vt); long long int max = grin_get_vertex_internal_id_upper_bound_by_type(g, __vt); FOR_VERTEX_BEGIN(g, vl, v) @@ -1004,14 +1009,14 @@ FOR_VERTEX_LIST_BEGIN(g, vl) grin_destroy_vertex(g, v1); #endif FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) + FOR_VERTEX_LIST_END(g, vl) grin_destroy_graph(g); } - void test_index(const char* uri_str) { -#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && \ + defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) test_index_order(uri_str); #endif #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX @@ -1024,7 +1029,7 @@ void test_vertex_property_value(const char* uri_str) { GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt, "age"); GRIN_VERTEX v = get_one_person(g); - + struct timeval t1, t2; gettimeofday(&t1, NULL); for (int i = 0; i < 1000000; ++i) { @@ -1032,7 +1037,7 @@ void test_vertex_property_value(const char* uri_str) { } gettimeofday(&t2, NULL); double elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; - elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; + elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; printf("%f ms.\n", elapsedTime); grin_destroy_vertex(g, v); grin_destroy_vertex_property(g, vp); @@ -1040,18 +1045,17 @@ void test_vertex_property_value(const char* uri_str) { grin_destroy_graph(g); } -void test_perf(const char* uri_str) { - test_vertex_property_value(uri_str); -} +void test_perf(const char* uri_str) { test_vertex_property_value(uri_str); } int main(int argc, char** argv) { const char* uri_str = "flex://" - "/Users/liulx/Downloads/code/GraphScope/flex/storages/rt_mutable_graph/modern_graph"; - + "/Users/liulx/Downloads/code/GraphScope/flex/storages/rt_mutable_graph/" + "modern_graph"; + test_index(uri_str); test_property(uri_str); - //test_partition(uri_str); + // test_partition(uri_str); test_topology(uri_str); test_perf(uri_str); return 0; diff --git a/flex/storages/rt_mutable_graph/mutable_csr.h b/flex/storages/rt_mutable_graph/mutable_csr.h index 793145afa48c..df0f609f40fc 100644 --- a/flex/storages/rt_mutable_graph/mutable_csr.h +++ b/flex/storages/rt_mutable_graph/mutable_csr.h @@ -34,7 +34,9 @@ template struct MutableNbr { MutableNbr() = default; MutableNbr(const MutableNbr& rhs) - : neighbor(rhs.neighbor), timestamp(rhs.timestamp.load()), data(rhs.data) {} + : neighbor(rhs.neighbor), + timestamp(rhs.timestamp.load()), + data(rhs.data) {} ~MutableNbr() = default; vid_t neighbor; diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index 5742eee06aa5..3475fbea2660 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -279,8 +279,8 @@ void MutablePropertyFragment::initEdges( std::tie(ie_[index], oe_[index]) = construct_csr( filenames, property_types, ie_strtagy, oe_strtagy, lf_indexers_[src_label_i], lf_indexers_[dst_label_i]); - -// LOG(FATAL) << "Unsupported edge property type."; + + // LOG(FATAL) << "Unsupported edge property type."; } } else { LOG(FATAL) << "Unsupported edge property type."; diff --git a/flex/storages/rt_mutable_graph/schema.cc b/flex/storages/rt_mutable_graph/schema.cc index 099c9f5c4cc1..a8cf71f6e32c 100644 --- a/flex/storages/rt_mutable_graph/schema.cc +++ b/flex/storages/rt_mutable_graph/schema.cc @@ -358,9 +358,9 @@ static PropertyType StringToPropertyType(const std::string& str) { return PropertyType::kEmpty; } else if (str == "int64") { return PropertyType::kInt64; - } else if (str == "double"){ + } else if (str == "double") { return PropertyType::kDouble; - }else { + } else { return PropertyType::kEmpty; } } diff --git a/flex/utils/property/types.h b/flex/utils/property/types.h index 51d9b3ffcb6d..bd0b57ab30bf 100644 --- a/flex/utils/property/types.h +++ b/flex/utils/property/types.h @@ -45,9 +45,9 @@ struct Date { Date() = default; ~Date() = default; Date(int64_t x); - Date(const char *str); + Date(const char* str); - void reset(const char *str); + void reset(const char* str); std::string to_string() const; int64_t milli_second; @@ -64,7 +64,8 @@ union AnyValue { double db; }; -template struct AnyConverter; +template +struct AnyConverter; struct Any { Any() : type(PropertyType::kEmpty) {} @@ -99,7 +100,7 @@ struct Any { value.s = v; } - void set_double(double db){ + void set_double(double db) { type = PropertyType::kDouble; value.db = db; } @@ -116,7 +117,7 @@ struct Any { return value.d.to_string(); } else if (type == PropertyType::kEmpty) { return "NULL"; - } else if (type == PropertyType::kDouble){ + } else if (type == PropertyType::kDouble) { return std::to_string(value.db); } else { LOG(FATAL) << "Unexpected property type: " << static_cast(type); @@ -139,17 +140,18 @@ struct Any { return value.db; } - const std::string_view &AsStringView() const { + const std::string_view& AsStringView() const { assert(type == PropertyType::kString); return value.s; } - const Date &AsDate() const { + const Date& AsDate() const { assert(type == PropertyType::kDate); return value.d; } - template static Any From(const T &value) { + template + static Any From(const T& value) { return AnyConverter::to_any(value); } @@ -157,250 +159,264 @@ struct Any { AnyValue value; }; -template struct ConvertAny { - static void to(const Any &value, T &out) { +template +struct ConvertAny { + static void to(const Any& value, T& out) { LOG(FATAL) << "Unexpected convert type..."; } }; -template <> struct ConvertAny { - static void to(const Any &value, int &out) { +template <> +struct ConvertAny { + static void to(const Any& value, int& out) { CHECK(value.type == PropertyType::kInt32); out = value.value.i; } }; - -template <> struct ConvertAny { - static void to(const Any &value, int64_t &out) { +template <> +struct ConvertAny { + static void to(const Any& value, int64_t& out) { CHECK(value.type == PropertyType::kInt64); out = value.value.l; } }; -template <> struct ConvertAny { - static void to(const Any &value, Date &out) { +template <> +struct ConvertAny { + static void to(const Any& value, Date& out) { CHECK(value.type == PropertyType::kDate); out = value.value.d; } }; -template <> struct ConvertAny { - static void to(const Any &value, grape::EmptyType &out) { +template <> +struct ConvertAny { + static void to(const Any& value, grape::EmptyType& out) { CHECK(value.type == PropertyType::kEmpty); } }; -template <> struct ConvertAny { - static void to(const Any &value, std::string &out) { +template <> +struct ConvertAny { + static void to(const Any& value, std::string& out) { CHECK(value.type == PropertyType::kString); out = std::string(value.value.s); } }; -template <> struct ConvertAny { - static void to(const Any& value, double& out){ +template <> +struct ConvertAny { + static void to(const Any& value, double& out) { CHECK(value.type == PropertyType::kDouble); out = value.value.db; } }; -template struct AnyConverter {}; +template +struct AnyConverter {}; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kInt32; - static Any to_any(const int &value) { + static Any to_any(const int& value) { Any ret; ret.set_integer(value); return ret; } - static AnyValue to_any_value(const int &value) { + static AnyValue to_any_value(const int& value) { AnyValue ret; ret.i = value; return ret; } - static const int &from_any(const Any &value) { + static const int& from_any(const Any& value) { CHECK(value.type == PropertyType::kInt32); return value.value.i; } - static const int &from_any_value(const AnyValue &value) { return value.i; } + static const int& from_any_value(const AnyValue& value) { return value.i; } }; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kInt64; - static Any to_any(const int64_t &value) { + static Any to_any(const int64_t& value) { Any ret; ret.set_long(value); return ret; } - static AnyValue to_any_value(const int64_t &value) { + static AnyValue to_any_value(const int64_t& value) { AnyValue ret; ret.l = value; return ret; } - static const int64_t &from_any(const Any &value) { + static const int64_t& from_any(const Any& value) { CHECK(value.type == PropertyType::kInt64); return value.value.l; } - static const int64_t &from_any_value(const AnyValue &value) { + static const int64_t& from_any_value(const AnyValue& value) { return value.l; } }; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kDate; - static Any to_any(const Date &value) { + static Any to_any(const Date& value) { Any ret; ret.set_date(value); return ret; } - static AnyValue to_any_value(const Date &value) { + static AnyValue to_any_value(const Date& value) { AnyValue ret; ret.d = value; return ret; } - static const Date &from_any(const Any &value) { + static const Date& from_any(const Any& value) { CHECK(value.type == PropertyType::kDate); return value.value.d; } - static const Date &from_any_value(const AnyValue &value) { return value.d; } + static const Date& from_any_value(const AnyValue& value) { return value.d; } }; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kString; - static Any to_any(const std::string_view &value) { + static Any to_any(const std::string_view& value) { Any ret; ret.set_string(value); return ret; } - static AnyValue to_any_value(const std::string_view &value) { + static AnyValue to_any_value(const std::string_view& value) { AnyValue ret; ret.s = value; return ret; } - static const std::string_view &from_any(const Any &value) { + static const std::string_view& from_any(const Any& value) { CHECK(value.type == PropertyType::kString); return value.value.s; } - static const std::string_view &from_any_value(const AnyValue &value) { + static const std::string_view& from_any_value(const AnyValue& value) { return value.s; } }; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kString; - static Any to_any(const std::string &value) { + static Any to_any(const std::string& value) { Any ret; ret.set_string(value); return ret; } - static AnyValue to_any_value(const std::string &value) { + static AnyValue to_any_value(const std::string& value) { AnyValue ret; ret.s = value; return ret; } - static std::string from_any(const Any &value) { + static std::string from_any(const Any& value) { CHECK(value.type == PropertyType::kString); return std::string(value.value.s); } - static std::string from_any_value(const AnyValue &value) { + static std::string from_any_value(const AnyValue& value) { return std::string(value.s); } }; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kEmpty; - static Any to_any(const grape::EmptyType &value) { + static Any to_any(const grape::EmptyType& value) { Any ret; return ret; } - static AnyValue to_any_value(const grape::EmptyType &value) { + static AnyValue to_any_value(const grape::EmptyType& value) { AnyValue ret; return ret; } - static grape::EmptyType from_any(const Any &value) { + static grape::EmptyType from_any(const Any& value) { CHECK(value.type == PropertyType::kEmpty); return grape::EmptyType(); } - static grape::EmptyType from_any_value(const AnyValue &value) { + static grape::EmptyType from_any_value(const AnyValue& value) { return grape::EmptyType(); } }; -template <> struct AnyConverter { +template <> +struct AnyConverter { static constexpr PropertyType type = PropertyType::kDouble; - static Any to_any(const double &value) { + static Any to_any(const double& value) { Any ret; - ret.set_long(value); + ret.set_double(value); return ret; } - static AnyValue to_any_value(const double &value) { + static AnyValue to_any_value(const double& value) { AnyValue ret; ret.db = value; return ret; } - static const double &from_any(const Any &value) { + static const double& from_any(const Any& value) { CHECK(value.type == PropertyType::kDouble); return value.value.db; } - static const double &from_any_value(const AnyValue &value) { + static const double& from_any_value(const AnyValue& value) { return value.db; } }; -void ParseRecord(const char *line, std::vector &rec); +void ParseRecord(const char* line, std::vector& rec); -void ParseRecord(const char *line, int64_t &id, std::vector &rec); +void ParseRecord(const char* line, int64_t& id, std::vector& rec); -void ParseRecordX(const char *line, int64_t &src, int64_t &dst, int &prop); +void ParseRecordX(const char* line, int64_t& src, int64_t& dst, int& prop); -void ParseRecordX(const char *line, int64_t &src, int64_t &dst, Date &prop); +void ParseRecordX(const char* line, int64_t& src, int64_t& dst, Date& prop); -void ParseRecordX(const char *line, int64_t &src, int64_t &dst, - grape::EmptyType &prop); +void ParseRecordX(const char* line, int64_t& src, int64_t& dst, + grape::EmptyType& prop); void ParseRecordX(const char* line, int64_t& src, int64_t& dst, double& prop); -grape::InArchive &operator<<(grape::InArchive &in_archive, const Any &value); -grape::OutArchive &operator>>(grape::OutArchive &out_archive, Any &value); +grape::InArchive& operator<<(grape::InArchive& in_archive, const Any& value); +grape::OutArchive& operator>>(grape::OutArchive& out_archive, Any& value); -} // namespace gs +} // namespace gs namespace std { -inline ostream &operator<<(ostream &os, const gs::Date &dt) { +inline ostream& operator<<(ostream& os, const gs::Date& dt) { os << dt.to_string(); return os; } -inline ostream &operator<<(ostream &os, gs::PropertyType pt) { +inline ostream& operator<<(ostream& os, gs::PropertyType pt) { switch (pt) { case gs::PropertyType::kInt32: os << "int32"; @@ -427,6 +443,6 @@ inline ostream &operator<<(ostream &os, gs::PropertyType pt) { return os; } -} // namespace std +} // namespace std -#endif // GRAPHSCOPE_TYPES_H_ +#endif // GRAPHSCOPE_TYPES_H_ From f99ef2ae5afabd8833af01fe3eee3b378d0d579a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 12:41:55 +0800 Subject: [PATCH 03/30] implement get_edge_num_by_type interfaces --- flex/grin/src/predefine.h | 6 +++--- flex/grin/src/property/topology.cc | 23 ++++++++++++++++++++++- flex/grin/test/test.cc | 5 ++++- flex/utils/property/types.h | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/flex/grin/src/predefine.h b/flex/grin/src/predefine.h index 47a86a956005..cd9c45f7ee35 100644 --- a/flex/grin/src/predefine.h +++ b/flex/grin/src/predefine.h @@ -29,10 +29,10 @@ typedef struct GRIN_ADJACENT_LIST_T { #endif #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -struct GRIN_ADJACENT_LIST_ITERATOR_T { +typedef struct GRIN_ADJACENT_LIST_ITERATOR_T { std::shared_ptr edge_iter; GRIN_ADJACENT_LIST_T* adj_list; -}; +} GRIN_ADJACENT_LIST_ITERATOR_T; #endif #ifdef GRIN_WITH_VERTEX_PROPERTY @@ -57,7 +57,7 @@ typedef std::vector GRIN_EDGE_PROPERTY_LIST_T; #endif #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef struct { +typedef struct GRIN_VERTEX_LIST_ITERATOR_T { size_t cur_vid; GRIN_VERTEX_LIST vertex_list; } GRIN_VERTEX_LIST_ITERATOR_T; diff --git a/flex/grin/src/property/topology.cc b/flex/grin/src/property/topology.cc index e32ff7754380..69bfc250b00f 100644 --- a/flex/grin/src/property/topology.cc +++ b/flex/grin/src/property/topology.cc @@ -22,7 +22,28 @@ size_t grin_get_vertex_num_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { #endif #ifdef GRIN_WITH_EDGE_PROPERTY -size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { return 0; } +size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { + auto src_label = et >> 16; + auto dst_label = (et >> 8) & (0xff); + auto edge_label = et & (0xff); + auto _g = static_cast(g); + + auto oe = _g->get_oe_csr(src_label, dst_label, edge_label); + auto vertex_num = _g->vertex_num(src_label); + size_t edge_num = 0; + for (auto i = 0; i < vertex_num; ++i) { + edge_num += oe->edge_iter(i)->size(); + } + if (edge_num != 0) { + return edge_num; + } + auto ie = _g->get_ie_csr(dst_label, src_label, edge_label); + vertex_num = _g->vertex_num(dst_label); + for (auto i = 0; i < vertex_num; ++i) { + edge_num += ie->edge_iter(i)->size(); + } + return edge_num; +} #endif #if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) diff --git a/flex/grin/test/test.cc b/flex/grin/test/test.cc index ac40ae80b295..0cb3754a5bb2 100644 --- a/flex/grin/test/test.cc +++ b/flex/grin/test/test.cc @@ -3,6 +3,9 @@ #include #include #include + +#include "grin/src/predefine.h" + #include "../include/include/common/error.h" #include "../include/include/index/internal_id.h" #include "../include/include/index/label.h" @@ -22,7 +25,7 @@ #include "../include/include/topology/edgelist.h" #include "../include/include/topology/structure.h" #include "../include/include/topology/vertexlist.h" -#include "grin/src/predefine.h" + #define eps (1e-8) #define FOR_VERTEX_BEGIN(g, vl, v) \ GRIN_VERTEX_LIST_ITERATOR __vli = grin_get_vertex_list_begin(g, vl); \ diff --git a/flex/utils/property/types.h b/flex/utils/property/types.h index 8dc83aa468a1..8bbf54c64bc9 100644 --- a/flex/utils/property/types.h +++ b/flex/utils/property/types.h @@ -22,6 +22,7 @@ limitations under the License. #include #include +#define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_NONSTD #include "grape/serialization/in_archive.h" #include "grape/serialization/out_archive.h" From b8aa2ac41876915d9c71a227f544d9d7f3fc2291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 13:33:40 +0800 Subject: [PATCH 04/30] add test.c --- flex/grin/CMakeLists.txt | 2 +- flex/grin/src/topology/structure.cc | 9 ++++++++- flex/grin/test/{test.cc => test.c} | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) rename flex/grin/test/{test.cc => test.c} (99%) diff --git a/flex/grin/CMakeLists.txt b/flex/grin/CMakeLists.txt index d9cdea8aa993..a9914a6a7db4 100644 --- a/flex/grin/CMakeLists.txt +++ b/flex/grin/CMakeLists.txt @@ -69,7 +69,7 @@ add_library(flex_grin SHARED ${SOURCES}) target_link_libraries(flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES} ${YAML_CPP_LIBRARIES}) -add_executable(run_grin_test test/test.cc) +add_executable(run_grin_test test/test.c) target_include_directories(run_grin_test PRIVATE ${LIBGRAPELITE_INCLUDE_DIRS}/grape/analytical_apps fragment) target_link_libraries(run_grin_test flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES}) diff --git a/flex/grin/src/topology/structure.cc b/flex/grin/src/topology/structure.cc index d20d073f39ea..47721aae071a 100644 --- a/flex/grin/src/topology/structure.cc +++ b/flex/grin/src/topology/structure.cc @@ -15,8 +15,15 @@ limitations under the License. #include "grin/src/predefine.h" -#include #include "grin/include/include/topology/structure.h" + +/** + * @brief Get a (non-partitioned) graph from storage + * @param uri The URI of the graph. + * Current URI format: + * flex://{path_to_yaml} + * @return A graph handle. + */ GRIN_GRAPH grin_get_graph_from_storage(const char* uri) { std::string _uri(uri); std::string::size_type pos = _uri.find("://"); diff --git a/flex/grin/test/test.cc b/flex/grin/test/test.c similarity index 99% rename from flex/grin/test/test.cc rename to flex/grin/test/test.c index 0cb3754a5bb2..a59a20ddbdb6 100644 --- a/flex/grin/test/test.cc +++ b/flex/grin/test/test.c @@ -2,9 +2,9 @@ #include #include #include -#include +#include -#include "grin/src/predefine.h" +#include "grin/predefine.h" #include "../include/include/common/error.h" #include "../include/include/index/internal_id.h" @@ -519,7 +519,7 @@ void test_property_edge_property_value(const char* uri_str, assert(grin_get_last_error_code() == NO_ERROR); #ifdef GRIN_ENABLE_ROW double rv = grin_get_double_from_row(g, row, j); - assert(abs(pv - rv) < eps); + assert(fabs(pv - rv) < eps); #endif #ifdef GRIN_WITH_EDGE_PROPERTY_NAME printf("%s %s %s: %lf\n", v_names[__vt][vid], v_names[ut][uid], @@ -635,7 +635,7 @@ void test_property_primary_key(const char* uri_str) { size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); printf("vertex type num with primary key: %zu\n", vtl_size); - unsigned id_type[7] = {static_cast(~0), 0, 0, 1, 0, 1, 0}; + unsigned id_type[7] = {(~0), 0, 0, 1, 0, 1, 0}; for (size_t i = 0; i < vtl_size; ++i) { GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); From 799825e7d8d3a4b5d2827f9a27456feb9913ce35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 15:17:34 +0800 Subject: [PATCH 05/30] mv grin to graph_db --- .gitmodules | 3 - .../graph_db}/grin/CMakeLists.txt | 14 +- flex/engines/graph_db/grin/include/.gitignore | 2 + flex/engines/graph_db/grin/include/LICENSE | 201 ++ flex/engines/graph_db/grin/include/README.md | 11 + .../graph_db/grin/include/docs/Makefile | 20 + .../graph_db/grin/include/docs/make.bat | 35 + .../include/docs/source/0.get_started.rst | 65 + .../include/docs/source/1.return_value.rst | 116 ++ .../grin/include/docs/source/2.api_naming.rst | 71 + .../include/docs/source/3.topology_api.rst | 42 + .../include/docs/source/4.partition_api.rst | 64 + .../include/docs/source/5.property_api.rst | 56 + .../grin/include/docs/source/6.index_api.rst | 43 + .../grin/include/docs/source/7.extension.rst | 20 + .../graph_db/grin/include/docs/source/conf.py | 28 + .../grin/include/docs/source/index.rst | 43 + .../extension/include/predefine.template.h | 45 + .../extension/include/topology/list_chain.h | 89 + .../grin/include/include/common/error.h | 40 + .../grin/include/include/common/message.h | 37 + .../grin/include/include/index/internal_id.h | 98 + .../grin/include/include/index/label.h | 108 ++ .../grin/include/include/index/order.h | 46 + .../graph_db/grin/include/include/index/pk.h | 46 + .../include/include/partition/partition.h | 89 + .../include/include/partition/reference.h | 159 ++ .../grin/include/include/partition/topology.h | 126 ++ .../grin/include/include/property/partition.h | 80 + .../include/include/property/primarykey.h | 67 + .../grin/include/include/property/property.h | 269 +++ .../include/include/property/propertylist.h | 98 + .../grin/include/include/property/row.h | 115 ++ .../grin/include/include/property/topology.h | 74 + .../grin/include/include/property/type.h | 176 ++ .../include/include/topology/adjacentlist.h | 117 ++ .../grin/include/include/topology/edgelist.h | 54 + .../grin/include/include/topology/structure.h | 121 ++ .../include/include/topology/vertexlist.h | 94 + .../proto/gie_data_model/data_type.proto | 127 ++ .../include/proto/gie_data_model/graph.proto | 13 + .../proto/gie_data_model/partition.proto | 123 ++ .../include/proto/gie_data_model/schema.proto | 46 + .../proto/gie_data_model/statistics.proto | 30 + .../graph_db/grin/include/proto/graph.proto | 141 ++ .../graph_db/grin/include/rust/Cargo.toml | 75 + .../graph_db/grin/include/rust/grin.rs | 1693 +++++++++++++++++ .../graph_db/grin/include/rust/grin_all.h | 83 + .../graph_db/grin/include/rust/grin_all.rs | 1368 +++++++++++++ .../graph_db/grin/include/rust/grin_v6d.h | 38 + .../graph_db/grin/include/rust/grin_v6d.rs | 97 + .../graph_db/grin/include/rust/parse.py | 257 +++ .../grin/include/storage/GART/predefine.h | 237 +++ .../grin/include/storage/GraphAr/predefine.h | 243 +++ .../grin/include/storage/v6d/predefine.h | 241 +++ .../graph_db/grin/include/template/features.h | 506 +++++ .../grin/include/template/predefine.h | 273 +++ .../engines/graph_db/grin/include/test/test.c | 1052 ++++++++++ .../graph_db/grin/include/yaml/schema.yaml | 69 + flex/{ => engines/graph_db}/grin/predefine.h | 0 .../graph_db}/grin/src/common/error.cc | 0 .../graph_db}/grin/src/index/internal_id.cc | 0 .../graph_db}/grin/src/index/pk.cc | 0 .../graph_db}/grin/src/predefine.cc | 0 .../graph_db}/grin/src/predefine.h | 2 +- .../graph_db}/grin/src/property/primarykey.cc | 0 .../graph_db}/grin/src/property/property.cc | 0 .../grin/src/property/propertylist.cc | 0 .../graph_db}/grin/src/property/row.cc | 0 .../graph_db}/grin/src/property/topology.cc | 0 .../graph_db}/grin/src/property/type.cc | 0 .../grin/src/topology/adjacentlist.cc | 0 .../graph_db}/grin/src/topology/structure.cc | 0 .../graph_db}/grin/src/topology/vertexlist.cc | 0 flex/{ => engines/graph_db}/grin/test/test.c | 0 flex/grin/include | 1 - 76 files changed, 9685 insertions(+), 12 deletions(-) rename flex/{ => engines/graph_db}/grin/CMakeLists.txt (83%) create mode 100644 flex/engines/graph_db/grin/include/.gitignore create mode 100644 flex/engines/graph_db/grin/include/LICENSE create mode 100644 flex/engines/graph_db/grin/include/README.md create mode 100644 flex/engines/graph_db/grin/include/docs/Makefile create mode 100644 flex/engines/graph_db/grin/include/docs/make.bat create mode 100644 flex/engines/graph_db/grin/include/docs/source/0.get_started.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/1.return_value.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/5.property_api.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/6.index_api.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/7.extension.rst create mode 100644 flex/engines/graph_db/grin/include/docs/source/conf.py create mode 100644 flex/engines/graph_db/grin/include/docs/source/index.rst create mode 100644 flex/engines/graph_db/grin/include/extension/include/predefine.template.h create mode 100644 flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h create mode 100644 flex/engines/graph_db/grin/include/include/common/error.h create mode 100644 flex/engines/graph_db/grin/include/include/common/message.h create mode 100644 flex/engines/graph_db/grin/include/include/index/internal_id.h create mode 100644 flex/engines/graph_db/grin/include/include/index/label.h create mode 100644 flex/engines/graph_db/grin/include/include/index/order.h create mode 100644 flex/engines/graph_db/grin/include/include/index/pk.h create mode 100644 flex/engines/graph_db/grin/include/include/partition/partition.h create mode 100644 flex/engines/graph_db/grin/include/include/partition/reference.h create mode 100644 flex/engines/graph_db/grin/include/include/partition/topology.h create mode 100644 flex/engines/graph_db/grin/include/include/property/partition.h create mode 100644 flex/engines/graph_db/grin/include/include/property/primarykey.h create mode 100644 flex/engines/graph_db/grin/include/include/property/property.h create mode 100644 flex/engines/graph_db/grin/include/include/property/propertylist.h create mode 100644 flex/engines/graph_db/grin/include/include/property/row.h create mode 100644 flex/engines/graph_db/grin/include/include/property/topology.h create mode 100644 flex/engines/graph_db/grin/include/include/property/type.h create mode 100644 flex/engines/graph_db/grin/include/include/topology/adjacentlist.h create mode 100644 flex/engines/graph_db/grin/include/include/topology/edgelist.h create mode 100644 flex/engines/graph_db/grin/include/include/topology/structure.h create mode 100644 flex/engines/graph_db/grin/include/include/topology/vertexlist.h create mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto create mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto create mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto create mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto create mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto create mode 100644 flex/engines/graph_db/grin/include/proto/graph.proto create mode 100644 flex/engines/graph_db/grin/include/rust/Cargo.toml create mode 100644 flex/engines/graph_db/grin/include/rust/grin.rs create mode 100644 flex/engines/graph_db/grin/include/rust/grin_all.h create mode 100644 flex/engines/graph_db/grin/include/rust/grin_all.rs create mode 100644 flex/engines/graph_db/grin/include/rust/grin_v6d.h create mode 100644 flex/engines/graph_db/grin/include/rust/grin_v6d.rs create mode 100644 flex/engines/graph_db/grin/include/rust/parse.py create mode 100644 flex/engines/graph_db/grin/include/storage/GART/predefine.h create mode 100644 flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h create mode 100644 flex/engines/graph_db/grin/include/storage/v6d/predefine.h create mode 100644 flex/engines/graph_db/grin/include/template/features.h create mode 100644 flex/engines/graph_db/grin/include/template/predefine.h create mode 100644 flex/engines/graph_db/grin/include/test/test.c create mode 100644 flex/engines/graph_db/grin/include/yaml/schema.yaml rename flex/{ => engines/graph_db}/grin/predefine.h (100%) rename flex/{ => engines/graph_db}/grin/src/common/error.cc (100%) rename flex/{ => engines/graph_db}/grin/src/index/internal_id.cc (100%) rename flex/{ => engines/graph_db}/grin/src/index/pk.cc (100%) rename flex/{ => engines/graph_db}/grin/src/predefine.cc (100%) rename flex/{ => engines/graph_db}/grin/src/predefine.h (95%) rename flex/{ => engines/graph_db}/grin/src/property/primarykey.cc (100%) rename flex/{ => engines/graph_db}/grin/src/property/property.cc (100%) rename flex/{ => engines/graph_db}/grin/src/property/propertylist.cc (100%) rename flex/{ => engines/graph_db}/grin/src/property/row.cc (100%) rename flex/{ => engines/graph_db}/grin/src/property/topology.cc (100%) rename flex/{ => engines/graph_db}/grin/src/property/type.cc (100%) rename flex/{ => engines/graph_db}/grin/src/topology/adjacentlist.cc (100%) rename flex/{ => engines/graph_db}/grin/src/topology/structure.cc (100%) rename flex/{ => engines/graph_db}/grin/src/topology/vertexlist.cc (100%) rename flex/{ => engines/graph_db}/grin/test/test.c (100%) delete mode 160000 flex/grin/include diff --git a/.gitmodules b/.gitmodules index dcf152e47bc9..f038d8b178ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "learning_engine/graph-learn"] path = learning_engine/graph-learn url = https://github.com/alibaba/graph-learn.git -[submodule "flex/grin/include"] - path = flex/grin/include - url = https://github.com/GraphScope/GRIN.git diff --git a/flex/grin/CMakeLists.txt b/flex/engines/graph_db/grin/CMakeLists.txt similarity index 83% rename from flex/grin/CMakeLists.txt rename to flex/engines/graph_db/grin/CMakeLists.txt index a9914a6a7db4..1fdc6341eeeb 100644 --- a/flex/grin/CMakeLists.txt +++ b/flex/engines/graph_db/grin/CMakeLists.txt @@ -24,14 +24,14 @@ find_package(OpenMP REQUIRED) find_package(libgrapelite REQUIRED) include_directories(${LIBGRAPELITE_INCLUDE_DIRS}) -include("../../flex/cmake/FindGFlags.cmake") +include("../../../../flex/cmake/FindGFlags.cmake") if (GFLAGS_FOUND) include_directories(SYSTEM ${GFLAGS_INCLUDE_DIRS}) else () message(FATAL_ERROR "gflags not found") endif () -include("../../flex/cmake/FindGlog.cmake") +include("../../../../flex/cmake/FindGlog.cmake") include_directories(SYSTEM ${GLOG_INCLUDE_DIRS}) if (GLOG_FOUND) set(CMAKE_REQUIRED_INCLUDES "${GLOG_INCLUDE_DIRS}") @@ -49,12 +49,12 @@ set(yaml-cpp_INCLUDE_DIRS "/usr/local/Cellar/yaml-cpp/0.7.0/include") include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) set(YAML_CPP_LIBRARIES "/usr/local/Cellar/yaml-cpp/0.7.0/lib/libyaml-cpp.0.7.0.dylib") -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../..) message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../storages/rt_mutable_graph) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../utils/property) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../storages/rt_mutable_graph) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../utils/property) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) file(GLOB_RECURSE FILES_NEED_FORMAT "src/*.cc") @@ -64,7 +64,7 @@ add_custom_target(grin_clformat COMMENT "Running clang-format." VERBATIM) -file(GLOB SOURCES "src/*.cc" "src/topology/*.cc" "src/property/*.cc" "src/index/*.cc" "src/common/*.cc" "../utils/property/*.cc" "../storages/rt_mutable_graph/*.cc") +file(GLOB SOURCES "src/*.cc" "src/topology/*.cc" "src/property/*.cc" "src/index/*.cc" "src/common/*.cc" "../../../utils/property/*.cc" "../../../storages/rt_mutable_graph/*.cc") add_library(flex_grin SHARED ${SOURCES}) target_link_libraries(flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES} ${YAML_CPP_LIBRARIES}) diff --git a/flex/engines/graph_db/grin/include/.gitignore b/flex/engines/graph_db/grin/include/.gitignore new file mode 100644 index 000000000000..97424860a106 --- /dev/null +++ b/flex/engines/graph_db/grin/include/.gitignore @@ -0,0 +1,2 @@ +/docs/build +.vscode/ diff --git a/flex/engines/graph_db/grin/include/LICENSE b/flex/engines/graph_db/grin/include/LICENSE new file mode 100644 index 000000000000..261eeb9e9f8b --- /dev/null +++ b/flex/engines/graph_db/grin/include/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/flex/engines/graph_db/grin/include/README.md b/flex/engines/graph_db/grin/include/README.md new file mode 100644 index 000000000000..69145a54035b --- /dev/null +++ b/flex/engines/graph_db/grin/include/README.md @@ -0,0 +1,11 @@ +# GRIN +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 engines in GraphScope, and to simplify the integration of these engines with each other. + +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 engine. + +These operations include: +* Traversal: navigating the graph structure to explore relationships between vertices +* Retrieval: retrieving the data and properties of vertices and edges +* Filter: filtering data structures with partitioning or property conditions + +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 engine. diff --git a/flex/engines/graph_db/grin/include/docs/Makefile b/flex/engines/graph_db/grin/include/docs/Makefile new file mode 100644 index 000000000000..d0c3cbf1020d --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/flex/engines/graph_db/grin/include/docs/make.bat b/flex/engines/graph_db/grin/include/docs/make.bat new file mode 100644 index 000000000000..747ffb7b3033 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/flex/engines/graph_db/grin/include/docs/source/0.get_started.rst b/flex/engines/graph_db/grin/include/docs/source/0.get_started.rst new file mode 100644 index 000000000000..da51dc905793 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/0.get_started.rst @@ -0,0 +1,65 @@ +Getting Started +---------------- + +Get Graph from Storage +^^^^^^^^^^^^^^^^^^^^^^ +To use GRIN, the first API we need is to get a graph handle for the graph in storage. +Here we introduce the ``grin_get_graph_from_storage`` API. + +:: + + GRIN_GRAPH grin_get_graph_from_storage(const char* uri); + +This API takes a URI as its parameter, which is a string that identifies the graph in storage. + +Different storage systems may define different required parameters in the URI: + - gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version} + - graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy} + - v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional. + +The return value of this API is a GRIN graph handle. + +Partitioned Graph +^^^^^^^^^^^^^^^^^ +In GRIN, a partitioned graph is a graph that is split into multiple fragments, +which can be stored separately. + +To work with a partitioned graph, we first need to get a handle to the partitioned graph. +We can do this using the `grin_get_partitioned_graph_from_storage` function. + +:: + + GRIN_PARTITIONED_GRAPH grin_get_partitioned_graph_from_storage(const char* uri); + +The parameters of this API are the same as the ``grin_get_graph_from_storage`` API. +The return value of this API is a GRIN partitioned graph handle. + +Once we have a handle to the partitioned graph, we can access the individual +graph fragments using the `grin_get_local_partition_list` and `grin_get_graph_by_partition` functions. + +:: + + GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(uri); + GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); + size_t num_partitions = grin_get_partition_list_size(local_partitions); + + if (num_partitions == 1) { // suppose we have only one local partition + GRIN_PARTITION partition = grin_get_partition_from_list(pg, local_partitions, 0); + GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition); + } + +We can then perform operations on each fragment of the partitioned graph, +just as we would with a regular graph. + +Note that partitioned graphs can be useful for working with large graphs +that are too large to be stored in memory all at once. By splitting the graph +into smaller fragments, we can work with the graph more efficiently. + +In the above code, all the types with ``GRIN_`` prefix are GRIN handle types. +A GRIN handle is an opaque value that identifies an object in GRIN. +It is important to note that the specific type of the handle, +whether it be an integer, a pointer, or something else, is not specified by +GRIN APIs and may vary between different implementations of GRIN from different storage systems. +Therefore, it is not safe to make assumptions about the type of a handle and +its properties based on its value. +Instead, you should use the GRIN APIs to access the object associated with the handle. diff --git a/flex/engines/graph_db/grin/include/docs/source/1.return_value.rst b/flex/engines/graph_db/grin/include/docs/source/1.return_value.rst new file mode 100644 index 000000000000..1be0347027c1 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/1.return_value.rst @@ -0,0 +1,116 @@ +Return Values +-------------- +Handle +^^^^^^^ + +In most cases, the return value of a GRIN API call is a GRIN handle. +A GRIN handle represents a GRIN object, such as a vertex or edge, and can be +used as a parameter for another GRIN API call. +For example, in the previous section, we obtained a GRIN_GRAPH handle g, +which we can use to get a vertex list of the graph: + +:: + + #ifdef GRIN_WITH_VERTEX_PROPERTY + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_LIST vlist = grin_get_vertex_list_by_type(g, vt); + #else + GRIN_VERTEX_LIST vlist = grin_get_vertex_list(g); + #endif + + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + size_t vlist_size = grin_get_vertex_list_size(g, vlist); + + for (unsigned int i = 0; i < vlist_size; ++i){ + GRIN_VERTEX v = grin_get_vertex_from_list(g, vlist, i); + // use v + grin_destroy_vertex(g, v); + } + #endif + + #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR + GRIN_VERTEX_LIST_ITERATOR vlist_iter = grin_get_vertex_list_begin(g, vlist); + + while (grin_is_vertex_list_end(g, vlist_iter)) { + GRIN_VERTEX v = grin_get_vertex_from_iter(g, vlist_iter); + // use v + grin_destroy_vertex(g, v); + grin_get_next_vertex_list_iter(g, vlist_iter); + } + + grin_destroy_vertex_list_iter(g, vlist_iter); + #endif + + grin_destroy_vertex_list(g, vlist); + +In the first step, we obtain a vertex list handle from a graph handle. +Note that when vertex property is supported (i.e., GRIN_WITH_VERTEX_PROPERTY is defined), +GRIN only provides the API to get the vertex list of a single type (e.g., person). +This is based on the low-level API design principle of GRIN, which means +GRIN APIs are a set of low-level abstractions for graph-retrieval actions. +Please refer to the low-level API subsection in the topology API section for more details. +However, GRIN does provide high-level APIs in its extensions. +Please refer to the extension section for more details. + +In the next step, the vertex list can be accessed in two ways: array and iterator. +This is also controlled by the macros enabled by the storage. +Some storage may only support one type of access, while some may support both. + +In the final step, we have to destroy every handle we obtain from GRIN to avoid memory leaks. + +Others +^^^^^^ +Exceptionally, there are three types of values returned by GRIN API calls other than handles: + +- GRIN enumerates: This includes enumerates defined in predefine.h, namely GRIN_DIRECTION, GRIN_DATATYPE, and GRIN_ERROR_CODE. +- Common values: This includes common values such as ``size_t`` for list size, ``bool`` for condition check, ``unsigned int`` for ID, and ``const char*`` for name. +- Property values: This includes property values such as ``int32``, ``int64``, ``float``, ``double``, and ``const char*``. The types are defined in the ``GRIN_DATATYPE`` enumerate. +- Serialized values: This includes serialized ``const char*`` from vertex ref or edge ref. + +Users do NOT have to destroy these return values since they are on the ``"stack"``, +except for the ``const char*`` in property values and serialized values. +In this case, users have to destroy the string value by using ``grin_destroy_string_value`` +and ``grin_destroy_serialized_vertex(edge)_ref``, respectively. +Note that if the ``const char*`` is returned by a GRIN API call for a name, +such as a vertex type name or edge property name, users do NOT have to destroy +it since they are common values. + +Validation +^^^^^^^^^^^ +GRIN provides invalid values for handles to let users check whether a handle +is valid or not. Normally, the invalid value of a GRIN handle ``GRIN_A`` is +defined as ``GRIN_NULL_A``. GRIN also provides invalid values for common values, +namely ``GRIN_NULL_SIZE`` and ``GRIN_NULL_NAME``. GRIN does NOT provide invalid +values for enumerates because each enumerate should cover all possible values. +GRIN also does NOT define invalid values for property values because there is +no specific value that can be defined as invalid for types like ``int32`` or ``double``. +This case is handled by GRIN error codes, as explained in the next section. + +Error Code +^^^^^^^^^^^ +GRIN defines a set of error codes in the ``GRIN_ERROR_CODE`` enumerate. +When a GRIN API call encounters an error but cannot return invalid values +(e.g., the property value case above), it can set the thread_local error code to +indicate the error. Users can get the error code using the ``grin_get_last_error_code`` +API and handle the error case accordingly. + +:: + + int value = grin_get_int32_from_row(g, row, 0); + if (grin_get_last_error_code() != GRIN_ERROR_CODE::GRIN_NO_ERROR) { + // handle error + } + +Summary +^^^^^^^ +To summerize, we list a table for return values of GRIN API calls and related operations: + +=================== =========================== ================= +Return Value Types Check Invalid Destroy Required +=================== =========================== ================= +handle != GRIN_NULL_A grin_destroy_A +GRIN enumerates N/A N/A +Common values != GRIN_NULL_X N/A +Property values grin_get_last_error_code grin_destroy_string_value only +Serialized values N/A grin_destroy_serialized_A_ref only +=================== =========================== ================= diff --git a/flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst b/flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst new file mode 100644 index 000000000000..6e9fc73cb855 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst @@ -0,0 +1,71 @@ +API Naming Rules +---------------- +Common Get +^^^^^^^^^^ +=========================== ============== +Format Description +=========================== ============== +grin_get_A return handle A or the value of some statitic A +grin_get_A_of_T return A of type T +grin_get_A_from_B A is an element of B and A must be a handle. In case B is A list, use grin_get_A_from_list for short +grin_get_A_by_B use B to find A, B can be id or name +grin_get_A_B B is an element of A, and B is NOT a handle or value. B can be name, datatype, id, or size +grin_get_As_with_B get A list with B enabled, B can be primary_keys +=========================== ============== + +List +^^^^ +=========================== ============== +Format Description +=========================== ============== +grin_get_A_list_begin return A list begin iterator +grin_get_next_A_list_iter get next iterator +grin_is_A_list_end check if end iterator +grin_get_A_from_iter get A from A list iterator, note that we use **from** but not **by** since A list is not a parameter, meaning that we are NOT using the iterator to find A from A list but simply get A from the iterator +grin_get_A_from_B_iter A != B, e.g., A and B can be neighbor(vertex) and adjacent list +grin_insert_A_to_list insert A to A list +=========================== ============== + +Ref & Serialization +^^^^^^^^^^^^^^^^^^^ +=========================== ============== +Format Description +=========================== ============== +grin_serialize_A serialize A into const char*, in fast ref, use grin_serialize_A_as_int64 +grin_deserialize_to_A deserialze const char* to A, in fast ref, use grin_deserialize_int64_to_A +=========================== ============== + + +Value +^^^^^ +=========================== ============== +Format Description +=========================== ============== +grin_get_A_datatype follow grin_get_A_B and return GRIN_DATATYPE +grin_get_value_from_A follow grin_get_B_from_A and return const void*, A can be row +grin_get_T_from_A follow grin_get_B_from_A and return T, A can be row +grin_insert_value_to_A insert const void* value to A, A can be row +girn_insert_T_to_A insert value of type T to A, A can be row +=========================== ============== + + +Others +^^^^^^ +=========================== ============== +Format Description +=========================== ============== +grin_destroy_A destroy handle of A +grin_is_X check whether condition X statisfied +grin_equal_A check whether two A handles are equal +grin_get_A_list_select_B select elements in A list based on B, B can be master, mirror or certain partition +=========================== ============== + + + +Parameter Order +^^^^^^^^^^^^^^^ +Rules to order parameters of APIs: + +- From larger-range handle to smaller-range handle + + diff --git a/flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst b/flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst new file mode 100644 index 000000000000..b4e2b98e4f15 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst @@ -0,0 +1,42 @@ +Topology APIs +------------- + +Topology lists +^^^^^^^^^^^^^^^ + +GRIN considers vertex list, edge list, and adjacent list as ``Topology Lists`` +and designs related APIs using the same principle. +GRIN provides low-level abstractions for topology lists. +Thus, in property graphs with various vertex types and edge types, +GRIN only provides APIs to get the vertex list and edge list of a single type +because a vertex list containing vertices of different types can be easily +constructed by merging vertex lists of different types. +GRIN will support such high-level abstractions in the future under ``GRIN extension``. + +Vertex List +^^^^^^^^^^^ + +In a simple graph, GRIN provides the ``grin_get_vertex_list`` API to get the +vertex list of the graph. In a property graph, GRIN provides the +``grin_get_vertex_list_by_type`` API to get the vertex list. Also, in a +partitioned graph, when ``GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST`` features +are enabled, GRIN provides two groups of additional APIs: +``grin_get_vertex_list_select_master, grin_get_vertex_list_select_mirror`` and +``grin_get_vertex_list_by_type_select_master, grin_get_vertex_list_by_type_select_mirror`` +for simple graph and property graph, respectively. + +Edge List +^^^^^^^^^^ + +Similar to the vertex list, GRIN provides the ``grin_get_edge_list`` API to get +the edge list for a simple graph and ``grin_get_edge_list_by_type`` for a property graph. + +Adjacent List +^^^^^^^^^^^^^^ + +GRIN considers the adjacent list as a special case of the edge list and thus +also provides the ``grin_get_adjacent_list_by_edge_type`` API for a property graph, +as well as ``grin_get_adjacent_list`` for a simple graph. +Additional selections can also be attached to adjacent lists of both simple graph +and property graph, such as ``grin_get_adjacent_list_select_neighbor_partition``, +``grin_get_adjacent_list_by_edge_type_select_master_neighbor``, etc. \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst b/flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst new file mode 100644 index 000000000000..13c44238a851 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst @@ -0,0 +1,64 @@ +Partition APIs +-------------- + +Vertex Reference +^^^^^^^^^^^^^^^^ +``GRIN_VERTEX_REF`` is a reference to a vertex in the graph. It is used to exchange vertex information +with remote partitions. + +To get the ``vertex_ref`` of a ``vertex`` and vice-versa, use: + +:: + + GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH, GRIN_VERTEX); + + GRIN_VERTEX grin_get_vertex_by_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + +Since ``GRIN_VERETX_REF`` is still a handle, we can further serialize it into ``const char*`` or +``int64`` if ``GRIN_TRAIT_FAST_VERTEX_REF`` is defined. + +:: + + const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + + #ifdef GRIN_TRAIT_FAST_VERTEX_REF + long long int grin_serialize_vertex_ref_as_int64(GRIN_GRAPH, GRIN_VERTEX_REF); + #endif + +Accordingly, the ``vertex_ref`` can be deserialized from ``const char*`` or ``int64``. + +:: + + GRIN_VERTEX_REF grin_deserialize_vertex_ref(GRIN_GRAPH, const char*); + + #ifdef GRIN_TRAIT_FAST_VERTEX_REF + GRIN_VERTEX_REF grin_deserialize_int64_to_vertex_ref(GRIN_GRAPH, long long int); + #endif + +Users can also get the master partition of a vertex using its vertex reference. + +:: + + GRIN_PARTITION grin_get_master_partition_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + +Actually vertex reference implies a vertex partition protocol between partitions. + + +Select Master +^^^^^^^^^^^^^ +In partitioned graph, a common need is to select master vertices from a vertex list. +Particularly in edgecut, this stands for the ``inner`` vertices of a partition. + +GRIN provides related APIS to handle this if corresponding traits are defined. + +:: + + GRIN_VERTEX_LIST vlist = grin_get_vertex_list(g); + + #ifdef GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST + GRIN_VERTEX_LIST master_vlist = grin_select_master_for_vertex_list(g, vlist); + + grin_destroy_vertex_list(g, master_vlist); + #endif + + grin_destroy_vertex_list(g, vlist); diff --git a/flex/engines/graph_db/grin/include/docs/source/5.property_api.rst b/flex/engines/graph_db/grin/include/docs/source/5.property_api.rst new file mode 100644 index 000000000000..8e01927f9106 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/5.property_api.rst @@ -0,0 +1,56 @@ +Property APIs +-------------- + +Get Vertex Property Value +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +GRIN provides APIs to get a single property value of a vertex, as well as all the property values +of a vertex as a row. + +:: + + GRIN_ROW row = grin_get_vertex_row(g, v); + + GRIN_VERTEX_TYPE vtype = grin_get_vertex_type(g, v); + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, vtype); + size_t vpl_sz = grin_get_vertex_property_list_size(g, vpl); + + for (size_t i = 0; i < vpl_sz; ++i) { + GRIN_VERTEX_PROPERTY vprop = grin_get_vertex_property_from_list(g, vpl, i); + GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vprop); + + if (dt == Int64) { + long long int value = grin_get_vertex_property_value_of_int64(g, v, vprop); + long long int value1 = grin_get_int64_from_row(g, row, i); + // use the value + } else if (dt == String) { + const char* value = grin_get_vertex_property_value_of_string(g, v, vprop); + const char* value1 = grin_get_string_from_row(g, row, i); + // use the value + grin_destroy_string_value(g, value); + grin_destroy_string_value(g, value1); + } else ... + } + + +Primary Key +^^^^^^^^^^^^ +GRIN explicitly distinguishes the concepts of primary keys and indexing based on primary keys. +Primary keys are used to identify a vertex or an edge, and just like in relational databases, +they are unique under a given vertex or edge type. +Indexing based on primary keys is the ability to find a vertex or an edge by its primary key. +These two sets of APIs are defined in ``property/primarykey.h`` and ``index/pk.h`` respectively. +Indexing with PK is discussed in the index section. + +Getting the primary key of a vertex is similar to getting the value of a property. +Users first get a row for the values of PK properties using the API +``grin_get_vertex_primary_keys_row``, and then get values from the row one-by-one. + + + + + + + + + + diff --git a/flex/engines/graph_db/grin/include/docs/source/6.index_api.rst b/flex/engines/graph_db/grin/include/docs/source/6.index_api.rst new file mode 100644 index 000000000000..542e34c2cdd2 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/6.index_api.rst @@ -0,0 +1,43 @@ +Index APIs +-------------- + +Sorted List and Order +^^^^^^^^^^^^^^^^^^^^^^ +Some storage sort the vertices in a vertex list by default. +This enables the ability to let the user to find the position of a vertex in the list +in sub-linear time complexity (O(log(n)) for binary search). + +To describe this feature, storage can define ``GRIN_ASSUME_ALL_VERTEX_LIST_SORTED`` to show +that all the vertex lists are sorted by default. If ``GRIN_ENABLE_VERTEX_LIST_ARRAY`` is also +defined, the position API is enabled: + +:: + + size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH, GRIN_VERTEX_LIST, GRIN_VERTEX); + +Internal ID +^^^^^^^^^^^ +Internal ID is an integer range indexing for vertices of a certain type. +The key feature of internal ID is that storage can provide lower and upper +bounds (left-closed, right-open) for internal IDs of vertices of a certain type. +This enables the ability to use vertices as an array index in the computing engine. + +PK Indexing +^^^^^^^^^^^^^ +To get a vertex from its PK values, we will first put all the values into a row +according to the PK properties of the vertex's type. Then we can use the row +to get the vertex handle. The following example shows how to get the vertex of +type "person" with name "marko" and age 29 if the PK properties of "person" are +"name" and "age" + +:: + + GRIN_VERTEX_TYPE vtype = grin_get_vertex_type_by_name(g, "person"); + GRIN_ROW row = grin_create_row(g); + if (!grin_insert_string_to_row(g, row, "marko")) { + printf("Failed to insert string to row\n"); + } + if (!grin_insert_int32_to_row(g, row, 29)) { + printf("Failed to insert int32 to row\n"); + } + GRIN_VERTEX v = grin_get_vertex_by_primary_keys(g, vtype, row); \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/docs/source/7.extension.rst b/flex/engines/graph_db/grin/include/docs/source/7.extension.rst new file mode 100644 index 000000000000..ae892b2b3f2e --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/7.extension.rst @@ -0,0 +1,20 @@ +Extension +-------------- + +GRIN Extension offers high-level APIs to expand functionality, as well as a +default implementation using GRIN basic (low-level) APIs. +Certain GRIN Extension APIs can be overwritten by a more efficient +implementation from storage. + +List Chain +^^^^^^^^^^^ + +Starting from v0.1, GRIN provides topology lists (i.e., vertex/edge/adjacent list) +of a single vertex or edge type in property graph to keep the basic APIs +low-level abstraction. However, in many cases, users need to traverse all the +vertices in a property graph. Although the user can first iterate all the vertex +types and then get the vertex list of each vertex type to traverse, this approach +increases boilerplate code. Thus, we provide a high-level handle ``VertexListChain`` +and related APIs in GRIN extension to handle this case. +Since we call them list chains, we only provide iterators to traverse the +list chain, but not array-like access. diff --git a/flex/engines/graph_db/grin/include/docs/source/conf.py b/flex/engines/graph_db/grin/include/docs/source/conf.py new file mode 100644 index 000000000000..bf2d996978c4 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/conf.py @@ -0,0 +1,28 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'GRIN' +copyright = '2023, grin workers' +author = 'grin workers' +release = '0.1.1' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [] + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'furo' +html_static_path = ['_static'] diff --git a/flex/engines/graph_db/grin/include/docs/source/index.rst b/flex/engines/graph_db/grin/include/docs/source/index.rst new file mode 100644 index 000000000000..b5090b37b420 --- /dev/null +++ b/flex/engines/graph_db/grin/include/docs/source/index.rst @@ -0,0 +1,43 @@ +.. GRIN documentation master file, created by + sphinx-quickstart on Thu May 11 17:08:47 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to GRIN's documentation! +================================ + +**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 engines in GraphScope, +and to simplify the integration of these engines with each other. + +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 engine. + +These operations include: + +- *Traversal*: navigating the graph structure to explore relationships between vertices +- *Retrieval*: retrieving the data and properties of vertices and edges +- *Filter*: filtering data structures with partitioning or property conditions + +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 engine. + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + 0.get_started + 1.return_value + 2.api_naming + 3.topology_api + 4.partition_api + 5.property_api + 6.index_api + 7.extension + + + diff --git a/flex/engines/graph_db/grin/include/extension/include/predefine.template.h b/flex/engines/graph_db/grin/include/extension/include/predefine.template.h new file mode 100644 index 000000000000..ad65ede10325 --- /dev/null +++ b/flex/engines/graph_db/grin/include/extension/include/predefine.template.h @@ -0,0 +1,45 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file extension/predefine.h + * @brief Pre-defined macros, handles and null values for + * GRIN extensions. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_EXTENSION_INCLUDE_PREDEFINE_H_ +#define GRIN_EXTENSION_INCLUDE_PREDEFINE_H_ + +typedef void* GRIN_VERTEX_LIST_CHAIN; + +typedef void* GRIN_VERTEX_LIST_CHAIN_ITERATOR; + +typedef void* GRIN_EDGE_LIST_CHAIN; + +typedef void* GRIN_EDGE_LIST_CHAIN_ITERATOR; + +typedef void* GRIN_ADJACENT_LIST_CHAIN; + +typedef void* GRIN_ADJACENT_LIST_CHAIN_ITERATOR; + +#endif // GRIN_EXTENSION_INCLUDE_PREDEFINE_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h b/flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h new file mode 100644 index 000000000000..dc859f175f47 --- /dev/null +++ b/flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h @@ -0,0 +1,89 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_EXTENSION_INCLUDE_TOPOLOGY_LIST_CHAIN_H_ +#define GRIN_EXTENSION_INCLUDE_TOPOLOGY_LIST_CHAIN_H_ + +#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types(GRIN_GRAPH); + +void grin_destroy_vertex_list_chain(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN); + +GRIN_VERTEX_LIST_CHAIN_ITERATOR grin_get_vertex_list_chain_begin(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN); + +void grin_destroy_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); + +void grin_get_next_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); + +bool grin_is_vertex_list_chain_end(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); + +GRIN_VERTEX grin_get_vertex_from_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); +#endif + +#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) +GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_master(GRIN_GRAPH); + +GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_mirror(GRIN_GRAPH); +#endif + +#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types(GRIN_GRAPH); + +void grin_destroy_edge_list_chain(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN); + +GRIN_EDGE_LIST_CHAIN_ITERATOR grin_get_edge_list_chain_begin(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN); + +void grin_destroy_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); + +void grin_get_next_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); + +bool grin_is_edge_list_chain_end(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); + +GRIN_EDGE grin_get_edge_from_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); +#endif + +#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) +GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types_select_master(GRIN_GRAPH); + +GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types_select_mirror(GRIN_GRAPH); +#endif + +#if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_ADJACENT_LIST_CHAIN grin_get_adjacent_list_chain_of_all_edge_types(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); + +void grin_destroy_adjacent_list_chain(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN); + +GRIN_ADJACENT_LIST_CHAIN_ITERATOR grin_get_adjacent_list_chain_begin(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN); + +void grin_destroy_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); + +void grin_get_next_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); + +bool grin_is_adjacent_list_chain_end(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); + +GRIN_EDGE grin_get_edge_from_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); + +GRIN_VERTEX grin_get_neighbor_from_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); +#endif + +#endif // GRIN_EXTENSION_INCLUDE_TOPOLOGY_VERTEX_LIST_CHAIN_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/common/error.h b/flex/engines/graph_db/grin/include/include/common/error.h new file mode 100644 index 000000000000..fccbd1aad186 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/common/error.h @@ -0,0 +1,40 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file error.h + @brief Define the error code related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_COMMON_ERROR_H_ +#define GRIN_INCLUDE_COMMON_ERROR_H_ + + +extern __thread GRIN_ERROR_CODE grin_error_code; + +/** + * @brief Get the last error code. + * The error code is thread local. + * Currently users only need to check the error code when using + * getting-value APIs whose return has no predefined invalid value. +*/ +GRIN_ERROR_CODE grin_get_last_error_code(); + +#endif // GRIN_INCLUDE_COMMON_ERROR_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/common/message.h b/flex/engines/graph_db/grin/include/include/common/message.h new file mode 100644 index 000000000000..099c49ae5a89 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/common/message.h @@ -0,0 +1,37 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file message.h + @brief Define storage feature protobuf message +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_COMMON_MESSAGE_H_ +#define GRIN_INCLUDE_COMMON_MESSAGE_H_ + +/** + * @brief Get the static feature prototype message of the storage. + * This proto describes the features of the storage, such as whether + * it supports property graph or partitioned graph. + * @return The serialized proto message. +*/ +const char* grin_get_static_storage_feature_msg(); + +#endif // GRIN_INCLUDE_PROTO_MESSAGE_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/internal_id.h b/flex/engines/graph_db/grin/include/include/index/internal_id.h new file mode 100644 index 000000000000..9622436bec87 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/index/internal_id.h @@ -0,0 +1,98 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file internal_id.h + @brief Define the internal ID related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_INDEX_INTERNAL_ID_H_ +#define GRIN_INCLUDE_INDEX_INTERNAL_ID_H_ + + +#if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && !defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the int64 internal id of a vertex + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The int64 internal id of the vertex +*/ +long long int grin_get_vertex_internal_id(GRIN_GRAPH, GRIN_VERTEX); + +/** + * @brief Get the vertex by internal id. + * Different from pk_of_int64, the internal id is unique over all vertex types. + * @param GRIN_GRAPH The graph + * @param id The internal id of the vertex + * @return The vertex +*/ +GRIN_VERTEX grin_get_vertex_by_internal_id(GRIN_GRAPH, long long int id); + +/** + * @brief Get the upper bound of internal id. + * @param GRIN_GRAPH The graph + * @return The upper bound +*/ +long long int grin_get_vertex_internal_id_upper_bound(GRIN_GRAPH); + +/** + * @brief Get the lower bound of internal id. + * @param GRIN_GRAPH The graph + * @return The lower bound +*/ +long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH); +#endif + +#if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the int64 internal id of a vertex + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The int64 internal id of the vertex +*/ +long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX); + +/** + * @brief Get the vertex by internal id under type + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @param id The internal id of the vertex under type + * @return The vertex +*/ +GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, long long int id); + +/** + * @brief Get the upper bound of internal id under type. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @return The upper bound of internal id under type +*/ +long long int grin_get_vertex_internal_id_upper_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +/** + * @brief Get the lower bound internal id under type. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @return The lower bound internal id under type +*/ +long long int grin_get_vertex_internal_id_lower_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); +#endif + +#endif // GRIN_INCLUDE_INDEX_INTERNAL_ID_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/label.h b/flex/engines/graph_db/grin/include/include/index/label.h new file mode 100644 index 000000000000..d592460f6c10 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/index/label.h @@ -0,0 +1,108 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file label.h + @brief Define the label related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_INDEX_LABEL_H_ +#define GRIN_INCLUDE_INDEX_LABEL_H_ + + +#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) +GRIN_LABEL grin_get_label_by_name(GRIN_GRAPH, const char*); + +void grin_destroy_label(GRIN_GRAPH, GRIN_LABEL); + +const char* grin_get_label_name(GRIN_GRAPH, GRIN_LABEL); + +void grin_destroy_label_list(GRIN_GRAPH, GRIN_LABEL_LIST); + +size_t grin_get_label_list_size(GRIN_GRAPH, GRIN_LABEL_LIST); + +GRIN_LABEL grin_get_label_from_list(GRIN_GRAPH, GRIN_LABEL_LIST, size_t); +#endif + +#ifdef GRIN_WITH_VERTEX_LABEL +/** + * @brief assign a label to a vertex + * @param GRIN_GRAPH the graph + * @param GRIN_LABEL the label + * @param GRIN_VERTEX the vertex + * @return whether succeed +*/ +bool grin_assign_label_to_vertex(GRIN_GRAPH, GRIN_LABEL, GRIN_VERTEX); + +/** + * @brief get the label list of a vertex + * @param GRIN_GRAPH the graph + * @param GRIN_VERTEX the vertex +*/ +GRIN_LABEL_LIST grin_get_vertex_label_list(GRIN_GRAPH, GRIN_VERTEX); + +/** + * @brief get the vertex list by label + * @param GRIN_GRAPH the graph + * @param GRIN_LABEL the label +*/ +GRIN_VERTEX_LIST grin_get_vertex_list_by_label(GRIN_GRAPH, GRIN_LABEL); + +/** + * @brief filtering an existing vertex list by label + * @param GRIN_VERTEX_LIST the existing vertex list + * @param GRIN_LABEL the label +*/ +GRIN_VERTEX_LIST grin_select_label_for_vertex_list(GRIN_GRAPH, GRIN_LABEL, GRIN_VERTEX_LIST); +#endif + +#ifdef GRIN_WITH_EDGE_LABEL +/** + * @brief assign a label to a edge + * @param GRIN_GRAPH the graph + * @param GRIN_LABEL the label + * @param GRIN_EDGE the edge + * @return whether succeed +*/ +bool grin_assign_label_to_edge(GRIN_GRAPH, GRIN_LABEL, GRIN_EDGE); + +/** + * @brief get the label list of a edge + * @param GRIN_GRAPH the graph + * @param GRIN_EDGE the edge +*/ +GRIN_LABEL_LIST grin_get_edge_label_list(GRIN_GRAPH, GRIN_EDGE); + +/** + * @brief get the edge list by label + * @param GRIN_GRAPH the graph + * @param GRIN_LABEL the label +*/ +GRIN_EDGE_LIST grin_get_edge_list_by_label(GRIN_GRAPH, GRIN_LABEL); + +/** + * @brief filtering an existing edge list by label + * @param GRIN_EDGE_LIST the existing edge list + * @param GRIN_LABEL the label +*/ +GRIN_EDGE_LIST grin_select_label_for_edge_list(GRIN_GRAPH, GRIN_LABEL, GRIN_EDGE_LIST); +#endif + +#endif // GRIN_INCLUDE_INDEX_LABEL_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/order.h b/flex/engines/graph_db/grin/include/include/index/order.h new file mode 100644 index 000000000000..8321d413a242 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/index/order.h @@ -0,0 +1,46 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file order.h + @brief Define the vertex ordering predicate APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_INDEX_ORDER_H_ +#define GRIN_INCLUDE_INDEX_ORDER_H_ + + +#ifdef GRIN_ASSUME_ALL_VERTEX_LIST_SORTED +bool grin_smaller_vertex(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX); +#endif + +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) +/** + * @brief Get the position of a vertex in a sorted list + * caller must guarantee the input vertex list is sorted to get the correct result + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_LIST The sorted vertex list + * @param GRIN_VERTEX The vertex to find + * @return The position of the vertex +*/ +size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH, GRIN_VERTEX_LIST, GRIN_VERTEX); +#endif + +#endif // GRIN_INCLUDE_INDEX_ORDER_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/pk.h b/flex/engines/graph_db/grin/include/include/index/pk.h new file mode 100644 index 000000000000..0b71065c79da --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/index/pk.h @@ -0,0 +1,46 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file pk.h + @brief Define the primary key indexing related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_INDEX_PK_H_ +#define GRIN_INCLUDE_INDEX_PK_H_ + +#if defined(GRIN_ENABLE_VERTEX_PK_INDEX) && defined(GRIN_ENABLE_VERTEX_PRIMARY_KEYS) +/** + * @brief Get the vertex by primary keys row. + * The values in the row must be in the same order as the primary keys + * properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @param GRIN_ROW The values row of primary keys properties. + * @return The vertex. +*/ +GRIN_VERTEX grin_get_vertex_by_primary_keys_row(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_ROW); +#endif + +#if defined(GRIN_ENABLE_EDGE_PK_INDEX) && defined(GRIN_ENABLE_EDGE_PRIMARY_KEYS) +GRIN_EDGE grin_get_edge_by_primary_keys_row(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_ROW); +#endif + +#endif // GRIN_INCLUDE_INDEX_PK_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/partition/partition.h b/flex/engines/graph_db/grin/include/include/partition/partition.h new file mode 100644 index 000000000000..df4c2e392215 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/partition/partition.h @@ -0,0 +1,89 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file partition.h + @brief Define the partition related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PARTITION_PARTITION_H_ +#define GRIN_INCLUDE_PARTITION_PARTITION_H_ + + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +/** + * @brief Get a partitioned graph from a storage. + * @param uri The URI of the graph. + * Current URI for supported storage includes: + * 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version} + * 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy} + * 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional. + * @return A partitioned graph handle. +*/ +GRIN_PARTITIONED_GRAPH grin_get_partitioned_graph_from_storage(const char* uri); + +void grin_destroy_partitioned_graph(GRIN_PARTITIONED_GRAPH); + +size_t grin_get_total_partitions_number(GRIN_PARTITIONED_GRAPH); + +/** + * @brief Get the local partition list of the partitioned graph. + * For example, a graph may be partitioned into 6 partitions and located in + * 2 machines, then each machine may contain a local partition list of size 3. + * @param GRIN_PARTITIONED_GRAPH The partitioned graph. + * @return A partition list of local partitions. +*/ +GRIN_PARTITION_LIST grin_get_local_partition_list(GRIN_PARTITIONED_GRAPH); + +void grin_destroy_partition_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST); + +GRIN_PARTITION_LIST grin_create_partition_list(GRIN_PARTITIONED_GRAPH); + +bool grin_insert_partition_to_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST, GRIN_PARTITION); + +size_t grin_get_partition_list_size(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST); + +GRIN_PARTITION grin_get_partition_from_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST, size_t); + +bool grin_equal_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION, GRIN_PARTITION); + +void grin_destroy_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); + +const void* grin_get_partition_info(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); + +/** + * @brief Get a local graph of the partitioned graph. + * @param GRIN_PARTITIONED_GRAPH The partitioned graph. + * @param GRIN_PARTITION The partition of the graph. + * @return A local graph. +*/ +GRIN_GRAPH grin_get_local_graph_by_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +GRIN_PARTITION grin_get_partition_by_id(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_ID); + +GRIN_PARTITION_ID grin_get_partition_id(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); +#endif + +#endif // GRIN_INCLUDE_PARTITION_PARTITION_H_ + +#ifdef __cplusplus +} +#endif diff --git a/flex/engines/graph_db/grin/include/include/partition/reference.h b/flex/engines/graph_db/grin/include/include/partition/reference.h new file mode 100644 index 000000000000..828c693b11d2 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/partition/reference.h @@ -0,0 +1,159 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file reference.h + @brief Define the reference related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PARTITION_REFERENCE_H_ +#define GRIN_INCLUDE_PARTITION_REFERENCE_H_ + +#ifdef GRIN_ENABLE_VERTEX_REF +/** + * @brief Get the vertex ref of a vertex. + * A vertex ref is a reference for a "local" vertex, and the reference can + * be recognized by other partitions. + * To transfer the vertex ref handle between partitions, users should + * first call serialization methods to serialize the vertex ref handle + * into string or int64 based on the storage's features; + * then send the messages to remote partitions and deserialize the string or + * int64 remotely to get the vertex ref handle on the remote partition; + * finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle + * on the remote partition. + * These two vertices should represent the same vertex in the partitioned graph. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The vertex ref +*/ +GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH, GRIN_VERTEX); + +void grin_destroy_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + +/** + * @brief get the local vertex handle from the vertex ref handle + * if the vertex ref handle is not recognized, a null vertex is returned + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_REF The vertex ref + * @return The vertex handle + */ +GRIN_VERTEX grin_get_vertex_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + +/** + * @brief get the master partition of a vertex ref. + * Some storage can still provide the master partition of the vertex ref, + * even if the vertex ref can NOT be recognized locally. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_REF The vertex ref + */ +GRIN_PARTITION grin_get_master_partition_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + +/** + * @brief serialize the vertex ref handle to string + * The returned string should be freed by ``grin_destroy_serialized_vertex_ref`` + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_REF The vertex ref +*/ +const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); + +void grin_destroy_serialized_vertex_ref(GRIN_GRAPH, const char*); + +/** + * @brief deserialize the string to vertex ref handle + * If the string is invalid, a null vertex ref is returned + * @param GRIN_GRAPH The graph + * @param msg The string message to be deserialized +*/ +GRIN_VERTEX_REF grin_deserialize_to_vertex_ref(GRIN_GRAPH, const char* msg); + +/** + * @brief check if the vertex is a master vertex + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex +*/ +bool grin_is_master_vertex(GRIN_GRAPH, GRIN_VERTEX); + +/** + * @brief check if the vertex is a mirror vertex + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex +*/ +bool grin_is_mirror_vertex(GRIN_GRAPH, GRIN_VERTEX); +#endif + +#ifdef GRIN_TRAIT_FAST_VERTEX_REF +/** + * @brief serialize the vertex ref handle to int64 + * This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref + * can be serialized into int64 instead of string. + * Obviously transferring and serializing int64 is faster than string. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_REF The vertex ref +*/ +long long int grin_serialize_vertex_ref_as_int64(GRIN_GRAPH, GRIN_VERTEX_REF); + +/** + * @brief deserialize the int64 to vertex ref handle + * @param GRIN_GRAPH The graph + * @param msg The int64 message to be deserialized +*/ +GRIN_VERTEX_REF grin_deserialize_int64_to_vertex_ref(GRIN_GRAPH, long long int msg); +#endif + +#ifdef GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST +GRIN_PARTITION_LIST grin_get_master_vertex_mirror_partition_list(GRIN_GRAPH, GRIN_VERTEX); +#endif + +#ifdef GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST +GRIN_PARTITION_LIST grin_get_mirror_vertex_mirror_partition_list(GRIN_GRAPH, GRIN_VERTEX); +#endif + +#ifdef GRIN_ENABLE_EDGE_REF +GRIN_EDGE_REF grin_get_edge_ref_by_edge(GRIN_GRAPH, GRIN_EDGE); + +void grin_destroy_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); + +GRIN_EDGE grin_get_edge_from_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); + +GRIN_PARTITION grin_get_master_partition_from_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); + +const char* grin_serialize_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); + +void grin_destroy_serialized_edge_ref(GRIN_GRAPH, const char*); + +GRIN_EDGE_REF grin_deserialize_to_edge_ref(GRIN_GRAPH, const char*); + +bool grin_is_master_edge(GRIN_GRAPH, GRIN_EDGE); + +bool grin_is_mirror_edge(GRIN_GRAPH, GRIN_EDGE); +#endif + +#ifdef GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST +GRIN_PARTITION_LIST grin_get_master_edge_mirror_partition_list(GRIN_GRAPH, GRIN_EDGE); +#endif + +#ifdef GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST +GRIN_PARTITION_LIST grin_get_mirror_edge_mirror_partition_list(GRIN_GRAPH, GRIN_EDGE); +#endif + +#endif // GRIN_INCLUDE_PARTITION_REFERENCE_H_ + +#ifdef __cplusplus +} +#endif diff --git a/flex/engines/graph_db/grin/include/include/partition/topology.h b/flex/engines/graph_db/grin/include/include/partition/topology.h new file mode 100644 index 000000000000..829188d1347c --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/partition/topology.h @@ -0,0 +1,126 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file partition/topology.h + @brief Define the topoloy related APIs under partitioned graph +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PARTITION_TOPOLOGY_H_ +#define GRIN_INCLUDE_PARTITION_TOPOLOGY_H_ + + +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the vertex list of the graph with master vertices only. + * This API is only available for simple graph. + * @param GRIN_GRAPH The graph. + * @return The vertex list of master vertices only. +*/ +GRIN_VERTEX_LIST grin_get_vertex_list_select_master(GRIN_GRAPH); + +/** + * @brief Get the vertex list of the graph with mirror vertices only. + * This API is only available for simple graph. + * @param GRIN_GRAPH The graph. + * @return The vertex list of mirror vertices only. +*/ +GRIN_VERTEX_LIST grin_get_vertex_list_select_mirror(GRIN_GRAPH); +#endif + +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the vertex list of a given type with master vertices only. + * This API is only available for property graph. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @return The vertex list of master vertices only. +*/ +GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_master(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +/** + * @brief Get the vertex list of a given type with mirror vertices only. + * This API is only available for property graph. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @return The vertex list of mirror vertices only. +*/ +GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_mirror(GRIN_GRAPH, GRIN_VERTEX_TYPE); +#endif + + +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_VERTEX_LIST grin_get_vertex_list_select_partition(GRIN_GRAPH, GRIN_PARTITION); +#endif + +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_partition(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_PARTITION); +#endif + + + +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list_select_master(GRIN_GRAPH); + +GRIN_EDGE_LIST grin_get_edge_list_select_mirror(GRIN_GRAPH); +#endif + +#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list_by_type_select_master(GRIN_GRAPH, GRIN_EDGE_TYPE); + +GRIN_EDGE_LIST grin_get_edge_list_by_type_select_mirror(GRIN_GRAPH, GRIN_EDGE_TYPE); +#endif + + +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list_select_partition(GRIN_GRAPH, GRIN_PARTITION); +#endif + +#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list_by_type_select_partition(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_PARTITION); +#endif + + +#if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_ADJACENT_LIST grin_get_adjacent_list_select_master_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); + +GRIN_ADJACENT_LIST grin_get_adjacent_list_select_mirror_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); +#endif + +#if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_master_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE); + +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_mirror_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE); +#endif + + +#if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_ADJACENT_LIST grin_get_adjacent_list_select_partition_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_PARTITION); +#endif + +#if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_partition_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE, GRIN_PARTITION); +#endif + + +#endif // GRIN_INCLUDE_PARTITION_TOPOLOGY_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/partition.h b/flex/engines/graph_db/grin/include/include/property/partition.h new file mode 100644 index 000000000000..4c7afb5b166b --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/partition.h @@ -0,0 +1,80 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file property/partition.h + @brief Define the partition related APIs under property graph + This file will be deprecated in the future. + Partition schema related APIs will be moved to partition/property.h +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_PARTITION_H_ +#define GRIN_INCLUDE_PROPERTY_PARTITION_H_ + + +#if defined(GRIN_ENABLE_GRAPH_PARTITION) && \ + !defined(GRIN_ASSUME_ALL_REPLICATE_PARTITION) && \ + !defined(GRIN_ASSUME_EDGE_CUT_PARTITION) && \ + !defined(GRIN_ASSUME_VERTEX_CUT_PARTITION) +// vertex partition +GRIN_VERTEX_TYPE_LIST grin_get_all_replicated_partition_vertex_types(GRIN_GRAPH); +GRIN_VERTEX_TYPE_LIST grin_get_disjoint_partition_vertex_types(GRIN_GRAPH); +GRIN_VERTEX_TYPE_LIST grin_get_follow_edge_partition_vertex_types(GRIN_GRAPH); + +// edge partition +GRIN_VEV_TYPE_LIST grin_get_all_replicated_partition_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_disjoint_partition_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_follow_src_partition_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_follow_dst_partition_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_follow_both_partition_vev_types(GRIN_GRAPH); +#endif + + +// vertex property partition +#if defined(GRIN_ENABLE_GRAPH_PARTITION) && \ + defined(GRIN_WITH_VERTEX_PROPERTY) && \ + !defined(GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY) && \ + !defined(GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY) && \ + !defined(GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY) +GRIN_VERTEX_TYPE_LIST grin_get_master_only_partition_vertex_types(GRIN_GRAPH); +GRIN_VERTEX_TYPE_LIST grin_get_replicate_master_mirror_partition_vertex_types(GRIN_GRAPH); +GRIN_VERTEX_TYPE_LIST grin_get_split_master_mirror_partition_vertex_types(GRIN_GRAPH); +#endif + +// edge property partition +#if defined(GRIN_ENABLE_GRAPH_PARTITION) && \ + defined(GRIN_WITH_EDGE_PROPERTY) && \ + !defined(GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY) && \ + !defined(GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY) && \ + !defined(GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY) +GRIN_VEV_TYPE_LIST grin_get_master_only_partition_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_replicate_master_mirror_partition_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_split_master_mirror_partition_vev_types(GRIN_GRAPH); +#endif + +// vev relation +#ifdef GRIN_TRAIT_SPECIFIC_VEV_RELATION +GRIN_VEV_TYPE_LIST grin_get_one_to_one_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_one_to_many_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_many_to_one_vev_types(GRIN_GRAPH); +GRIN_VEV_TYPE_LIST grin_get_many_to_many_vev_types(GRIN_GRAPH); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_PARTITION_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/primarykey.h b/flex/engines/graph_db/grin/include/include/property/primarykey.h new file mode 100644 index 000000000000..8585d1f32e0b --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/primarykey.h @@ -0,0 +1,67 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file primarykey.h + @brief Define the primary key related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_ +#define GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_ + + +#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS +/** + * @brief Get the vertex types that have primary keys + * In some graph, not every vertex type has primary keys. + * @param GRIN_GRAPH The graph + * @return The vertex type list of types that have primary keys +*/ +GRIN_VERTEX_TYPE_LIST grin_get_vertex_types_with_primary_keys(GRIN_GRAPH); + +/** + * @brief Get the primary keys properties of a vertex type + * The primary keys properties are the properties that can be used to identify a vertex. + * They are a subset of the properties of a vertex type. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type + * @return The primary keys properties list +*/ +GRIN_VERTEX_PROPERTY_LIST grin_get_primary_keys_by_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +/** + * @brief Get the primary keys values row of a vertex + * The values in the row are in the same order as the primary keys properties. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @return The primary keys values row +*/ +GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH, GRIN_VERTEX); +#endif + +#ifdef GRIN_ENABLE_EDGE_PRIMARY_KEYS +GRIN_EDGE_TYPE_LIST grin_get_edge_types_with_primary_keys(GRIN_GRAPH); + +GRIN_EDGE_PROPERTY_LIST grin_get_primary_keys_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); + +GRIN_ROW grin_get_edge_primary_keys_row(GRIN_GRAPH, GRIN_EDGE); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/property.h b/flex/engines/graph_db/grin/include/include/property/property.h new file mode 100644 index 000000000000..924541f7f574 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/property.h @@ -0,0 +1,269 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file property.h + @brief Define the property related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_PROPERTY_H_ +#define GRIN_INCLUDE_PROPERTY_PROPERTY_H_ + + +void grin_destroy_string_value(GRIN_GRAPH, const char*); + +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME +/** + * @brief Get the vertex property name + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The vertex type that the property belongs to + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The property's name as string + */ +const char* grin_get_vertex_property_name(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the vertex property with a given name under a specific vertex type + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_TYPE The specific vertex type + * @param name The name + * @return The vertex property + */ +GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH, GRIN_VERTEX_TYPE, const char* name); + +/** + * @brief Get properties under all types with a given name. + * For example, vertex type "person" and "company" both have a property + * called "name". When this API is called given "name", it will return a list + * of "name" properties under both types. + * @param GRIN_GRAPH The graph + * @param name The name + * @return The vertex property list of properties with the given name + */ +GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH, const char* name); +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME +const char* grin_get_edge_property_name(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY); + +GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH, GRIN_EDGE_TYPE, const char* name); + +GRIN_EDGE_PROPERTY_LIST grin_get_edge_properties_by_name(GRIN_GRAPH, const char* name); +#endif + + +#ifdef GRIN_WITH_VERTEX_PROPERTY +bool grin_equal_vertex_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY, GRIN_VERTEX_PROPERTY); + +void grin_destroy_vertex_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the datatype of the vertex property + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The datatype of the vertex property +*/ +GRIN_DATATYPE grin_get_vertex_property_datatype(GRIN_GRAPH, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of int32, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype int32. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +int grin_get_vertex_property_value_of_int32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of uint32, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype uint32. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +unsigned int grin_get_vertex_property_value_of_uint32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of int64, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype int64. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of uint64, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype uint64. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +unsigned long long int grin_get_vertex_property_value_of_uint64(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of float, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype float. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +float grin_get_vertex_property_value_of_float(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of double, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype double. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +double grin_get_vertex_property_value_of_double(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of string, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype string. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * Note that the returned string should be explicitly freed by the user, + * by calling API ``grin_destroy_string_value``. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of int32, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype date32. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +int grin_get_vertex_property_value_of_date32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of int32, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype time32. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * Note that the returned string should be explicitly freed by the user, + * by calling API ``grin_destroy_string_value``. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +int grin_get_vertex_property_value_of_time32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the value of int64, given a vertex and a vertex property. + * The user should make sure the vertex property is of datatype timestamp64. + * The return int has no predefined invalid value. + * User should use ``grin_get_last_error_code()`` to check if the API call + * is successful. + * Note that the returned string should be explicitly freed by the user, + * by calling API ``grin_destroy_string_value``. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The value of the property +*/ +long long int grin_get_vertex_property_value_of_timestamp64(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); + +/** + * @brief Get the vertex type that a given vertex property belongs to. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX_PROPERTY The vertex property + * @return The vertex type +*/ +GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY); +#endif + +#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) +const void* grin_get_vertex_property_value(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); +#endif + + +#ifdef GRIN_WITH_EDGE_PROPERTY +bool grin_equal_edge_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY, GRIN_EDGE_PROPERTY); + +void grin_destroy_edge_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY); + +GRIN_DATATYPE grin_get_edge_property_datatype(GRIN_GRAPH, GRIN_EDGE_PROPERTY); + +int grin_get_edge_property_value_of_int32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +unsigned int grin_get_edge_property_value_of_uint32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +long long int grin_get_edge_property_value_of_int64(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +unsigned long long int grin_get_edge_property_value_of_uint64(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +float grin_get_edge_property_value_of_float(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +double grin_get_edge_property_value_of_double(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +const char* grin_get_edge_property_value_of_string(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +int grin_get_edge_property_value_of_date32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +int grin_get_edge_property_value_of_time32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +long long int grin_get_edge_property_value_of_timestamp64(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); + +GRIN_EDGE_TYPE grin_get_edge_type_from_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY); +#endif + +#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) +const void* grin_get_edge_property_value(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_PROPERTY_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/propertylist.h b/flex/engines/graph_db/grin/include/include/property/propertylist.h new file mode 100644 index 000000000000..07e65c27eb43 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/propertylist.h @@ -0,0 +1,98 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file propertylist.h + @brief Define the property list related and graph projection APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_ +#define GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_ + + +#ifdef GRIN_WITH_VERTEX_PROPERTY +/** + * @brief Get the vertex property list of the graph. + * This API is only available for property graph. + * @param GRIN_GRAPH The graph. + * @return The vertex property list. +*/ +GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +size_t grin_get_vertex_property_list_size(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST); + +GRIN_VERTEX_PROPERTY grin_get_vertex_property_from_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST, size_t); + +GRIN_VERTEX_PROPERTY_LIST grin_create_vertex_property_list(GRIN_GRAPH); + +void grin_destroy_vertex_property_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST); + +bool grin_insert_vertex_property_to_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST, GRIN_VERTEX_PROPERTY); +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +/** + * @brief Get the vertex property handle by id. + * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``, + * meaning that the storage has naturally increasing ids for vertex properties + * under a certain vertex type. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @param GRIN_VERTEX_PROPERTY_ID The vertex property id. + * @return The vertex property handle. +*/ +GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY_ID); + +/** + * @brief Get the vertex property's natural id. + * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``, + * meaning that the storage has naturally increasing ids for vertex properties + * under a certain vertex type. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @param GRIN_VERTEX_PROPERTY The vertex property handle. + * @return The vertex property id. +*/ +GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY); +#endif + + +#ifdef GRIN_WITH_EDGE_PROPERTY +GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); + +size_t grin_get_edge_property_list_size(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST); + +GRIN_EDGE_PROPERTY grin_get_edge_property_from_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST, size_t); + +GRIN_EDGE_PROPERTY_LIST grin_create_edge_property_list(GRIN_GRAPH); + +void grin_destroy_edge_property_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST); + +bool grin_insert_edge_property_to_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST, GRIN_EDGE_PROPERTY); +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +GRIN_EDGE_PROPERTY grin_get_edge_property_by_id(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY_ID); + +/// We must specify the edge type here, because the edge property id is unique only under a specific edge type +GRIN_EDGE_PROPERTY_ID grin_get_edge_property_id(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/row.h b/flex/engines/graph_db/grin/include/include/property/row.h new file mode 100644 index 000000000000..7533daac105a --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/row.h @@ -0,0 +1,115 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file row.h + @brief Define the row related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_ROW_H_ +#define GRIN_INCLUDE_PROPERTY_ROW_H_ + + +#ifdef GRIN_ENABLE_ROW +void grin_destroy_row(GRIN_GRAPH, GRIN_ROW); + +int grin_get_int32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +unsigned int grin_get_uint32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +long long int grin_get_int64_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +unsigned long long int grin_get_uint64_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +float grin_get_float_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +double grin_get_double_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +const char* grin_get_string_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +int grin_get_date32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +int grin_get_time32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +long long int grin_get_timestamp64_from_row(GRIN_GRAPH, GRIN_ROW, size_t); + +/** + * @brief Create a row. + * Row works as carrier of property values in GRIN. + * It is a pure value array, and users can only get the value by the array index. + * That means users should understand the property that each value is + * representing when using the row. + * Currently rows are used in two scenarios: + * 1. Users can create a row of values for primary keys properties, + * and then query the vertex/edge using the row if pk indexing is enabled. + * 2. Users can get the row of values for the entire property list of + * a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``. + * However this API is not recommended if the user only wants to get the + * properties values, in which case, the user can get property values + * one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``. +*/ +GRIN_ROW grin_create_row(GRIN_GRAPH); + +bool grin_insert_int32_to_row(GRIN_GRAPH, GRIN_ROW, int); + +bool grin_insert_uint32_to_row(GRIN_GRAPH, GRIN_ROW, unsigned int); + +bool grin_insert_int64_to_row(GRIN_GRAPH, GRIN_ROW, long long int); + +bool grin_insert_uint64_to_row(GRIN_GRAPH, GRIN_ROW, unsigned long long int); + +bool grin_insert_float_to_row(GRIN_GRAPH, GRIN_ROW, float); + +bool grin_insert_double_to_row(GRIN_GRAPH, GRIN_ROW, double); + +bool grin_insert_string_to_row(GRIN_GRAPH, GRIN_ROW, const char*); + +bool grin_insert_date32_to_row(GRIN_GRAPH, GRIN_ROW, int); + +bool grin_insert_time32_to_row(GRIN_GRAPH, GRIN_ROW, int); + +bool grin_insert_timestamp64_to_row(GRIN_GRAPH, GRIN_ROW, long long int); +#endif + +#if defined(GRIN_ENABLE_ROW) && defined(GRIN_TRAIT_CONST_VALUE_PTR) +const void* grin_get_value_from_row(GRIN_GRAPH, GRIN_ROW, GRIN_DATATYPE, size_t); +#endif + + +#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_ENABLE_ROW) +/** + * @brief Get row of values for the entire property list of a vertex. + * Later users can get property values from the row using APIs like + * ``grin_get_int32_from_row``. + * However this two-step value getting is not recommended if the user + * only wants to get the value of one property, in which case, the user + * should use APIs like ``grin_get_vertex_property_value_of_int32``. + * @param GRIN_GRAPH The graph + * @param GRIN_VERTEX The vertex + */ +GRIN_ROW grin_get_vertex_row(GRIN_GRAPH, GRIN_VERTEX); +#endif + + +#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_ENABLE_ROW) +GRIN_ROW grin_get_edge_row(GRIN_GRAPH, GRIN_EDGE); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_ROW_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/topology.h b/flex/engines/graph_db/grin/include/include/property/topology.h new file mode 100644 index 000000000000..29181d2b8ef9 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/topology.h @@ -0,0 +1,74 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file property/topology.h + @brief Define the topology related APIs under property graph +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_ +#define GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_ + + +#ifdef GRIN_WITH_VERTEX_PROPERTY +/** + * @brief Get the vertex number of a given type in the graph. + * This API is only available for property graph. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @return The vertex number. +*/ +size_t grin_get_vertex_num_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +size_t grin_get_edge_num_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); +#endif + +#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the vertex list of a given type. + * This API is only available for property graph. + * To get a vertex list chain of all types, using APIs in GRIN extension. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @return The vertex list of the given type. +*/ +GRIN_VERTEX_LIST grin_get_vertex_list_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); +#endif + +#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); +#endif + +#if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) +/** + * @brief Get the adjacent list of given direction, vertex and edge type. + * This API is only available for property graph. + * To get a adjacent list chain of all types, using APIs in GRIN extension. + * @param GRIN_GRAPH The graph. + * @param GRIN_DIRECTION The direction of the adjacent list. + * @param GRIN_VERTEX The vertex. + * @return The adjacent list. +*/ +GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/type.h b/flex/engines/graph_db/grin/include/include/property/type.h new file mode 100644 index 000000000000..674521b566f4 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/property/type.h @@ -0,0 +1,176 @@ +/** Copyright 2020 Alibaba Group Holding Limited. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + @file type.h + @brief Define the vertex/edge type related APIs +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_PROPERTY_TYPE_H_ +#define GRIN_INCLUDE_PROPERTY_TYPE_H_ + + +#ifdef GRIN_WITH_VERTEX_PROPERTY +bool grin_equal_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_TYPE); + +GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH, GRIN_VERTEX); + +void grin_destroy_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +/** + * @brief Get the vertex type list of the graph + * This API is only available for property graph. + * It lists all the vertex types in the graph. + * @param GRIN_GRAPH The graph. + * @return The vertex type list. +*/ +GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list(GRIN_GRAPH); + +void grin_destroy_vertex_type_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST); + +GRIN_VERTEX_TYPE_LIST grin_create_vertex_type_list(GRIN_GRAPH); + +bool grin_insert_vertex_type_to_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST, GRIN_VERTEX_TYPE); + +size_t grin_get_vertex_type_list_size(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST); + +GRIN_VERTEX_TYPE grin_get_vertex_type_from_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST, size_t); +#endif + +#ifdef GRIN_WITH_VERTEX_TYPE_NAME +/** + * @brief Get the vertex type name. + * This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``, + * meaning that the graph has a unique name for each vertex type. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @return The vertex type name of string. +*/ +const char* grin_get_vertex_type_name(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +/** + * @brief Get the vertex type by name. + * This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``, + * meaning that the graph has a unique name for each vertex type. + * @param GRIN_GRAPH The graph. + * @param name The vertex type name. + * @return The vertex type. +*/ +GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH, const char* name); +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +/** + * @brief Get the vertex type id. + * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``, + * meaning that the graph has naturally increasing ids for vertex types. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The vertex type. + * @return The vertex type id. +*/ +GRIN_VERTEX_TYPE_ID grin_get_vertex_type_id(GRIN_GRAPH, GRIN_VERTEX_TYPE); + +/** + * @brief Get the vertex type by id. + * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``, + * meaning that the graph has naturally increasing ids for vertex types. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE_ID The vertex type id. + * @return The vertex type. +*/ +GRIN_VERTEX_TYPE grin_get_vertex_type_by_id(GRIN_GRAPH, GRIN_VERTEX_TYPE_ID); +#endif + + +#ifdef GRIN_WITH_EDGE_PROPERTY +bool grin_equal_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_TYPE); + +GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH, GRIN_EDGE); + +void grin_destroy_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); + +GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH); + +void grin_destroy_edge_type_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST); + +GRIN_EDGE_TYPE_LIST grin_create_edge_type_list(GRIN_GRAPH); + +bool grin_insert_edge_type_to_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST, GRIN_EDGE_TYPE); + +size_t grin_get_edge_type_list_size(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST); + +GRIN_EDGE_TYPE grin_get_edge_type_from_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST, size_t); +#endif + +#ifdef GRIN_WITH_EDGE_TYPE_NAME +const char* grin_get_edge_type_name(GRIN_GRAPH, GRIN_EDGE_TYPE); + +GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH, const char*); +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +GRIN_EDGE_TYPE_ID grin_get_edge_type_id(GRIN_GRAPH, GRIN_EDGE_TYPE); + +GRIN_EDGE_TYPE grin_get_edge_type_by_id(GRIN_GRAPH, GRIN_EDGE_TYPE_ID); +#endif + + +#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_WITH_EDGE_PROPERTY) +/** + * @brief Get source vertex types related to an edge type. + * GRIN assumes the relation between edge type and pairs of vertex types is + * many-to-many. + * To return the related pairs of vertex types, GRIN provides two APIs to get + * the src and dst vertex types respectively. + * The returned vertex type lists are of the same size, + * and the src/dst vertex types are aligned with their positions in the lists. + * @param GRIN_GRAPH The graph. + * @param GRIN_EDGE_TYPE The edge type. + * @return The vertex type list of source. + */ +GRIN_VERTEX_TYPE_LIST grin_get_src_types_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); + +/** + * @brief Get destination vertex types related to an edge type. + * GRIN assumes the relation between edge type and pairs of vertex types is + * many-to-many. + * To return the related pairs of vertex types, GRIN provides two APIs to get + * the src and dst vertex types respectively. + * The returned vertex type lists are of the same size, + * and the src/dst vertex types are aligned with their positions in the lists. + * @param GRIN_GRAPH The graph. + * @param GRIN_EDGE_TYPE The edge type. + * @return The vertex type list of destination. +*/ +GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); + +/** + * @brief Get edge types related to a pair of vertex types. + * GRIN assumes the relation between edge type and pairs of vertex types is + * many-to-many. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_TYPE The source vertex type. + * @param GRIN_VERTEX_TYPE The destination vertex type. + * @return The related edge type list. +*/ +GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_TYPE); +#endif + +#endif // GRIN_INCLUDE_PROPERTY_TYPE_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/topology/adjacentlist.h b/flex/engines/graph_db/grin/include/include/topology/adjacentlist.h new file mode 100644 index 000000000000..6e2a3e8426e3 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/topology/adjacentlist.h @@ -0,0 +1,117 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_ +#define GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_ + + +#if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) +/** + * @brief Get the adjacent list of a vertex. + * This API is only available when the graph has no edge property. + * Otherwise, use ``grin_get_adjacent_list_by_edge_type`` instead. + * @param GRIN_GRAPH The graph. + * @param GRIN_DIRECTION The direction of the adjacent list. + * @param GRIN_VERTEX The vertex. + * @return The adjacent list. +*/ +GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST +void grin_destroy_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST); +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY +size_t grin_get_adjacent_list_size(GRIN_GRAPH, GRIN_ADJACENT_LIST); + +/** + * @brief Get the neighbor vertex from the adjacent list. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST The adjacent list. + * @param index The index of the edge to/from the neighbor in the adjacent list. + * @return The neighbor vertex. +*/ +GRIN_VERTEX grin_get_neighbor_from_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST, size_t index); + +/** + * @brief Get the edge from the adjacent list. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST The adjacent list. + * @param index The index of the edge in the adjacent list. + * @return The edge. Note that when the direction is OUT, the destination vertex + * of the edge is the neighbor vertex. While the direction is IN, the source + * vertex of the edge is the neighbor vertex. +*/ +GRIN_EDGE grin_get_edge_from_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST, size_t); +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +/** + * @brief Get the begin iterator of the adjacent list. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST The adjacent list. + * @return The begin iterator of the adjacent list. +*/ +GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin(GRIN_GRAPH, GRIN_ADJACENT_LIST); + +void grin_destroy_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); + +/** + * @brief Update the iterator to the next of the adjacent list. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator to be updated. +*/ +void grin_get_next_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); + +/** + * @brief Check if the adjacent list iterator is at the end. + * Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin`` + * if the adjacent list is empty. + * Users should check if the iterator is at the end before using it. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator. + * @return True if the iterator is at the end, otherwise false. +*/ +bool grin_is_adjacent_list_end(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); + +/** + * @brief Get the neighbor vertex from the adjacent list iterator. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator. + * @return The neighbor vertex. +*/ +GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); + +/** + * @brief Get the edge from the adjacent list iterator. + * @param GRIN_GRAPH The graph. + * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator. + * @return The edge. Note that when the direction is OUT, the destination vertex + * of the edge is the neighbor vertex. While the direction is IN, the source + * vertex of the edge is the neighbor vertex. +*/ +GRIN_EDGE grin_get_edge_from_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); +#endif + +#endif // GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_ + +#ifdef __cplusplus +} +#endif diff --git a/flex/engines/graph_db/grin/include/include/topology/edgelist.h b/flex/engines/graph_db/grin/include/include/topology/edgelist.h new file mode 100644 index 000000000000..221693c8b73b --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/topology/edgelist.h @@ -0,0 +1,54 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_ +#define GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_ + + +#if defined(GRIN_ENABLE_EDGE_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) +GRIN_EDGE_LIST grin_get_edge_list(GRIN_GRAPH); +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST +void grin_destroy_edge_list(GRIN_GRAPH, GRIN_EDGE_LIST); +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ARRAY +size_t grin_get_edge_list_size(GRIN_GRAPH, GRIN_EDGE_LIST); + +GRIN_EDGE grin_get_edge_from_list(GRIN_GRAPH, GRIN_EDGE_LIST, size_t); +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR +GRIN_EDGE_LIST_ITERATOR grin_get_edge_list_begin(GRIN_GRAPH, GRIN_EDGE_LIST); + +void grin_destroy_edge_list_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); + +void grin_get_next_edge_list_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); + +bool grin_is_edge_list_end(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); + +GRIN_EDGE grin_get_edge_from_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); +#endif + +#endif // GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/topology/structure.h b/flex/engines/graph_db/grin/include/include/topology/structure.h new file mode 100644 index 000000000000..0604b3628f6c --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/topology/structure.h @@ -0,0 +1,121 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_ +#define GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_ + +/** + * @brief Get a (non-partitioned) graph from storage + * @param uri The URI of the graph. + * Current URI for supported storage includes: + * 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version} + * 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy} + * 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional. + * @return A graph handle. +*/ +GRIN_GRAPH grin_get_graph_from_storage(const char*); + +void grin_destroy_graph(GRIN_GRAPH); + +// Graph +#if defined(GRIN_ASSUME_HAS_DIRECTED_GRAPH) && defined(GRIN_ASSUME_HAS_UNDIRECTED_GRAPH) +/** + * @brief Check if the graph is directed. + * This API is only available when the storage supports both directed and + * undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH`` + * and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined. + * @param GRIN_GRAPH The graph. + * @return True if the graph is directed, otherwise false. +*/ +bool grin_is_directed(GRIN_GRAPH); +#endif + +#ifdef GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +/** + * @brief Check if the graph is a multigraph. + * This API is only available when the storage supports multigraph. + * @param GRIN_GRAPH The graph. + * @return True if the graph is a multigraph, otherwise false. +*/ +bool grin_is_multigraph(GRIN_GRAPH); +#endif + +#ifndef GRIN_WITH_VERTEX_PROPERTY +/** + * @brief Get the number of vertices in the graph. + * This API is only available for simple graph. + * @param GRIN_GRAPH The graph. + * @return The number of vertices in the graph. +*/ +size_t grin_get_vertex_num(GRIN_GRAPH); +#endif + +#ifndef GRIN_WITH_EDGE_PROPERTY +/** + * @brief Get the number of edges in the graph. + * This API is only available for simple graph. + * @param GRIN_GRAPH The graph. + * @return The number of edges in the graph. +*/ +size_t grin_get_edge_num(GRIN_GRAPH); +#endif + + +// Vertex +void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX); + +bool grin_equal_vertex(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX); + +// Data +#ifdef GRIN_WITH_VERTEX_DATA +GRIN_DATATYPE grin_get_vertex_data_datatype(GRIN_GRAPH, GRIN_VERTEX); + +const void* grin_get_vertex_data_value(GRIN_GRAPH, GRIN_VERTEX); +#endif + +// Edge +void grin_destroy_edge(GRIN_GRAPH, GRIN_EDGE); + +/** + * @brief Get the source vertex of an edge. + * @param GRIN_GRAPH The graph. + * @param GRIN_EDGE The edge. + * @return The source vertex of the edge. +*/ +GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE); + +/** + * @brief Get the destination vertex of an edge. + * @param GRIN_GRAPH The graph. + * @param GRIN_EDGE The edge. + * @return The destination vertex of the edge. +*/ +GRIN_VERTEX grin_get_dst_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE); + +#ifdef GRIN_WITH_EDGE_DATA +GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE); + +const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE); +#endif + +#endif // GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/topology/vertexlist.h b/flex/engines/graph_db/grin/include/include/topology/vertexlist.h new file mode 100644 index 000000000000..42922bae1374 --- /dev/null +++ b/flex/engines/graph_db/grin/include/include/topology/vertexlist.h @@ -0,0 +1,94 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_ +#define GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_ + + +#if defined(GRIN_ENABLE_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) +/** + * @brief Get the vertex list of the graph + * This API is only available for simple graph. + * In property graph, use ``grin_get_vertex_list_by_type`` instead. + * @param GRIN_GRAPH The graph. + * @return The vertex list. +*/ +GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH); +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +void grin_destroy_vertex_list(GRIN_GRAPH, GRIN_VERTEX_LIST); +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY +size_t grin_get_vertex_list_size(GRIN_GRAPH, GRIN_VERTEX_LIST); + +/** + * @brief Get the vertex from the vertex list. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_LIST The vertex list. + * @param index The index of the vertex in the vertex list. + * @return The vertex. +*/ +GRIN_VERTEX grin_get_vertex_from_list(GRIN_GRAPH, GRIN_VERTEX_LIST, size_t index); +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +/** + * @brief Get the begin iterator of the vertex list. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_LIST The vertex list. + * @return The begin iterator. +*/ +GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH, GRIN_VERTEX_LIST); + +void grin_destroy_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); + +/** + * @brief Update the iterator to the next of the vertex list. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_LIST_ITERATOR The iterator to be updated. +*/ +void grin_get_next_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); + +/** + * @brief Check whether the iterator reaches the end of the vertex list. + * Note that we may get an end iterator when calling ``grin_get_vertex_list_begin`` + * if the vertex list is empty. + * Users should check if the iterator is at the end before using it. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_LIST_ITERATOR The iterator. + * @return True if the iterator reaches the end of the vertex list. +*/ +bool grin_is_vertex_list_end(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); + +/** + * @brief Get the vertex from the iterator. + * @param GRIN_GRAPH The graph. + * @param GRIN_VERTEX_LIST_ITERATOR The iterator. + * @return The vertex. +*/ +GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); +#endif + +#endif // GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_ + +#ifdef __cplusplus +} +#endif diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto new file mode 100644 index 000000000000..f96b9f0afb77 --- /dev/null +++ b/flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto @@ -0,0 +1,127 @@ +syntax = "proto3"; + +package gie; +option java_package = "com.alibaba.graphscope.proto.schema"; + +enum PrimitiveType { + DT_ANY = 0; + DT_SIGNED_INT32 = 1; + DT_UNSIGNED_INT32 = 2; + DT_SIGNED_INT64 = 3; + DT_UNSIGNED_INT64 = 4; + DT_BOOL = 5; + DT_FLOAT = 6; + DT_DOUBLE = 7; + DT_STRING = 8; // string with unlimited length +} + +message Numeric { // precision=4 scale=2 : 23.12 + uint32 precision = 1; + uint32 scale = 2; +} + +message Char { + uint32 fixed_length = 1; +} + +message VarChar { + uint32 max_length = 1; +} + +// temporal types + +enum DateFormat { + DF_YYYY_MM_DD = 0; // ISO fomat: 2019-01-01 +} + +enum TimeFormat { + TF_HH_MM_SS_SSS = 0; // ISO format: 00:00:00.000 +} + +enum DateTimeFormat { + DTF_YYYY_MM_DD_HH_MM_SS_SSS = 0; // ISO format: 2019-01-01 00:00:00.000 +} + +enum TimeZoneFormat { + TZF_UTC = 0; // Z + TZF_OFFSET = 1; // +08:00 or -08:00 +} + +message Date { + DateFormat date_format = 1; +} + +message Time { + TimeFormat time_format = 1; + TimeZoneFormat time_zone_format = 2; +} + +message DateTime { + DateTimeFormat date_time_format = 1; + TimeZoneFormat time_zone_format = 2; +} + +// element type nested in array or multiset or map +message ComponentType { + oneof item { + PrimitiveType primitive_type = 1; + Numeric numeric = 2; + Char char = 3; + VarChar var_char = 4; + Date date = 5; + Time time = 6; + DateTime date_time = 7; + } +} + +message Array { + ComponentType component_type = 1; + uint32 max_length = 2; +} + +message MultiSet { + ComponentType component_type = 1; +} + +message Map { + // type can be hashing + message KeyType { + enum PrimitiveKeyType { + DT_SIGNED_INT32 = 0; + DT_UNSIGNED_INT32 = 1; + DT_SIGNED_INT64 = 2; + DT_UNSIGNED_INT64 = 3; + DT_BOOL = 4; + DT_STRING = 5; + } + + oneof item { + PrimitiveKeyType primitive_key_type = 1; + Char char = 2; + VarChar var_char = 3; + Date date = 4; + Time time = 5; + DateTime date_time = 6; + } + } + + KeyType key_type = 1; + ComponentType value_type = 2; +} + +message StorageDataType { + oneof item { + PrimitiveType primitive_type = 1; + Numeric numeric = 2; + Char char = 3; + VarChar var_char = 4; + Date date = 5; + Time time = 6; + DateTime date_time = 7; + Array array = 8; + MultiSet multi_set = 9; + Map map = 10; + } + + bool nullable = 11; +} diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto new file mode 100644 index 000000000000..e5d323464d4e --- /dev/null +++ b/flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package gie; +option java_package = "com.alibaba.graphscope.proto.schema"; + +import "schema.proto"; +import "partition.proto"; + +message Graph { + string snapshot_id = 1; + Schema schema = 2; + GraphPartitionStrategy partition_strategy = 3; +} \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto new file mode 100644 index 000000000000..bfc7c571add8 --- /dev/null +++ b/flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto @@ -0,0 +1,123 @@ +syntax = "proto3"; + +package gie; +option java_package = "com.alibaba.graphscope.proto.schema"; + +import "schema.proto"; + +message GraphTopologyPartitionStrategy { + enum VertexPartitionStrategy { + VPS_ALL = 0; // a vertex is replicated in all partitions + VPS_ONE = 1; // Edge-Cut, a vertex is distributed to one partition + 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 + } + + enum EdgePartitionStrategy { + EPS_ALL = 0; // an edge is replicated in all partitions + EPS_ONE = 1; // Vertex-Cut, an edge is distributed to one partition + EPS_FOLLOW_SRC = 2; // Edge-Cut, an edge is distributed to the partition where its source vertex resides + EPS_FOLLOW_DST = 3; // Edge-Cut, an edge is distributed to the partition where its dst vertex resides + EPS_FOLLOW_BOTH = 4; // Edge-Cut, an edge is distributed to the partitions where its src or dst vertices reside + } + + // Index Strategy to lookup edges by vertex + enum VertexToEdgeIndexStrategy { + VTE_NONE = 0; // no indexing, i.e. Vertex-Cut + VTE_INDEX_SRC = 1; // indexing based on the source vertex + VTE_INDEX_DST = 2; // indexing based on the dst vertex + VTE_INDEX_BOTH = 3; // indexing based on both the src and dst vertices + } + + message AllReplicate { + // VertexPartitionStrategy = ALL + // EdgePartitionStrategy = ALL + VertexToEdgeIndexStrategy index_strategy = 1; + } + + message VertexCut { + // partition edges first, then place vertices automatically + } + + message EdgeCut { + // partition vertices first using MAP_TO_ONE strategy, + // then place edges with certain placement strategy + + // VertexPartitionStrategy = ONE + EdgePartitionStrategy edge_partition_strategy = 1; + VertexToEdgeIndexStrategy edge_index_strategy = 2; + } + + message AdvancedEdgeCut { + message VertexTypePairEdgePartitionStrategy { + uint32 src_type = 1; + uint32 dst_type = 2; + EdgePartitionStrategy edge_partition_strategy = 3; + } + + message VertexTypePairEdgeIndexStrategy { + uint32 src_type = 1; + uint32 dst_type = 2; + VertexToEdgeIndexStrategy edge_index_strategy = 3; + } + + message VertexTypePairEdgePartitionStrategyArray { + repeated VertexTypePairEdgePartitionStrategy vertex_type_pair_edge_partition_strategy = 1; + } + + message VertexTypePairEdgeIndexStrategyArray { + repeated VertexTypePairEdgeIndexStrategy vertex_type_pair_edge_index_strategy = 1; + } + + map vertex_type_to_partition_strategy = 1; + map edge_type_to_partition_strategy = 2; + map edge_type_to_index_strategy = 3; + } + + oneof item { + AllReplicate replicate = 1; + EdgeCut edge_cut = 2; + VertexCut vertex_cut = 3; + AdvancedEdgeCut advanced_edge_cut = 4; + } +} + +message GraphPropertyPlacementStrategy { + // This strategy assumes that properties are always distributed along with the topology of the vertices/edges. + // Other strategies, i.e., properties are not distributed along with the topology, are not currently being considered. + enum PropertyPlacementStrategy { + PPS_UNDEFINED = 0; + // Properties exist only in one of partitions (i.e., the master node in GRIN) where the vertex/edge topology resides. + // 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'. + PPS_ON_MASTER = 1; + // Properties exist in each partition where the vertex/edge topology resides. + // 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'. + PPS_ON_MASTER_N_MIRROR = 2; + } + + message AllReplicatePropertyPlacement { + PropertyPlacementStrategy all_replicate_vertex_property_placement_strategy = 1; + PropertyPlacementStrategy all_replicate_edge_property_placement_strategy = 2; + } + + // Combine the EdgeCut and AdvancedEdgeCut partition strategies. + message EdgeCutPropertyPlacement { + PropertyPlacementStrategy all_replicate_vertex_property_placement_strategy = 1; + PropertyPlacementStrategy edge_cut_vertex_property_placement_strategy = 2; + PropertyPlacementStrategy edge_cut_edge_property_placement_strategy = 3; + } + + message VertexCutPropertyPlacement { + // property placement in VertexCut is not considered currently. + } + + oneof item { + AllReplicatePropertyPlacement all_replicate_property_placement = 1; + EdgeCutPropertyPlacement edge_cut_property_placement = 2; + VertexCutPropertyPlacement vertex_cut_property_placement = 3; + } +} + +message GraphPartitionStrategy { + GraphTopologyPartitionStrategy topology_partition = 1; + GraphPropertyPlacementStrategy property_placement = 2; +} diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto new file mode 100644 index 000000000000..8a5f28f76851 --- /dev/null +++ b/flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package gie; +option java_package = "com.alibaba.graphscope.proto.schema"; + +import "data_type.proto"; + +message Property { + uint32 property_id = 1; + string property_name = 2; + StorageDataType property_type = 3; + string comment = 4; // description of the property +} + +message VertexType { + uint32 type_id = 1; + string type_name = 2; + repeated Property properties = 3; + repeated uint32 primary_key_ids = 4; + string comment = 5; // description of the vertex type +} + +message EdgeType { + enum Relation { + MANY_TO_MANY = 0; + MANY_TO_ONE = 1; + ONE_TO_MANY = 2; + ONE_TO_ONE = 3; + } + message VertexTypePairRelation { + uint32 src_type_id = 1; + uint32 dst_type_id = 2; + Relation relation = 3; + } + uint32 type_id = 1; + string type_name = 2; + repeated Property properties = 3; + repeated uint32 primary_key_ids = 4; + repeated VertexTypePairRelation vertex_type_pair_relations = 5; + string comment = 6; // description of the edge type +} + +message Schema { + repeated VertexType vertex_types = 1; + repeated EdgeType edge_types = 2; +} diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto new file mode 100644 index 000000000000..bc4e5554940a --- /dev/null +++ b/flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package gie; +option java_package = "com.alibaba.graphscope.proto.schema"; + +message VertexTypeStatistics { + uint32 vertex_type_id = 1; + uint64 num_vertices = 2; +} + +message EdgeTypeStatistics { + message EntityPairStatistics { + uint32 src_type_id = 1; + uint32 dst_type_id = 2; + uint64 num_edges = 3; + } + uint32 edge_type_id = 1; + repeated EntityPairStatistics entity_pair_statistics = 2; +} + +message Statistics { + string snapshot_id = 1; + + uint32 num_partitions = 2; + uint64 num_vertices = 3; + uint64 num_edges = 4; + + repeated VertexTypeStatistics vertex_type_statistics = 5; + repeated EdgeTypeStatistics edge_type_statistics = 6; +} diff --git a/flex/engines/graph_db/grin/include/proto/graph.proto b/flex/engines/graph_db/grin/include/proto/graph.proto new file mode 100644 index 000000000000..36473f516892 --- /dev/null +++ b/flex/engines/graph_db/grin/include/proto/graph.proto @@ -0,0 +1,141 @@ +syntax = "proto3"; + +package grin; + +enum ListRetrieval { + LR_NA = 0; + LR_ARRAY_LIKE = 1; + LR_ITERATOR = 2; +} + +message TopologyFeature { + bool grin_assume_has_directed_graph = 1; + bool grin_assume_has_undirected_graph = 2; + bool grin_assume_has_multi_edge_graph = 3; + bool grin_with_vertex_data = 4; + bool grin_with_edge_data = 5; + repeated ListRetrieval vertex_list_retrievals = 6; + repeated ListRetrieval edge_list_retrievals = 7; + repeated ListRetrieval adjacent_list_retrievals = 8; +} + +enum GraphPartitionStrategy { + GPS_NA = 0; + GPS_ALL_REPLICATE = 1; + GPS_EDGE_CUT = 2; + GPS_VERTEX_CUT = 3; + GPS_HYBRID_CUT = 4; +} + +enum PropertyDataPartitionStrategy { + PDPS_NA = 0; + PDPS_MASTER_ONLY = 1; + PDPS_REPLICATE_MASTER_MIRROR = 2; + PDPS_SPLIT_MASTER_MIRROR = 3; +} + +message MirrorPartitionListFeature { + bool grin_trait_master_vertex_mirror_partition_list = 1; + bool grin_trait_mirror_vertex_mirror_partition_list = 2; + bool grin_trait_master_edge_mirror_partition_list = 3; + bool grin_trait_mirror_edge_mirror_partition_list = 4; +} + + +message PartitionFeature { + GraphPartitionStrategy graph_partition_strategy = 1; + + bool grin_trait_natural_id_for_partition = 2; + bool grin_enable_vertex_ref = 3; + bool grin_enable_edge_ref = 4; + + PropertyDataPartitionStrategy vertex_data = 5; + PropertyDataPartitionStrategy edge_data = 6; + + MirrorPartitionListFeature mirror_partition_list_feature = 7; + + bool grin_trait_select_master_for_vertex_list = 8; + bool grin_trait_select_partition_for_vertex_list = 9; + bool grin_trait_select_master_for_edge_list = 10; + bool grin_trait_select_partition_for_edge_list = 11; + bool grin_trait_select_master_neighbor_for_adjacent_list = 12; + bool grin_trait_select_neighbor_partition_for_adjacent_list = 13; + + bool grin_trait_fast_vertex_ref = 14; +} + +message VertexPropertyFeature { + bool grin_with_vertex_property = 1; + bool grin_with_vertex_property_name = 2; + bool grin_with_vertex_type_name = 3; + + bool grin_enable_vertex_primary_keys = 4; + + bool grin_trait_natural_id_for_vertex_type = 5; + bool grin_trait_natural_id_for_vertex_property = 6; +} + +message EdgePropertyFeature { + bool grin_with_edge_property = 1; + bool grin_with_edge_property_name = 2; + bool grin_with_edge_type_name = 3; + + bool grin_enable_edge_primary_keys = 4; + + bool grin_trait_natural_id_for_edge_type = 5; + bool grin_trait_natural_id_for_edge_property = 6; +} + +message PropertyFeature { + bool grin_enable_row = 1; + VertexPropertyFeature vertex_property_feature = 2; + EdgePropertyFeature edge_property_feature = 3; + + PropertyDataPartitionStrategy vertex_property = 4; + PropertyDataPartitionStrategy edge_property = 5; + + bool grin_trait_specific_vev_relation = 6; + + bool grin_trait_const_value_ptr = 7; +} + +message IndexFeature { + bool grin_with_vertex_label = 1; + bool grin_with_edge_label = 2; + + bool grin_assume_all_vertex_list_sorted = 3; + + bool grin_enable_vertex_internal_id_index = 4; + + bool grin_enable_vertex_pk_index = 5; + bool grin_enable_edge_pk_index = 6; +} + +message PredicateFeature { + +} + +message StorageFeature { + oneof specific_feature { + TopologyFeature topology_feature = 1; + PartitionFeature partition_feature = 2; + PropertyFeature property_feature = 3; + IndexFeature index_feature = 4; + PredicateFeature predicate_feature = 5; + } +} + +message Statistics { + int32 vertex_count = 1; + int32 edge_count = 2; + int32 partition_count = 3; + int32 vertex_type_count = 4; + int32 edge_type_count = 5; +} + +message Graph { + string uri = 1; + string grin_version = 2; + repeated StorageFeature features = 3; + Statistics statistics = 4; +} diff --git a/flex/engines/graph_db/grin/include/rust/Cargo.toml b/flex/engines/graph_db/grin/include/rust/Cargo.toml new file mode 100644 index 000000000000..75783a76f55c --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/Cargo.toml @@ -0,0 +1,75 @@ +[package] +name = "grin" +version = "0.1.1" +authors = ["dijie"] + +[dependencies] +cfg-if = "0.1" + +[features] +grin_assume_has_directed_graph = [] +grin_assume_has_undirected_graph = [] +grin_assume_has_multi_edge_graph = [] +grin_with_vertex_data = [] +grin_with_edge_data = [] +grin_enable_vertex_list = [] +grin_enable_vertex_list_array = [] +grin_enable_vertex_list_iterator = [] +grin_enable_edge_list = [] +grin_enable_edge_list_array = [] +grin_enable_edge_list_iterator = [] +grin_enable_adjacent_list = [] +grin_enable_adjacent_list_array = [] +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_enable_edge_ref = [] +grin_assume_all_replicate_partition = [] +grin_assume_edge_cut_partition = [] +grin_assume_edge_cut_follow_src_partition = [] +grin_assume_edge_cut_follow_dst_partition = [] +grin_assume_vertex_cut_partition = [] +grin_assume_master_only_partition_for_vertex_data = [] +grin_assume_replicate_master_mirror_partition_for_vertex_data = [] +grin_assume_master_only_partition_for_edge_data = [] +grin_assume_replicate_master_mirror_partition_for_edge_data = [] +grin_trait_master_vertex_mirror_partition_list = [] +grin_trait_mirror_vertex_mirror_partition_list = [] +grin_trait_master_edge_mirror_partition_list = [] +grin_trait_mirror_edge_mirror_partition_list = [] +grin_trait_select_master_for_vertex_list = [] +grin_trait_select_partition_for_vertex_list = [] +grin_trait_select_master_for_edge_list = [] +grin_trait_select_partition_for_edge_list = [] +grin_trait_select_master_neighbor_for_adjacent_list = [] +grin_trait_select_neighbor_partition_for_adjacent_list = [] +grin_enable_row = [] +grin_trait_const_value_ptr = [] +grin_with_vertex_property = [] +grin_with_vertex_property_name = [] +grin_with_vertex_type_name = [] +grin_trait_natural_id_for_vertex_type = [] +grin_enable_vertex_primary_keys = [] +grin_trait_natural_id_for_vertex_property = [] +grin_with_edge_property = [] +grin_with_edge_property_name = [] +grin_with_edge_type_name = [] +grin_trait_natural_id_for_edge_type = [] +grin_enable_edge_primary_keys = [] +grin_trait_natural_id_for_edge_property = [] +grin_trait_specific_vev_relation = [] +grin_assume_master_only_partition_for_vertex_property = [] +grin_assume_replicate_master_mirror_partition_for_vertex_property = [] +grin_assume_split_master_mirror_partition_for_vertex_property = [] +grin_assume_master_only_partition_for_edge_property = [] +grin_assume_replicate_master_mirror_partition_for_edge_property = [] +grin_assume_split_master_mirror_partition_for_edge_property = [] +grin_with_vertex_label = [] +grin_with_edge_label = [] +grin_assume_all_vertex_list_sorted = [] +grin_enable_vertex_internal_id_index = [] +grin_enable_vertex_pk_index = [] +grin_enable_edge_pk_index = [] +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_trait_natural_id_for_partition', 'grin_enable_vertex_ref', 'grin_trait_fast_vertex_ref', 'grin_assume_edge_cut_partition', 'grin_trait_select_master_for_vertex_list', 'grin_enable_row', 'grin_with_vertex_property', 'grin_with_vertex_property_name', 'grin_with_vertex_type_name', 'grin_trait_natural_id_for_vertex_type', 'grin_trait_natural_id_for_vertex_property', 'grin_with_edge_property', 'grin_with_edge_property_name', 'grin_with_edge_type_name', 'grin_trait_natural_id_for_edge_type', 'grin_trait_natural_id_for_edge_property', 'grin_enable_vertex_primary_keys', 'grin_enable_vertex_internal_id_index', 'grin_enable_vertex_pk_index'] diff --git a/flex/engines/graph_db/grin/include/rust/grin.rs b/flex/engines/graph_db/grin/include/rust/grin.rs new file mode 100644 index 000000000000..2b51035f88a6 --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/grin.rs @@ -0,0 +1,1693 @@ +#[doc = "< incoming"] +pub const GRIN_DIRECTION_IN: GrinDirection = 0; +#[doc = "< outgoing"] +pub const GRIN_DIRECTION_OUT: GrinDirection = 1; +#[doc = "< incoming & outgoing"] +pub const GRIN_DIRECTION_BOTH: GrinDirection = 2; +#[doc = " Enumerates the directions of edges with respect to a certain vertex"] +pub type GrinDirection = u32; +#[doc = "< other unknown types"] +pub const GRIN_DATATYPE_UNDEFINED: GrinDatatype = 0; +#[doc = "< int"] +pub const GRIN_DATATYPE_INT32: GrinDatatype = 1; +#[doc = "< unsigned int"] +pub const GRIN_DATATYPE_UINT32: GrinDatatype = 2; +#[doc = "< long int"] +pub const GRIN_DATATYPE_INT64: GrinDatatype = 3; +#[doc = "< unsigned long int"] +pub const GRIN_DATATYPE_UINT64: GrinDatatype = 4; +#[doc = "< float"] +pub const GRIN_DATATYPE_FLOAT: GrinDatatype = 5; +#[doc = "< double"] +pub const GRIN_DATATYPE_DOUBLE: GrinDatatype = 6; +#[doc = "< string"] +pub const GRIN_DATATYPE_STRING: GrinDatatype = 7; +#[doc = "< date"] +pub const GRIN_DATATYPE_DATE32: GrinDatatype = 8; +#[doc = "< Time32"] +pub const GRIN_DATATYPE_TIME32: GrinDatatype = 9; +#[doc = "< Timestamp"] +pub const GRIN_DATATYPE_TIMESTAMP64: GrinDatatype = 10; +#[doc = " Enumerates the datatype supported in the storage"] +pub type GrinDatatype = u32; +#[doc = "< success"] +pub const GRIN_ERROR_CODE_NO_ERROR: GrinErrorCode = 0; +#[doc = "< unknown error"] +pub const GRIN_ERROR_CODE_UNKNOWN_ERROR: GrinErrorCode = 1; +#[doc = "< invalid value"] +pub const GRIN_ERROR_CODE_INVALID_VALUE: GrinErrorCode = 2; +#[doc = "< unknown datatype"] +pub const GRIN_ERROR_CODE_UNKNOWN_DATATYPE: GrinErrorCode = 3; +#[doc = " Enumerates the error codes of grin"] +pub type GrinErrorCode = u32; +cfg_if::cfg_if! { + if #[cfg(feature = "grin_features_enable_v6d")]{ + pub type GrinGraph = *mut ::std::os::raw::c_void; + pub type GrinVertex = u64; + #[repr(C)] + #[derive(Debug, Copy, Clone, PartialEq)] + pub struct GrinEdge { + pub src: GrinVertex, + pub dst: GrinVertex, + pub dir: GrinDirection, + pub etype: u32, + pub eid: u64, + } + pub type GrinVertexList = *mut ::std::os::raw::c_void; + pub type GrinVertexListIterator = *mut ::std::os::raw::c_void; + #[repr(C)] + #[derive(Debug, Copy, Clone, PartialEq)] + pub struct GrinAdjacentList { + pub begin: *const ::std::os::raw::c_void, + pub end: *const ::std::os::raw::c_void, + pub vid: GrinVertex, + pub dir: GrinDirection, + pub etype: u32, + } + pub type GrinAdjacentListIterator = *mut ::std::os::raw::c_void; + pub type GrinPartitionedGraph = *mut ::std::os::raw::c_void; + pub type GrinPartition = u32; + pub type GrinPartitionList = *mut ::std::os::raw::c_void; + pub type GrinPartitionId = u32; + pub type GrinVertexRef = i64; + pub type GrinVertexType = u32; + pub type GrinVertexTypeList = *mut ::std::os::raw::c_void; + pub type GrinVertexProperty = u64; + pub type GrinVertexPropertyList = *mut ::std::os::raw::c_void; + pub type GrinVertexTypeId = u32; + pub type GrinVertexPropertyId = u32; + pub type GrinEdgeType = u32; + pub type GrinEdgeTypeList = *mut ::std::os::raw::c_void; + pub type GrinVevType = *mut ::std::os::raw::c_void; + pub type GrinVevTypeList = *mut ::std::os::raw::c_void; + pub type GrinEdgeProperty = u64; + pub type GrinEdgePropertyList = *mut ::std::os::raw::c_void; + pub type GrinEdgeTypeId = u32; + pub type GrinEdgePropertyId = u32; + pub type GrinRow = *mut ::std::os::raw::c_void; + pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; + pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX; + pub const GRIN_NULL_EDGE: GrinEdge = GrinEdge{src: u64::MAX, dst: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX, eid: u64::MAX}; + pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); + pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = GrinAdjacentList{begin: std::ptr::null(), end: std::ptr::null(), vid: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX}; + pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX; + pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; + pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1; + pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX; + pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX; + pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; + pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; + pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX; + pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); + pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); + pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX; + pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; + pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; + pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); + pub const GRIN_NULL_SIZE: u32 = u32::MAX; + } else { + pub type GrinGraph = *mut ::std::os::raw::c_void; + pub type GrinVertex = *mut ::std::os::raw::c_void; + pub type GrinEdge = *mut ::std::os::raw::c_void; + pub type GrinVertexData = *mut ::std::os::raw::c_void; + pub type GrinVertexList = *mut ::std::os::raw::c_void; + pub type GrinVertexListIterator = *mut ::std::os::raw::c_void; + pub type GrinAdjacentList = *mut ::std::os::raw::c_void; + pub type GrinAdjacentListIterator = *mut ::std::os::raw::c_void; + pub type GrinEdgeData = *mut ::std::os::raw::c_void; + pub type GrinEdgeList = *mut ::std::os::raw::c_void; + pub type GrinEdgeListIterator = *mut ::std::os::raw::c_void; + pub type GrinPartitionedGraph = *mut ::std::os::raw::c_void; + pub type GrinPartition = *mut ::std::os::raw::c_void; + pub type GrinPartitionList = *mut ::std::os::raw::c_void; + pub type GrinPartitionId = u32; + pub type GrinVertexRef = *mut ::std::os::raw::c_void; + pub type GrinEdgeRef = *mut ::std::os::raw::c_void; + pub type GrinVertexType = *mut ::std::os::raw::c_void; + pub type GrinVertexTypeList = *mut ::std::os::raw::c_void; + pub type GrinVertexProperty = *mut ::std::os::raw::c_void; + pub type GrinVertexPropertyList = *mut ::std::os::raw::c_void; + pub type GrinVertexTypeId = u32; + pub type GrinVertexPropertyId = u32; + pub type GrinEdgeType = *mut ::std::os::raw::c_void; + pub type GrinEdgeTypeList = *mut ::std::os::raw::c_void; + pub type GrinVevType = *mut ::std::os::raw::c_void; + pub type GrinVevTypeList = *mut ::std::os::raw::c_void; + pub type GrinEdgeProperty = *mut ::std::os::raw::c_void; + pub type GrinEdgePropertyList = *mut ::std::os::raw::c_void; + pub type GrinEdgeTypeId = u32; + pub type GrinEdgePropertyId = u32; + pub type GrinRow = *mut ::std::os::raw::c_void; + pub type GrinLabel = *mut ::std::os::raw::c_void; + pub type GrinLabelList = *mut ::std::os::raw::c_void; + pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; + pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_DATA: GrinVertexData = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); + pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut(); + pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_DATA: GrinEdgeData = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITION: GrinPartition = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); + pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; + pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); + pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; + pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; + pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); + pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); + pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); + pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; + pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; + pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); + pub const GRIN_NULL_LABEL: GrinLabel = std::ptr::null_mut(); + pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut(); + pub const GRIN_NULL_SIZE: u32 = u32::MAX; + } +} +extern "C" { + #[cfg(feature = "grin_enable_adjacent_list")] + #[allow(unused)] + pub fn grin_destroy_adjacent_list(arg1: GrinGraph, arg2: GrinAdjacentList); + + #[cfg(feature = "grin_enable_adjacent_list_array")] + #[allow(unused)] + pub fn grin_get_adjacent_list_size(arg1: GrinGraph, arg2: GrinAdjacentList) -> usize; + + #[doc = " @brief Get the neighbor vertex from the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentList The adjacent list.\n @param index The index of the edge to/from the neighbor in the adjacent list.\n @return The neighbor vertex."] + #[cfg(feature = "grin_enable_adjacent_list_array")] + #[allow(unused)] + pub fn grin_get_neighbor_from_adjacent_list( + arg1: GrinGraph, + arg2: GrinAdjacentList, + index: usize, + ) -> GrinVertex; + + #[doc = " @brief Get the edge from the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentList The adjacent list.\n @param index The index of the edge in the adjacent list.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] + #[cfg(feature = "grin_enable_adjacent_list_array")] + #[allow(unused)] + pub fn grin_get_edge_from_adjacent_list( + arg1: GrinGraph, + arg2: GrinAdjacentList, + arg3: usize, + ) -> GrinEdge; + + #[doc = " @brief Get the begin iterator of the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentList The adjacent list.\n @return The begin iterator of the adjacent list."] + #[cfg(feature = "grin_enable_adjacent_list_iterator")] + #[allow(unused)] + pub fn grin_get_adjacent_list_begin( + arg1: GrinGraph, + arg2: GrinAdjacentList, + ) -> GrinAdjacentListIterator; + + #[cfg(feature = "grin_enable_adjacent_list_iterator")] + #[allow(unused)] + pub fn grin_destroy_adjacent_list_iter(arg1: GrinGraph, arg2: GrinAdjacentListIterator); + + #[doc = " @brief Update the iterator to the next of the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator to be updated."] + #[cfg(feature = "grin_enable_adjacent_list_iterator")] + #[allow(unused)] + pub fn grin_get_next_adjacent_list_iter(arg1: GrinGraph, arg2: GrinAdjacentListIterator); + + #[doc = " @brief Check if the adjacent list iterator is at the end.\n Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin``\n if the adjacent list is empty.\n Users should check if the iterator is at the end before using it.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator.\n @return True if the iterator is at the end, otherwise false."] + #[cfg(feature = "grin_enable_adjacent_list_iterator")] + #[allow(unused)] + pub fn grin_is_adjacent_list_end(arg1: GrinGraph, arg2: GrinAdjacentListIterator) -> bool; + + #[doc = " @brief Get the neighbor vertex from the adjacent list iterator.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator.\n @return The neighbor vertex."] + #[cfg(feature = "grin_enable_adjacent_list_iterator")] + #[allow(unused)] + pub fn grin_get_neighbor_from_adjacent_list_iter( + arg1: GrinGraph, + arg2: GrinAdjacentListIterator, + ) -> GrinVertex; + + #[doc = " @brief Get the edge from the adjacent list iterator.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] + #[cfg(feature = "grin_enable_adjacent_list_iterator")] + #[allow(unused)] + pub fn grin_get_edge_from_adjacent_list_iter( + arg1: GrinGraph, + arg2: GrinAdjacentListIterator, + ) -> GrinEdge; + + #[cfg(feature = "grin_enable_edge_list")] + #[allow(unused)] + pub fn grin_destroy_edge_list(arg1: GrinGraph, arg2: GrinEdgeList); + + #[cfg(feature = "grin_enable_edge_list_array")] + #[allow(unused)] + pub fn grin_get_edge_list_size(arg1: GrinGraph, arg2: GrinEdgeList) -> usize; + + #[cfg(feature = "grin_enable_edge_list_array")] + #[allow(unused)] + pub fn grin_get_edge_from_list( + arg1: GrinGraph, + arg2: GrinEdgeList, + arg3: usize, + ) -> GrinEdge; + + #[cfg(feature = "grin_enable_edge_list_iterator")] + #[allow(unused)] + pub fn grin_get_edge_list_begin( + arg1: GrinGraph, + arg2: GrinEdgeList, + ) -> GrinEdgeListIterator; + + #[cfg(feature = "grin_enable_edge_list_iterator")] + #[allow(unused)] + pub fn grin_destroy_edge_list_iter(arg1: GrinGraph, arg2: GrinEdgeListIterator); + + #[cfg(feature = "grin_enable_edge_list_iterator")] + #[allow(unused)] + pub fn grin_get_next_edge_list_iter(arg1: GrinGraph, arg2: GrinEdgeListIterator); + + #[cfg(feature = "grin_enable_edge_list_iterator")] + #[allow(unused)] + pub fn grin_is_edge_list_end(arg1: GrinGraph, arg2: GrinEdgeListIterator) -> bool; + + #[cfg(feature = "grin_enable_edge_list_iterator")] + #[allow(unused)] + pub fn grin_get_edge_from_iter(arg1: GrinGraph, arg2: GrinEdgeListIterator) -> GrinEdge; + + #[doc = " @brief Get a (non-partitioned) graph from storage\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A graph handle."] + #[allow(unused)] + pub fn grin_get_graph_from_storage(arg1: *const ::std::os::raw::c_char) -> GrinGraph; + + #[allow(unused)] + pub fn grin_destroy_graph(arg1: GrinGraph); + + #[doc = " @brief Check if the graph is directed.\n This API is only available when the storage supports both directed and\n undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH``\n and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined.\n @param GrinGraph The graph.\n @return True if the graph is directed, otherwise false."] + #[cfg(all(feature = "grin_assume_has_directed_graph", feature = "grin_assume_has_undirected_graph"))] + #[allow(unused)] + pub fn grin_is_directed(arg1: GrinGraph) -> bool; + + #[doc = " @brief Check if the graph is a multigraph.\n This API is only available when the storage supports multigraph.\n @param GrinGraph The graph.\n @return True if the graph is a multigraph, otherwise false."] + #[cfg(feature = "grin_assume_has_multi_edge_graph")] + #[allow(unused)] + pub fn grin_is_multigraph(arg1: GrinGraph) -> bool; + + #[allow(unused)] + pub fn grin_destroy_vertex(arg1: GrinGraph, arg2: GrinVertex); + + #[allow(unused)] + pub fn grin_equal_vertex(arg1: GrinGraph, arg2: GrinVertex, arg3: GrinVertex) -> bool; + + #[cfg(feature = "grin_with_vertex_data")] + #[allow(unused)] + pub fn grin_get_vertex_data_datatype(arg1: GrinGraph, arg2: GrinVertex) -> GrinDatatype; + + #[cfg(feature = "grin_with_vertex_data")] + #[allow(unused)] + pub fn grin_get_vertex_data_value( + arg1: GrinGraph, + arg2: GrinVertex, + ) -> *const ::std::os::raw::c_void; + + #[allow(unused)] + pub fn grin_destroy_edge(arg1: GrinGraph, arg2: GrinEdge); + + #[doc = " @brief Get the source vertex of an edge.\n @param GrinGraph The graph.\n @param GrinEdge The edge.\n @return The source vertex of the edge."] + #[allow(unused)] + pub fn grin_get_src_vertex_from_edge(arg1: GrinGraph, arg2: GrinEdge) -> GrinVertex; + + #[doc = " @brief Get the destination vertex of an edge.\n @param GrinGraph The graph.\n @param GrinEdge The edge.\n @return The destination vertex of the edge."] + #[allow(unused)] + pub fn grin_get_dst_vertex_from_edge(arg1: GrinGraph, arg2: GrinEdge) -> GrinVertex; + + #[cfg(feature = "grin_with_edge_data")] + #[allow(unused)] + pub fn grin_get_edge_data_datatype(arg1: GrinGraph, arg2: GrinEdge) -> GrinDatatype; + + #[cfg(feature = "grin_with_edge_data")] + #[allow(unused)] + pub fn grin_get_edge_data_value( + arg1: GrinGraph, + arg2: GrinEdge, + ) -> *const ::std::os::raw::c_void; + + #[cfg(feature = "grin_enable_vertex_list")] + #[allow(unused)] + pub fn grin_destroy_vertex_list(arg1: GrinGraph, arg2: GrinVertexList); + + #[cfg(feature = "grin_enable_vertex_list_array")] + #[allow(unused)] + pub fn grin_get_vertex_list_size(arg1: GrinGraph, arg2: GrinVertexList) -> usize; + + #[doc = " @brief Get the vertex from the vertex list.\n @param GrinGraph The graph.\n @param GrinVertexList The vertex list.\n @param index The index of the vertex in the vertex list.\n @return The vertex."] + #[cfg(feature = "grin_enable_vertex_list_array")] + #[allow(unused)] + pub fn grin_get_vertex_from_list( + arg1: GrinGraph, + arg2: GrinVertexList, + index: usize, + ) -> GrinVertex; + + #[doc = " @brief Get the begin iterator of the vertex list.\n @param GrinGraph The graph.\n @param GrinVertexList The vertex list.\n @return The begin iterator."] + #[cfg(feature = "grin_enable_vertex_list_iterator")] + #[allow(unused)] + pub fn grin_get_vertex_list_begin( + arg1: GrinGraph, + arg2: GrinVertexList, + ) -> GrinVertexListIterator; + + #[cfg(feature = "grin_enable_vertex_list_iterator")] + #[allow(unused)] + pub fn grin_destroy_vertex_list_iter(arg1: GrinGraph, arg2: GrinVertexListIterator); + + #[doc = " @brief Update the iterator to the next of the vertex list.\n @param GrinGraph The graph.\n @param GrinVertexListIterator The iterator to be updated."] + #[cfg(feature = "grin_enable_vertex_list_iterator")] + #[allow(unused)] + pub fn grin_get_next_vertex_list_iter(arg1: GrinGraph, arg2: GrinVertexListIterator); + + #[doc = " @brief Check whether the iterator reaches the end of the vertex list.\n Note that we may get an end iterator when calling ``grin_get_vertex_list_begin``\n if the vertex list is empty.\n Users should check if the iterator is at the end before using it.\n @param GrinGraph The graph.\n @param GrinVertexListIterator The iterator.\n @return True if the iterator reaches the end of the vertex list."] + #[cfg(feature = "grin_enable_vertex_list_iterator")] + #[allow(unused)] + pub fn grin_is_vertex_list_end(arg1: GrinGraph, arg2: GrinVertexListIterator) -> bool; + + #[doc = " @brief Get the vertex from the iterator.\n @param GrinGraph The graph.\n @param GrinVertexListIterator The iterator.\n @return The vertex."] + #[cfg(feature = "grin_enable_vertex_list_iterator")] + #[allow(unused)] + pub fn grin_get_vertex_from_iter( + arg1: GrinGraph, + arg2: GrinVertexListIterator, + ) -> GrinVertex; + + #[doc = " @brief Get a partitioned graph from a storage.\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A partitioned graph handle."] + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_partitioned_graph_from_storage( + uri: *const ::std::os::raw::c_char, + ) -> GrinPartitionedGraph; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_destroy_partitioned_graph(arg1: GrinPartitionedGraph); + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_total_partitions_number(arg1: GrinPartitionedGraph) -> usize; + + #[doc = " @brief Get the local partition list of the partitioned graph.\n For example, a graph may be partitioned into 6 partitions and located in\n 2 machines, then each machine may contain a local partition list of size 3.\n @param GrinPartitionedGraph The partitioned graph.\n @return A partition list of local partitions."] + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_local_partition_list(arg1: GrinPartitionedGraph) -> GrinPartitionList; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_destroy_partition_list(arg1: GrinPartitionedGraph, arg2: GrinPartitionList); + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_create_partition_list(arg1: GrinPartitionedGraph) -> GrinPartitionList; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_insert_partition_to_list( + arg1: GrinPartitionedGraph, + arg2: GrinPartitionList, + arg3: GrinPartition, + ) -> bool; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_partition_list_size( + arg1: GrinPartitionedGraph, + arg2: GrinPartitionList, + ) -> usize; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_partition_from_list( + arg1: GrinPartitionedGraph, + arg2: GrinPartitionList, + arg3: usize, + ) -> GrinPartition; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_equal_partition( + arg1: GrinPartitionedGraph, + arg2: GrinPartition, + arg3: GrinPartition, + ) -> bool; + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_destroy_partition(arg1: GrinPartitionedGraph, arg2: GrinPartition); + + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_partition_info( + arg1: GrinPartitionedGraph, + arg2: GrinPartition, + ) -> *const ::std::os::raw::c_void; + + #[doc = " @brief Get a local graph of the partitioned graph.\n @param GrinPartitionedGraph The partitioned graph.\n @param GrinPartition The partition of the graph.\n @return A local graph."] + #[cfg(feature = "grin_enable_graph_partition")] + #[allow(unused)] + pub fn grin_get_local_graph_by_partition( + arg1: GrinPartitionedGraph, + arg2: GrinPartition, + ) -> GrinGraph; + + #[cfg(feature = "grin_trait_natural_id_for_partition")] + #[allow(unused)] + pub fn grin_get_partition_by_id( + arg1: GrinPartitionedGraph, + arg2: GrinPartitionId, + ) -> GrinPartition; + + #[cfg(feature = "grin_trait_natural_id_for_partition")] + #[allow(unused)] + pub fn grin_get_partition_id( + arg1: GrinPartitionedGraph, + arg2: GrinPartition, + ) -> GrinPartitionId; + + #[doc = " @brief Get the vertex ref of a vertex.\n A vertex ref is a reference for a \"local\" vertex, and the reference can\n be recognized by other partitions.\n To transfer the vertex ref handle between partitions, users should\n first call serialization methods to serialize the vertex ref handle\n into string or int64 based on the storage's features;\n then send the messages to remote partitions and deserialize the string or\n int64 remotely to get the vertex ref handle on the remote partition;\n finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle\n on the remote partition.\n These two vertices should represent the same vertex in the partitioned graph.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @return The vertex ref"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_get_vertex_ref_by_vertex(arg1: GrinGraph, arg2: GrinVertex) -> GrinVertexRef; + + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_destroy_vertex_ref(arg1: GrinGraph, arg2: GrinVertexRef); + + #[doc = " @brief get the local vertex handle from the vertex ref handle\n if the vertex ref handle is not recognized, a null vertex is returned\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref\n @return The vertex handle"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_get_vertex_from_vertex_ref(arg1: GrinGraph, arg2: GrinVertexRef) -> GrinVertex; + + #[doc = " @brief get the master partition of a vertex ref.\n Some storage can still provide the master partition of the vertex ref,\n even if the vertex ref can NOT be recognized locally.\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_get_master_partition_from_vertex_ref( + arg1: GrinGraph, + arg2: GrinVertexRef, + ) -> GrinPartition; + + #[doc = " @brief serialize the vertex ref handle to string\n The returned string should be freed by ``grin_destroy_serialized_vertex_ref``\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_serialize_vertex_ref( + arg1: GrinGraph, + arg2: GrinVertexRef, + ) -> *const ::std::os::raw::c_char; + + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_destroy_serialized_vertex_ref( + arg1: GrinGraph, + arg2: *const ::std::os::raw::c_char, + ); + + #[doc = " @brief deserialize the string to vertex ref handle\n If the string is invalid, a null vertex ref is returned\n @param GrinGraph The graph\n @param msg The string message to be deserialized"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_deserialize_to_vertex_ref( + arg1: GrinGraph, + msg: *const ::std::os::raw::c_char, + ) -> GrinVertexRef; + + #[doc = " @brief check if the vertex is a master vertex\n @param GrinGraph The graph\n @param GrinVertex The vertex"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_is_master_vertex(arg1: GrinGraph, arg2: GrinVertex) -> bool; + + #[doc = " @brief check if the vertex is a mirror vertex\n @param GrinGraph The graph\n @param GrinVertex The vertex"] + #[cfg(feature = "grin_enable_vertex_ref")] + #[allow(unused)] + pub fn grin_is_mirror_vertex(arg1: GrinGraph, arg2: GrinVertex) -> bool; + + #[doc = " @brief serialize the vertex ref handle to int64\n This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref\n can be serialized into int64 instead of string.\n Obviously transferring and serializing int64 is faster than string.\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref"] + #[cfg(feature = "grin_trait_fast_vertex_ref")] + #[allow(unused)] + pub fn grin_serialize_vertex_ref_as_int64( + arg1: GrinGraph, + arg2: GrinVertexRef, + ) -> i64; + + #[doc = " @brief deserialize the int64 to vertex ref handle\n @param GrinGraph The graph\n @param msg The int64 message to be deserialized"] + #[cfg(feature = "grin_trait_fast_vertex_ref")] + #[allow(unused)] + pub fn grin_deserialize_int64_to_vertex_ref( + arg1: GrinGraph, + msg: i64, + ) -> GrinVertexRef; + + #[cfg(feature = "grin_trait_master_vertex_mirror_partition_list")] + #[allow(unused)] + pub fn grin_get_master_vertex_mirror_partition_list( + arg1: GrinGraph, + arg2: GrinVertex, + ) -> GrinPartitionList; + + #[cfg(feature = "grin_trait_mirror_vertex_mirror_partition_list")] + #[allow(unused)] + pub fn grin_get_mirror_vertex_mirror_partition_list( + arg1: GrinGraph, + arg2: GrinVertex, + ) -> GrinPartitionList; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_get_edge_ref_by_edge(arg1: GrinGraph, arg2: GrinEdge) -> GrinEdgeRef; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_destroy_edge_ref(arg1: GrinGraph, arg2: GrinEdgeRef); + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_get_edge_from_edge_ref(arg1: GrinGraph, arg2: GrinEdgeRef) -> GrinEdge; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_get_master_partition_from_edge_ref( + arg1: GrinGraph, + arg2: GrinEdgeRef, + ) -> GrinPartition; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_serialize_edge_ref( + arg1: GrinGraph, + arg2: GrinEdgeRef, + ) -> *const ::std::os::raw::c_char; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_destroy_serialized_edge_ref(arg1: GrinGraph, arg2: *const ::std::os::raw::c_char); + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_deserialize_to_edge_ref( + arg1: GrinGraph, + arg2: *const ::std::os::raw::c_char, + ) -> GrinEdgeRef; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_is_master_edge(arg1: GrinGraph, arg2: GrinEdge) -> bool; + + #[cfg(feature = "grin_enable_edge_ref")] + #[allow(unused)] + pub fn grin_is_mirror_edge(arg1: GrinGraph, arg2: GrinEdge) -> bool; + + #[cfg(feature = "grin_trait_master_edge_mirror_partition_list")] + #[allow(unused)] + pub fn grin_get_master_edge_mirror_partition_list( + arg1: GrinGraph, + arg2: GrinEdge, + ) -> GrinPartitionList; + + #[cfg(feature = "grin_trait_mirror_edge_mirror_partition_list")] + #[allow(unused)] + pub fn grin_get_mirror_edge_mirror_partition_list( + arg1: GrinGraph, + arg2: GrinEdge, + ) -> GrinPartitionList; + + #[doc = " @brief Get the vertex list of a given type with master vertices only.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex list of master vertices only."] + #[cfg(all(feature = "grin_trait_select_master_for_vertex_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_list_by_type_select_master( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> GrinVertexList; + + #[doc = " @brief Get the vertex list of a given type with mirror vertices only.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex list of mirror vertices only."] + #[cfg(all(feature = "grin_trait_select_master_for_vertex_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_list_by_type_select_mirror( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> GrinVertexList; + + #[cfg(all(feature = "grin_trait_select_partition_for_vertex_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_list_by_type_select_partition( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinPartition, + ) -> GrinVertexList; + + #[cfg(all(feature = "grin_trait_select_master_for_edge_list", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_edge_list_by_type_select_master( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> GrinEdgeList; + + #[cfg(all(feature = "grin_trait_select_master_for_edge_list", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_edge_list_by_type_select_mirror( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> GrinEdgeList; + + #[cfg(all(feature = "grin_trait_select_partition_for_edge_list", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_edge_list_by_type_select_partition( + arg1: GrinGraph, + arg2: GrinEdgeType, + arg3: GrinPartition, + ) -> GrinEdgeList; + + #[cfg(all(feature = "grin_trait_select_master_neighbor_for_adjacent_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_adjacent_list_by_edge_type_select_master_neighbor( + arg1: GrinGraph, + arg2: GrinDirection, + arg3: GrinVertex, + arg4: GrinEdgeType, + ) -> GrinAdjacentList; + + #[cfg(all(feature = "grin_trait_select_master_neighbor_for_adjacent_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_adjacent_list_by_edge_type_select_mirror_neighbor( + arg1: GrinGraph, + arg2: GrinDirection, + arg3: GrinVertex, + arg4: GrinEdgeType, + ) -> GrinAdjacentList; + + #[cfg(all(feature = "grin_trait_select_neighbor_partition_for_adjacent_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_adjacent_list_by_edge_type_select_partition_neighbor( + arg1: GrinGraph, + arg2: GrinDirection, + arg3: GrinVertex, + arg4: GrinEdgeType, + arg5: GrinPartition, + ) -> GrinAdjacentList; + + #[cfg(feature = "grin_trait_specific_vev_relation")] + #[allow(unused)] + pub fn grin_get_one_to_one_vev_types(arg1: GrinGraph) -> GrinVevTypeList; + + #[cfg(feature = "grin_trait_specific_vev_relation")] + #[allow(unused)] + pub fn grin_get_one_to_many_vev_types(arg1: GrinGraph) -> GrinVevTypeList; + + #[cfg(feature = "grin_trait_specific_vev_relation")] + #[allow(unused)] + pub fn grin_get_many_to_one_vev_types(arg1: GrinGraph) -> GrinVevTypeList; + + #[cfg(feature = "grin_trait_specific_vev_relation")] + #[allow(unused)] + pub fn grin_get_many_to_many_vev_types(arg1: GrinGraph) -> GrinVevTypeList; + + #[doc = " @brief Get the vertex types that have primary keys\n In some graph, not every vertex type has primary keys.\n @param GrinGraph The graph\n @return The vertex type list of types that have primary keys"] + #[cfg(feature = "grin_enable_vertex_primary_keys")] + #[allow(unused)] + pub fn grin_get_vertex_types_with_primary_keys(arg1: GrinGraph) -> GrinVertexTypeList; + + #[doc = " @brief Get the primary keys properties of a vertex type\n The primary keys properties are the properties that can be used to identify a vertex.\n They are a subset of the properties of a vertex type.\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @return The primary keys properties list"] + #[cfg(feature = "grin_enable_vertex_primary_keys")] + #[allow(unused)] + pub fn grin_get_primary_keys_by_vertex_type( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> GrinVertexPropertyList; + + #[doc = " @brief Get the primary keys values row of a vertex\n The values in the row are in the same order as the primary keys properties.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @return The primary keys values row"] + #[cfg(feature = "grin_enable_vertex_primary_keys")] + #[allow(unused)] + pub fn grin_get_vertex_primary_keys_row(arg1: GrinGraph, arg2: GrinVertex) -> GrinRow; + + #[cfg(feature = "grin_enable_edge_primary_keys")] + #[allow(unused)] + pub fn grin_get_edge_types_with_primary_keys(arg1: GrinGraph) -> GrinEdgeTypeList; + + #[cfg(feature = "grin_enable_edge_primary_keys")] + #[allow(unused)] + pub fn grin_get_primary_keys_by_edge_type( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> GrinEdgePropertyList; + + #[cfg(feature = "grin_enable_edge_primary_keys")] + #[allow(unused)] + pub fn grin_get_edge_primary_keys_row(arg1: GrinGraph, arg2: GrinEdge) -> GrinRow; + + #[allow(unused)] + pub fn grin_destroy_string_value(arg1: GrinGraph, arg2: *const ::std::os::raw::c_char); + + #[doc = " @brief Get the vertex property name\n @param GrinGraph The graph\n @param GrinVertexType The vertex type that the property belongs to\n @param GrinVertexProperty The vertex property\n @return The property's name as string"] + #[cfg(feature = "grin_with_vertex_property_name")] + #[allow(unused)] + pub fn grin_get_vertex_property_name( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinVertexProperty, + ) -> *const ::std::os::raw::c_char; + + #[doc = " @brief Get the vertex property with a given name under a specific vertex type\n @param GrinGraph The graph\n @param GrinVertexType The specific vertex type\n @param name The name\n @return The vertex property"] + #[cfg(feature = "grin_with_vertex_property_name")] + #[allow(unused)] + pub fn grin_get_vertex_property_by_name( + arg1: GrinGraph, + arg2: GrinVertexType, + name: *const ::std::os::raw::c_char, + ) -> GrinVertexProperty; + + #[doc = " @brief Get properties under all types with a given name.\n For example, vertex type \"person\" and \"company\" both have a property\n called \"name\". When this API is called given \"name\", it will return a list\n of \"name\" properties under both types.\n @param GrinGraph The graph\n @param name The name\n @return The vertex property list of properties with the given name"] + #[cfg(feature = "grin_with_vertex_property_name")] + #[allow(unused)] + pub fn grin_get_vertex_properties_by_name( + arg1: GrinGraph, + name: *const ::std::os::raw::c_char, + ) -> GrinVertexPropertyList; + + #[cfg(feature = "grin_with_edge_property_name")] + #[allow(unused)] + pub fn grin_get_edge_property_name( + arg1: GrinGraph, + arg2: GrinEdgeType, + arg3: GrinEdgeProperty, + ) -> *const ::std::os::raw::c_char; + + #[cfg(feature = "grin_with_edge_property_name")] + #[allow(unused)] + pub fn grin_get_edge_property_by_name( + arg1: GrinGraph, + arg2: GrinEdgeType, + name: *const ::std::os::raw::c_char, + ) -> GrinEdgeProperty; + + #[cfg(feature = "grin_with_edge_property_name")] + #[allow(unused)] + pub fn grin_get_edge_properties_by_name( + arg1: GrinGraph, + name: *const ::std::os::raw::c_char, + ) -> GrinEdgePropertyList; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_equal_vertex_property( + arg1: GrinGraph, + arg2: GrinVertexProperty, + arg3: GrinVertexProperty, + ) -> bool; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_destroy_vertex_property(arg1: GrinGraph, arg2: GrinVertexProperty); + + #[doc = " @brief Get the datatype of the vertex property\n @param GrinGraph The graph\n @param GrinVertexProperty The vertex property\n @return The datatype of the vertex property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_datatype( + arg1: GrinGraph, + arg2: GrinVertexProperty, + ) -> GrinDatatype; + + #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_int32( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> i32; + + #[doc = " @brief Get the value of uint32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_uint32( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> u32; + + #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_int64( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> i64; + + #[doc = " @brief Get the value of uint64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_uint64( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> u64; + + #[doc = " @brief Get the value of float, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype float.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_float( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> f32; + + #[doc = " @brief Get the value of double, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype double.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_double( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> f64; + + #[doc = " @brief Get the value of string, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype string.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_string( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> *const ::std::os::raw::c_char; + + #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype date32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_date32( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> i32; + + #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype time32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_time32( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> i32; + + #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype timestamp64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_value_of_timestamp64( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> i64; + + #[doc = " @brief Get the vertex type that a given vertex property belongs to.\n @param GrinGraph The graph\n @param GrinVertexProperty The vertex property\n @return The vertex type"] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_type_from_property( + arg1: GrinGraph, + arg2: GrinVertexProperty, + ) -> GrinVertexType; + + #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_trait_const_value_ptr"))] + #[allow(unused)] + pub fn grin_get_vertex_property_value( + arg1: GrinGraph, + arg2: GrinVertex, + arg3: GrinVertexProperty, + ) -> *const ::std::os::raw::c_void; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_equal_edge_property( + arg1: GrinGraph, + arg2: GrinEdgeProperty, + arg3: GrinEdgeProperty, + ) -> bool; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_destroy_edge_property(arg1: GrinGraph, arg2: GrinEdgeProperty); + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_datatype( + arg1: GrinGraph, + arg2: GrinEdgeProperty, + ) -> GrinDatatype; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_int32( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> i32; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_uint32( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> u32; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_int64( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> i64; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_uint64( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> u64; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_float( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> f32; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_double( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> f64; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_string( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> *const ::std::os::raw::c_char; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_date32( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> i32; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_time32( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> i32; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_value_of_timestamp64( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> i64; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_type_from_property( + arg1: GrinGraph, + arg2: GrinEdgeProperty, + ) -> GrinEdgeType; + + #[cfg(all(feature = "grin_with_edge_property", feature = "grin_trait_const_value_ptr"))] + #[allow(unused)] + pub fn grin_get_edge_property_value( + arg1: GrinGraph, + arg2: GrinEdge, + arg3: GrinEdgeProperty, + ) -> *const ::std::os::raw::c_void; + + #[doc = " @brief Get the vertex property list of the graph.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @return The vertex property list."] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_list_by_type( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> GrinVertexPropertyList; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_list_size( + arg1: GrinGraph, + arg2: GrinVertexPropertyList, + ) -> usize; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_from_list( + arg1: GrinGraph, + arg2: GrinVertexPropertyList, + arg3: usize, + ) -> GrinVertexProperty; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_create_vertex_property_list(arg1: GrinGraph) -> GrinVertexPropertyList; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_destroy_vertex_property_list(arg1: GrinGraph, arg2: GrinVertexPropertyList); + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_insert_vertex_property_to_list( + arg1: GrinGraph, + arg2: GrinVertexPropertyList, + arg3: GrinVertexProperty, + ) -> bool; + + #[doc = " @brief Get the vertex property handle by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @param GrinVertexPropertyId The vertex property id.\n @return The vertex property handle."] + #[cfg(feature = "grin_trait_natural_id_for_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_by_id( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinVertexPropertyId, + ) -> GrinVertexProperty; + + #[doc = " @brief Get the vertex property's natural id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @param GrinVertexProperty The vertex property handle.\n @return The vertex property id."] + #[cfg(feature = "grin_trait_natural_id_for_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_property_id( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinVertexProperty, + ) -> GrinVertexPropertyId; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_list_by_type( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> GrinEdgePropertyList; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_list_size( + arg1: GrinGraph, + arg2: GrinEdgePropertyList, + ) -> usize; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_from_list( + arg1: GrinGraph, + arg2: GrinEdgePropertyList, + arg3: usize, + ) -> GrinEdgeProperty; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_create_edge_property_list(arg1: GrinGraph) -> GrinEdgePropertyList; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_destroy_edge_property_list(arg1: GrinGraph, arg2: GrinEdgePropertyList); + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_insert_edge_property_to_list( + arg1: GrinGraph, + arg2: GrinEdgePropertyList, + arg3: GrinEdgeProperty, + ) -> bool; + + #[cfg(feature = "grin_trait_natural_id_for_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_by_id( + arg1: GrinGraph, + arg2: GrinEdgeType, + arg3: GrinEdgePropertyId, + ) -> GrinEdgeProperty; + + #[doc = " We must specify the edge type here, because the edge property id is unique only under a specific edge type"] + #[cfg(feature = "grin_trait_natural_id_for_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_property_id( + arg1: GrinGraph, + arg2: GrinEdgeType, + arg3: GrinEdgeProperty, + ) -> GrinEdgePropertyId; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_destroy_row(arg1: GrinGraph, arg2: GrinRow); + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_int32_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> i32; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_uint32_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> u32; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_int64_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> i64; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_uint64_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> u64; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_float_from_row(arg1: GrinGraph, arg2: GrinRow, arg3: usize) -> f32; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_double_from_row(arg1: GrinGraph, arg2: GrinRow, arg3: usize) -> f64; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_string_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> *const ::std::os::raw::c_char; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_date32_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> i32; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_time32_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> i32; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_get_timestamp64_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: usize, + ) -> i64; + + #[doc = " @brief Create a row.\n Row works as carrier of property values in GRIN.\n It is a pure value array, and users can only get the value by the array index.\n That means users should understand the property that each value is\n representing when using the row.\n Currently rows are used in two scenarios:\n 1. Users can create a row of values for primary keys properties,\n and then query the vertex/edge using the row if pk indexing is enabled.\n 2. Users can get the row of values for the entire property list of\n a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``.\n However this API is not recommended if the user only wants to get the\n properties values, in which case, the user can get property values\n one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``."] + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_create_row(arg1: GrinGraph) -> GrinRow; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_int32_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: i32, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_uint32_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: u32, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_int64_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: i64, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_uint64_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: u64, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_float_to_row(arg1: GrinGraph, arg2: GrinRow, arg3: f32) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_double_to_row(arg1: GrinGraph, arg2: GrinRow, arg3: f64) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_string_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: *const ::std::os::raw::c_char, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_date32_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: i32, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_time32_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: i32, + ) -> bool; + + #[cfg(feature = "grin_enable_row")] + #[allow(unused)] + pub fn grin_insert_timestamp64_to_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: i64, + ) -> bool; + + #[cfg(all(feature = "grin_enable_row", feature = "grin_trait_const_value_ptr"))] + #[allow(unused)] + pub fn grin_get_value_from_row( + arg1: GrinGraph, + arg2: GrinRow, + arg3: GrinDatatype, + arg4: usize, + ) -> *const ::std::os::raw::c_void; + + #[doc = " @brief Get row of values for the entire property list of a vertex.\n Later users can get property values from the row using APIs like\n ``grin_get_int32_from_row``.\n However this two-step value getting is not recommended if the user\n only wants to get the value of one property, in which case, the user\n should use APIs like ``grin_get_vertex_property_value_of_int32``.\n @param GrinGraph The graph\n @param GrinVertex The vertex"] + #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_enable_row"))] + #[allow(unused)] + pub fn grin_get_vertex_row(arg1: GrinGraph, arg2: GrinVertex) -> GrinRow; + + #[cfg(all(feature = "grin_with_edge_property", feature = "grin_enable_row"))] + #[allow(unused)] + pub fn grin_get_edge_row(arg1: GrinGraph, arg2: GrinEdge) -> GrinRow; + + #[doc = " @brief Get the vertex number of a given type in the graph.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex number."] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_num_by_type(arg1: GrinGraph, arg2: GrinVertexType) -> usize; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_num_by_type(arg1: GrinGraph, arg2: GrinEdgeType) -> usize; + + #[doc = " @brief Get the vertex list of a given type.\n This API is only available for property graph.\n To get a vertex list chain of all types, using APIs in GRIN extension.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex list of the given type."] + #[cfg(all(feature = "grin_enable_vertex_list", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_list_by_type( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> GrinVertexList; + + #[cfg(all(feature = "grin_enable_edge_list", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_edge_list_by_type(arg1: GrinGraph, arg2: GrinEdgeType) -> GrinEdgeList; + + #[doc = " @brief Get the adjacent list of given direction, vertex and edge type.\n This API is only available for property graph.\n To get a adjacent list chain of all types, using APIs in GRIN extension.\n @param GrinGraph The graph.\n @param GrinDirection The direction of the adjacent list.\n @param GrinVertex The vertex.\n @return The adjacent list."] + #[cfg(all(feature = "grin_enable_adjacent_list", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_adjacent_list_by_edge_type( + arg1: GrinGraph, + arg2: GrinDirection, + arg3: GrinVertex, + arg4: GrinEdgeType, + ) -> GrinAdjacentList; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_equal_vertex_type( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinVertexType, + ) -> bool; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_type(arg1: GrinGraph, arg2: GrinVertex) -> GrinVertexType; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_destroy_vertex_type(arg1: GrinGraph, arg2: GrinVertexType); + + #[doc = " @brief Get the vertex type list of the graph\n This API is only available for property graph.\n It lists all the vertex types in the graph.\n @param GrinGraph The graph.\n @return The vertex type list."] + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_type_list(arg1: GrinGraph) -> GrinVertexTypeList; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_destroy_vertex_type_list(arg1: GrinGraph, arg2: GrinVertexTypeList); + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_create_vertex_type_list(arg1: GrinGraph) -> GrinVertexTypeList; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_insert_vertex_type_to_list( + arg1: GrinGraph, + arg2: GrinVertexTypeList, + arg3: GrinVertexType, + ) -> bool; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_type_list_size(arg1: GrinGraph, arg2: GrinVertexTypeList) -> usize; + + #[cfg(feature = "grin_with_vertex_property")] + #[allow(unused)] + pub fn grin_get_vertex_type_from_list( + arg1: GrinGraph, + arg2: GrinVertexTypeList, + arg3: usize, + ) -> GrinVertexType; + + #[doc = " @brief Get the vertex type name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex type name of string."] + #[cfg(feature = "grin_with_vertex_type_name")] + #[allow(unused)] + pub fn grin_get_vertex_type_name( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> *const ::std::os::raw::c_char; + + #[doc = " @brief Get the vertex type by name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GrinGraph The graph.\n @param name The vertex type name.\n @return The vertex type."] + #[cfg(feature = "grin_with_vertex_type_name")] + #[allow(unused)] + pub fn grin_get_vertex_type_by_name( + arg1: GrinGraph, + name: *const ::std::os::raw::c_char, + ) -> GrinVertexType; + + #[doc = " @brief Get the vertex type id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex type id."] + #[cfg(feature = "grin_trait_natural_id_for_vertex_type")] + #[allow(unused)] + pub fn grin_get_vertex_type_id(arg1: GrinGraph, arg2: GrinVertexType) + -> GrinVertexTypeId; + + #[doc = " @brief Get the vertex type by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GrinGraph The graph.\n @param GrinVertexTypeId The vertex type id.\n @return The vertex type."] + #[cfg(feature = "grin_trait_natural_id_for_vertex_type")] + #[allow(unused)] + pub fn grin_get_vertex_type_by_id( + arg1: GrinGraph, + arg2: GrinVertexTypeId, + ) -> GrinVertexType; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_equal_edge_type( + arg1: GrinGraph, + arg2: GrinEdgeType, + arg3: GrinEdgeType, + ) -> bool; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_type(arg1: GrinGraph, arg2: GrinEdge) -> GrinEdgeType; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_destroy_edge_type(arg1: GrinGraph, arg2: GrinEdgeType); + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_type_list(arg1: GrinGraph) -> GrinEdgeTypeList; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_destroy_edge_type_list(arg1: GrinGraph, arg2: GrinEdgeTypeList); + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_create_edge_type_list(arg1: GrinGraph) -> GrinEdgeTypeList; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_insert_edge_type_to_list( + arg1: GrinGraph, + arg2: GrinEdgeTypeList, + arg3: GrinEdgeType, + ) -> bool; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_type_list_size(arg1: GrinGraph, arg2: GrinEdgeTypeList) -> usize; + + #[cfg(feature = "grin_with_edge_property")] + #[allow(unused)] + pub fn grin_get_edge_type_from_list( + arg1: GrinGraph, + arg2: GrinEdgeTypeList, + arg3: usize, + ) -> GrinEdgeType; + + #[cfg(feature = "grin_with_edge_type_name")] + #[allow(unused)] + pub fn grin_get_edge_type_name( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> *const ::std::os::raw::c_char; + + #[cfg(feature = "grin_with_edge_type_name")] + #[allow(unused)] + pub fn grin_get_edge_type_by_name( + arg1: GrinGraph, + arg2: *const ::std::os::raw::c_char, + ) -> GrinEdgeType; + + #[cfg(feature = "grin_trait_natural_id_for_edge_type")] + #[allow(unused)] + pub fn grin_get_edge_type_id(arg1: GrinGraph, arg2: GrinEdgeType) -> GrinEdgeTypeId; + + #[cfg(feature = "grin_trait_natural_id_for_edge_type")] + #[allow(unused)] + pub fn grin_get_edge_type_by_id(arg1: GrinGraph, arg2: GrinEdgeTypeId) -> GrinEdgeType; + + #[doc = " @brief Get source vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GrinGraph The graph.\n @param GrinEdgeType The edge type.\n @return The vertex type list of source."] + #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_src_types_by_edge_type( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> GrinVertexTypeList; + + #[doc = " @brief Get destination vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GrinGraph The graph.\n @param GrinEdgeType The edge type.\n @return The vertex type list of destination."] + #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_dst_types_by_edge_type( + arg1: GrinGraph, + arg2: GrinEdgeType, + ) -> GrinVertexTypeList; + + #[doc = " @brief Get edge types related to a pair of vertex types.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n @param GrinGraph The graph.\n @param GrinVertexType The source vertex type.\n @param GrinVertexType The destination vertex type.\n @return The related edge type list."] + #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_with_edge_property"))] + #[allow(unused)] + pub fn grin_get_edge_types_by_vertex_type_pair( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinVertexType, + ) -> GrinEdgeTypeList; + + #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] + #[allow(unused)] + pub fn grin_get_label_by_name( + arg1: GrinGraph, + arg2: *const ::std::os::raw::c_char, + ) -> GrinLabel; + + #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] + #[allow(unused)] + pub fn grin_destroy_label(arg1: GrinGraph, arg2: GrinLabel); + + #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] + #[allow(unused)] + pub fn grin_get_label_name(arg1: GrinGraph, arg2: GrinLabel) + -> *const ::std::os::raw::c_char; + + #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] + #[allow(unused)] + pub fn grin_destroy_label_list(arg1: GrinGraph, arg2: GrinLabelList); + + #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] + #[allow(unused)] + pub fn grin_get_label_list_size(arg1: GrinGraph, arg2: GrinLabelList) -> usize; + + #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] + #[allow(unused)] + pub fn grin_get_label_from_list( + arg1: GrinGraph, + arg2: GrinLabelList, + arg3: usize, + ) -> GrinLabel; + + #[doc = " @brief assign a label to a vertex\n @param GrinGraph the graph\n @param GrinLabel the label\n @param GrinVertex the vertex\n @return whether succeed"] + #[cfg(feature = "grin_with_vertex_label")] + #[allow(unused)] + pub fn grin_assign_label_to_vertex( + arg1: GrinGraph, + arg2: GrinLabel, + arg3: GrinVertex, + ) -> bool; + + #[doc = " @brief get the label list of a vertex\n @param GrinGraph the graph\n @param GrinVertex the vertex"] + #[cfg(feature = "grin_with_vertex_label")] + #[allow(unused)] + pub fn grin_get_vertex_label_list(arg1: GrinGraph, arg2: GrinVertex) -> GrinLabelList; + + #[doc = " @brief get the vertex list by label\n @param GrinGraph the graph\n @param GrinLabel the label"] + #[cfg(feature = "grin_with_vertex_label")] + #[allow(unused)] + pub fn grin_get_vertex_list_by_label(arg1: GrinGraph, arg2: GrinLabel) -> GrinVertexList; + + #[doc = " @brief filtering an existing vertex list by label\n @param GrinVertexList the existing vertex list\n @param GrinLabel the label"] + #[cfg(feature = "grin_with_vertex_label")] + #[allow(unused)] + pub fn grin_select_label_for_vertex_list( + arg1: GrinGraph, + arg2: GrinLabel, + arg3: GrinVertexList, + ) -> GrinVertexList; + + #[doc = " @brief assign a label to a edge\n @param GrinGraph the graph\n @param GrinLabel the label\n @param GrinEdge the edge\n @return whether succeed"] + #[cfg(feature = "grin_with_edge_label")] + #[allow(unused)] + pub fn grin_assign_label_to_edge(arg1: GrinGraph, arg2: GrinLabel, arg3: GrinEdge) -> bool; + + #[doc = " @brief get the label list of a edge\n @param GrinGraph the graph\n @param GrinEdge the edge"] + #[cfg(feature = "grin_with_edge_label")] + #[allow(unused)] + pub fn grin_get_edge_label_list(arg1: GrinGraph, arg2: GrinEdge) -> GrinLabelList; + + #[doc = " @brief get the edge list by label\n @param GrinGraph the graph\n @param GrinLabel the label"] + #[cfg(feature = "grin_with_edge_label")] + #[allow(unused)] + pub fn grin_get_edge_list_by_label(arg1: GrinGraph, arg2: GrinLabel) -> GrinEdgeList; + + #[doc = " @brief filtering an existing edge list by label\n @param GrinEdgeList the existing edge list\n @param GrinLabel the label"] + #[cfg(feature = "grin_with_edge_label")] + #[allow(unused)] + pub fn grin_select_label_for_edge_list( + arg1: GrinGraph, + arg2: GrinLabel, + arg3: GrinEdgeList, + ) -> GrinEdgeList; + + #[cfg(feature = "grin_assume_all_vertex_list_sorted")] + #[allow(unused)] + pub fn grin_smaller_vertex(arg1: GrinGraph, arg2: GrinVertex, arg3: GrinVertex) -> bool; + + #[doc = " @brief Get the position of a vertex in a sorted list\n caller must guarantee the input vertex list is sorted to get the correct result\n @param GrinGraph The graph\n @param GrinVertexList The sorted vertex list\n @param GrinVertex The vertex to find\n @return The position of the vertex"] + #[cfg(all(feature = "grin_assume_all_vertex_list_sorted", feature = "grin_enable_vertex_list_array"))] + #[allow(unused)] + pub fn grin_get_position_of_vertex_from_sorted_list( + arg1: GrinGraph, + arg2: GrinVertexList, + arg3: GrinVertex, + ) -> usize; + + #[doc = " @brief Get the int64 internal id of a vertex\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @return The int64 internal id of the vertex"] + #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_internal_id_by_type( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinVertex, + ) -> i64; + + #[doc = " @brief Get the vertex by internal id under type\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @param id The internal id of the vertex under type\n @return The vertex"] + #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_by_internal_id_by_type( + arg1: GrinGraph, + arg2: GrinVertexType, + id: i64, + ) -> GrinVertex; + + #[doc = " @brief Get the upper bound of internal id under type.\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @return The upper bound of internal id under type"] + #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_internal_id_upper_bound_by_type( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> i64; + + #[doc = " @brief Get the lower bound internal id under type.\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @return The lower bound internal id under type"] + #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] + #[allow(unused)] + pub fn grin_get_vertex_internal_id_lower_bound_by_type( + arg1: GrinGraph, + arg2: GrinVertexType, + ) -> i64; + + #[doc = " @brief Get the vertex by primary keys row.\n The values in the row must be in the same order as the primary keys\n properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @param GrinRow The values row of primary keys properties.\n @return The vertex."] + #[cfg(all(feature = "grin_enable_vertex_pk_index", feature = "grin_enable_vertex_primary_keys"))] + #[allow(unused)] + pub fn grin_get_vertex_by_primary_keys_row( + arg1: GrinGraph, + arg2: GrinVertexType, + arg3: GrinRow, + ) -> GrinVertex; + + #[cfg(all(feature = "grin_enable_edge_pk_index", feature = "grin_enable_edge_primary_keys"))] + #[allow(unused)] + pub fn grin_get_edge_by_primary_keys_row( + arg1: GrinGraph, + arg2: GrinEdgeType, + arg3: GrinRow, + ) -> GrinEdge; + + pub static mut grin_error_code: GrinErrorCode; + + #[doc = " @brief Get the last error code.\n The error code is thread local.\n Currently users only need to check the error code when using\n getting-value APIs whose return has no predefined invalid value."] + #[allow(unused)] + pub fn grin_get_last_error_code() -> GrinErrorCode; + + #[doc = " @brief Get the static feature prototype message of the storage.\n This proto describes the features of the storage, such as whether\n it supports property graph or partitioned graph.\n @return The serialized proto message."] + #[allow(unused)] + pub fn grin_get_static_storage_feature_msg() -> *const ::std::os::raw::c_char; +} diff --git a/flex/engines/graph_db/grin/include/rust/grin_all.h b/flex/engines/graph_db/grin/include/rust/grin_all.h new file mode 100644 index 000000000000..234b2eb7c7f1 --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/grin_all.h @@ -0,0 +1,83 @@ +#define GRIN_FEATURES_ENABLE_ALL +#define GRIN_RUST_CODEGEN + +#include "template/predefine.h" +#include "topology/adjacentlist.h" +#include "topology/edgelist.h" +#include "topology/structure.h" +#include "topology/vertexlist.h" +#include "partition/partition.h" +#include "partition/reference.h" +#include "partition/topology.h" +#include "property/partition.h" +#include "property/primarykey.h" +#include "property/property.h" +#include "property/propertylist.h" +#include "property/row.h" +#include "property/topology.h" +#include "property/type.h" +#include "index/label.h" +#include "index/order.h" +#include "index/internal_id.h" +#include "index/pk.h" +#include "common/error.h" +#include "common/message.h" + +#ifdef GRIN_RUST_CODEGEN +/// GRIN_FEATURES_ENABLE_ALL +/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; +/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_DATA: GrinVertexData = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_DATA: GrinEdgeData = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_LABEL: GrinLabel = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX; +int __rust_keep_grin_null; +#endif + +/// GRIN_V6D +/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; +/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_LIST: *mut ::std::os::raw::c_void = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_LIST_ITERATOR: *mut ::std::os::raw::c_void = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX; +/// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_NATURAL_ID: u32 = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX; +///int __rust_keep_grin_null_v6d; \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/rust/grin_all.rs b/flex/engines/graph_db/grin/include/rust/grin_all.rs new file mode 100644 index 000000000000..0b06ea2694c3 --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/grin_all.rs @@ -0,0 +1,1368 @@ +/* automatically generated by rust-bindgen 0.64.0 */ + +pub const true_: u32 = 1; +pub const false_: u32 = 0; +pub const __bool_true_false_are_defined: u32 = 1; +pub type wchar_t = ::std::os::raw::c_int; +pub type max_align_t = u128; +#[doc = "< incoming"] +pub const GRIN_DIRECTION_IN: GRIN_DIRECTION = 0; +#[doc = "< outgoing"] +pub const GRIN_DIRECTION_OUT: GRIN_DIRECTION = 1; +#[doc = "< incoming & outgoing"] +pub const GRIN_DIRECTION_BOTH: GRIN_DIRECTION = 2; +#[doc = " Enumerates the directions of edges with respect to a certain vertex"] +pub type GRIN_DIRECTION = ::std::os::raw::c_uint; +#[doc = "< other unknown types"] +pub const GRIN_DATATYPE_Undefined: GRIN_DATATYPE = 0; +#[doc = "< int"] +pub const GRIN_DATATYPE_Int32: GRIN_DATATYPE = 1; +#[doc = "< unsigned int"] +pub const GRIN_DATATYPE_UInt32: GRIN_DATATYPE = 2; +#[doc = "< long int"] +pub const GRIN_DATATYPE_Int64: GRIN_DATATYPE = 3; +#[doc = "< unsigned long int"] +pub const GRIN_DATATYPE_UInt64: GRIN_DATATYPE = 4; +#[doc = "< float"] +pub const GRIN_DATATYPE_Float: GRIN_DATATYPE = 5; +#[doc = "< double"] +pub const GRIN_DATATYPE_Double: GRIN_DATATYPE = 6; +#[doc = "< string"] +pub const GRIN_DATATYPE_String: GRIN_DATATYPE = 7; +#[doc = "< date"] +pub const GRIN_DATATYPE_Date32: GRIN_DATATYPE = 8; +#[doc = "< Time32"] +pub const GRIN_DATATYPE_Time32: GRIN_DATATYPE = 9; +#[doc = "< Timestamp"] +pub const GRIN_DATATYPE_Timestamp64: GRIN_DATATYPE = 10; +#[doc = " Enumerates the datatype supported in the storage"] +pub type GRIN_DATATYPE = ::std::os::raw::c_uint; +#[doc = "< success"] +pub const GRIN_ERROR_CODE_NO_ERROR: GRIN_ERROR_CODE = 0; +#[doc = "< unknown error"] +pub const GRIN_ERROR_CODE_UNKNOWN_ERROR: GRIN_ERROR_CODE = 1; +#[doc = "< invalid value"] +pub const GRIN_ERROR_CODE_INVALID_VALUE: GRIN_ERROR_CODE = 2; +#[doc = "< unknown datatype"] +pub const GRIN_ERROR_CODE_UNKNOWN_DATATYPE: GRIN_ERROR_CODE = 3; +#[doc = " Enumerates the error codes of grin"] +pub type GRIN_ERROR_CODE = ::std::os::raw::c_uint; +pub type GRIN_GRAPH = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_DATA = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void; +pub type GRIN_ADJACENT_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_DATA = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_LIST_ITERATOR = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITION = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint; +pub type GRIN_VERTEX_REF = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_REF = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_TYPE = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_PROPERTY = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint; +pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint; +pub type GRIN_EDGE_TYPE = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VEV_TYPE = *mut ::std::os::raw::c_void; +pub type GRIN_VEV_TYPE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_PROPERTY = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint; +pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint; +pub type GRIN_ROW = *mut ::std::os::raw::c_void; +pub type GRIN_LABEL = *mut ::std::os::raw::c_void; +pub type GRIN_LABEL_LIST = *mut ::std::os::raw::c_void; +extern "C" { + pub fn grin_destroy_adjacent_list(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST); +} +extern "C" { + pub fn grin_get_adjacent_list_size(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST) -> usize; +} +extern "C" { + #[doc = " @brief Get the neighbor vertex from the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST The adjacent list.\n @param index The index of the edge to/from the neighbor in the adjacent list.\n @return The neighbor vertex."] + pub fn grin_get_neighbor_from_adjacent_list( + arg1: GRIN_GRAPH, + arg2: GRIN_ADJACENT_LIST, + index: usize, + ) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief Get the edge from the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST The adjacent list.\n @param index The index of the edge in the adjacent list.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] + pub fn grin_get_edge_from_adjacent_list( + arg1: GRIN_GRAPH, + arg2: GRIN_ADJACENT_LIST, + arg3: usize, + ) -> GRIN_EDGE; +} +extern "C" { + #[doc = " @brief Get the begin iterator of the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST The adjacent list.\n @return The begin iterator of the adjacent list."] + pub fn grin_get_adjacent_list_begin( + arg1: GRIN_GRAPH, + arg2: GRIN_ADJACENT_LIST, + ) -> GRIN_ADJACENT_LIST_ITERATOR; +} +extern "C" { + pub fn grin_destroy_adjacent_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST_ITERATOR); +} +extern "C" { + #[doc = " @brief Update the iterator to the next of the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator to be updated."] + pub fn grin_get_next_adjacent_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST_ITERATOR); +} +extern "C" { + #[doc = " @brief Check if the adjacent list iterator is at the end.\n Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin``\n if the adjacent list is empty.\n Users should check if the iterator is at the end before using it.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.\n @return True if the iterator is at the end, otherwise false."] + pub fn grin_is_adjacent_list_end(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST_ITERATOR) -> bool; +} +extern "C" { + #[doc = " @brief Get the neighbor vertex from the adjacent list iterator.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.\n @return The neighbor vertex."] + pub fn grin_get_neighbor_from_adjacent_list_iter( + arg1: GRIN_GRAPH, + arg2: GRIN_ADJACENT_LIST_ITERATOR, + ) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief Get the edge from the adjacent list iterator.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] + pub fn grin_get_edge_from_adjacent_list_iter( + arg1: GRIN_GRAPH, + arg2: GRIN_ADJACENT_LIST_ITERATOR, + ) -> GRIN_EDGE; +} +extern "C" { + pub fn grin_destroy_edge_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST); +} +extern "C" { + pub fn grin_get_edge_list_size(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST) -> usize; +} +extern "C" { + pub fn grin_get_edge_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_LIST, + arg3: usize, + ) -> GRIN_EDGE; +} +extern "C" { + pub fn grin_get_edge_list_begin( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_LIST, + ) -> GRIN_EDGE_LIST_ITERATOR; +} +extern "C" { + pub fn grin_destroy_edge_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR); +} +extern "C" { + pub fn grin_get_next_edge_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR); +} +extern "C" { + pub fn grin_is_edge_list_end(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR) -> bool; +} +extern "C" { + pub fn grin_get_edge_from_iter(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR) -> GRIN_EDGE; +} +extern "C" { + #[doc = " @brief Get a (non-partitioned) graph from storage\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A graph handle."] + pub fn grin_get_graph_from_storage(arg1: *const ::std::os::raw::c_char) -> GRIN_GRAPH; +} +extern "C" { + pub fn grin_destroy_graph(arg1: GRIN_GRAPH); +} +extern "C" { + #[doc = " @brief Check if the graph is directed.\n This API is only available when the storage supports both directed and\n undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH``\n and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined.\n @param GRIN_GRAPH The graph.\n @return True if the graph is directed, otherwise false."] + pub fn grin_is_directed(arg1: GRIN_GRAPH) -> bool; +} +extern "C" { + #[doc = " @brief Check if the graph is a multigraph.\n This API is only available when the storage supports multigraph.\n @param GRIN_GRAPH The graph.\n @return True if the graph is a multigraph, otherwise false."] + pub fn grin_is_multigraph(arg1: GRIN_GRAPH) -> bool; +} +extern "C" { + pub fn grin_destroy_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX); +} +extern "C" { + pub fn grin_equal_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX, arg3: GRIN_VERTEX) -> bool; +} +extern "C" { + pub fn grin_get_vertex_data_datatype(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_DATATYPE; +} +extern "C" { + pub fn grin_get_vertex_data_value( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + ) -> *const ::std::os::raw::c_void; +} +extern "C" { + pub fn grin_destroy_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE); +} +extern "C" { + #[doc = " @brief Get the source vertex of an edge.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE The edge.\n @return The source vertex of the edge."] + pub fn grin_get_src_vertex_from_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief Get the destination vertex of an edge.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE The edge.\n @return The destination vertex of the edge."] + pub fn grin_get_dst_vertex_from_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_VERTEX; +} +extern "C" { + pub fn grin_get_edge_data_datatype(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_DATATYPE; +} +extern "C" { + pub fn grin_get_edge_data_value( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + ) -> *const ::std::os::raw::c_void; +} +extern "C" { + pub fn grin_destroy_vertex_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST); +} +extern "C" { + pub fn grin_get_vertex_list_size(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST) -> usize; +} +extern "C" { + #[doc = " @brief Get the vertex from the vertex list.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST The vertex list.\n @param index The index of the vertex in the vertex list.\n @return The vertex."] + pub fn grin_get_vertex_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_LIST, + index: usize, + ) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief Get the begin iterator of the vertex list.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST The vertex list.\n @return The begin iterator."] + pub fn grin_get_vertex_list_begin( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_LIST, + ) -> GRIN_VERTEX_LIST_ITERATOR; +} +extern "C" { + pub fn grin_destroy_vertex_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST_ITERATOR); +} +extern "C" { + #[doc = " @brief Update the iterator to the next of the vertex list.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST_ITERATOR The iterator to be updated."] + pub fn grin_get_next_vertex_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST_ITERATOR); +} +extern "C" { + #[doc = " @brief Check whether the iterator reaches the end of the vertex list.\n Note that we may get an end iterator when calling ``grin_get_vertex_list_begin``\n if the vertex list is empty.\n Users should check if the iterator is at the end before using it.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST_ITERATOR The iterator.\n @return True if the iterator reaches the end of the vertex list."] + pub fn grin_is_vertex_list_end(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST_ITERATOR) -> bool; +} +extern "C" { + #[doc = " @brief Get the vertex from the iterator.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST_ITERATOR The iterator.\n @return The vertex."] + pub fn grin_get_vertex_from_iter( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_LIST_ITERATOR, + ) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief Get a partitioned graph from a storage.\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A partitioned graph handle."] + pub fn grin_get_partitioned_graph_from_storage( + uri: *const ::std::os::raw::c_char, + ) -> GRIN_PARTITIONED_GRAPH; +} +extern "C" { + pub fn grin_destroy_partitioned_graph(arg1: GRIN_PARTITIONED_GRAPH); +} +extern "C" { + pub fn grin_get_total_partitions_number(arg1: GRIN_PARTITIONED_GRAPH) -> usize; +} +extern "C" { + #[doc = " @brief Get the local partition list of the partitioned graph.\n For example, a graph may be partitioned into 6 partitions and located in\n 2 machines, then each machine may contain a local partition list of size 3.\n @param GRIN_PARTITIONED_GRAPH The partitioned graph.\n @return A partition list of local partitions."] + pub fn grin_get_local_partition_list(arg1: GRIN_PARTITIONED_GRAPH) -> GRIN_PARTITION_LIST; +} +extern "C" { + pub fn grin_destroy_partition_list(arg1: GRIN_PARTITIONED_GRAPH, arg2: GRIN_PARTITION_LIST); +} +extern "C" { + pub fn grin_create_partition_list(arg1: GRIN_PARTITIONED_GRAPH) -> GRIN_PARTITION_LIST; +} +extern "C" { + pub fn grin_insert_partition_to_list( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION_LIST, + arg3: GRIN_PARTITION, + ) -> bool; +} +extern "C" { + pub fn grin_get_partition_list_size( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION_LIST, + ) -> usize; +} +extern "C" { + pub fn grin_get_partition_from_list( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION_LIST, + arg3: usize, + ) -> GRIN_PARTITION; +} +extern "C" { + pub fn grin_equal_partition( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION, + arg3: GRIN_PARTITION, + ) -> bool; +} +extern "C" { + pub fn grin_destroy_partition(arg1: GRIN_PARTITIONED_GRAPH, arg2: GRIN_PARTITION); +} +extern "C" { + pub fn grin_get_partition_info( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION, + ) -> *const ::std::os::raw::c_void; +} +extern "C" { + #[doc = " @brief Get a local graph of the partitioned graph.\n @param GRIN_PARTITIONED_GRAPH The partitioned graph.\n @param GRIN_PARTITION The partition of the graph.\n @return A local graph."] + pub fn grin_get_local_graph_by_partition( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION, + ) -> GRIN_GRAPH; +} +extern "C" { + pub fn grin_get_partition_by_id( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION_ID, + ) -> GRIN_PARTITION; +} +extern "C" { + pub fn grin_get_partition_id( + arg1: GRIN_PARTITIONED_GRAPH, + arg2: GRIN_PARTITION, + ) -> GRIN_PARTITION_ID; +} +extern "C" { + #[doc = " @brief Get the vertex ref of a vertex.\n A vertex ref is a reference for a \"local\" vertex, and the reference can\n be recognized by other partitions.\n To transfer the vertex ref handle between partitions, users should\n first call serialization methods to serialize the vertex ref handle\n into string or int64 based on the storage's features;\n then send the messages to remote partitions and deserialize the string or\n int64 remotely to get the vertex ref handle on the remote partition;\n finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle\n on the remote partition.\n These two vertices should represent the same vertex in the partitioned graph.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @return The vertex ref"] + pub fn grin_get_vertex_ref_by_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_VERTEX_REF; +} +extern "C" { + pub fn grin_destroy_vertex_ref(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_REF); +} +extern "C" { + #[doc = " @brief get the local vertex handle from the vertex ref handle\n if the vertex ref handle is not recognized, a null vertex is returned\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref\n @return The vertex handle"] + pub fn grin_get_vertex_from_vertex_ref(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_REF) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief get the master partition of a vertex ref.\n Some storage can still provide the master partition of the vertex ref,\n even if the vertex ref can NOT be recognized locally.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref"] + pub fn grin_get_master_partition_from_vertex_ref( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_REF, + ) -> GRIN_PARTITION; +} +extern "C" { + #[doc = " @brief serialize the vertex ref handle to string\n The returned string should be freed by ``grin_destroy_serialized_vertex_ref``\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref"] + pub fn grin_serialize_vertex_ref( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_REF, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_destroy_serialized_vertex_ref( + arg1: GRIN_GRAPH, + arg2: *const ::std::os::raw::c_char, + ); +} +extern "C" { + #[doc = " @brief deserialize the string to vertex ref handle\n If the string is invalid, a null vertex ref is returned\n @param GRIN_GRAPH The graph\n @param msg The string message to be deserialized"] + pub fn grin_deserialize_to_vertex_ref( + arg1: GRIN_GRAPH, + msg: *const ::std::os::raw::c_char, + ) -> GRIN_VERTEX_REF; +} +extern "C" { + #[doc = " @brief check if the vertex is a master vertex\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex"] + pub fn grin_is_master_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> bool; +} +extern "C" { + #[doc = " @brief check if the vertex is a mirror vertex\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex"] + pub fn grin_is_mirror_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> bool; +} +extern "C" { + #[doc = " @brief serialize the vertex ref handle to int64\n This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref\n can be serialized into int64 instead of string.\n Obviously transferring and serializing int64 is faster than string.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref"] + pub fn grin_serialize_vertex_ref_as_int64( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_REF, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief deserialize the int64 to vertex ref handle\n @param GRIN_GRAPH The graph\n @param msg The int64 message to be deserialized"] + pub fn grin_deserialize_int64_to_vertex_ref( + arg1: GRIN_GRAPH, + msg: ::std::os::raw::c_longlong, + ) -> GRIN_VERTEX_REF; +} +extern "C" { + pub fn grin_get_master_vertex_mirror_partition_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + ) -> GRIN_PARTITION_LIST; +} +extern "C" { + pub fn grin_get_mirror_vertex_mirror_partition_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + ) -> GRIN_PARTITION_LIST; +} +extern "C" { + pub fn grin_get_edge_ref_by_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_EDGE_REF; +} +extern "C" { + pub fn grin_destroy_edge_ref(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_REF); +} +extern "C" { + pub fn grin_get_edge_from_edge_ref(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_REF) -> GRIN_EDGE; +} +extern "C" { + pub fn grin_get_master_partition_from_edge_ref( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_REF, + ) -> GRIN_PARTITION; +} +extern "C" { + pub fn grin_serialize_edge_ref( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_REF, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_destroy_serialized_edge_ref(arg1: GRIN_GRAPH, arg2: *const ::std::os::raw::c_char); +} +extern "C" { + pub fn grin_deserialize_to_edge_ref( + arg1: GRIN_GRAPH, + arg2: *const ::std::os::raw::c_char, + ) -> GRIN_EDGE_REF; +} +extern "C" { + pub fn grin_is_master_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> bool; +} +extern "C" { + pub fn grin_is_mirror_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> bool; +} +extern "C" { + pub fn grin_get_master_edge_mirror_partition_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + ) -> GRIN_PARTITION_LIST; +} +extern "C" { + pub fn grin_get_mirror_edge_mirror_partition_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + ) -> GRIN_PARTITION_LIST; +} +extern "C" { + #[doc = " @brief Get the vertex list of a given type with master vertices only.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex list of master vertices only."] + pub fn grin_get_vertex_list_by_type_select_master( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> GRIN_VERTEX_LIST; +} +extern "C" { + #[doc = " @brief Get the vertex list of a given type with mirror vertices only.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex list of mirror vertices only."] + pub fn grin_get_vertex_list_by_type_select_mirror( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> GRIN_VERTEX_LIST; +} +extern "C" { + pub fn grin_get_vertex_list_by_type_select_partition( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_PARTITION, + ) -> GRIN_VERTEX_LIST; +} +extern "C" { + pub fn grin_get_edge_list_by_type_select_master( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> GRIN_EDGE_LIST; +} +extern "C" { + pub fn grin_get_edge_list_by_type_select_mirror( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> GRIN_EDGE_LIST; +} +extern "C" { + pub fn grin_get_edge_list_by_type_select_partition( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + arg3: GRIN_PARTITION, + ) -> GRIN_EDGE_LIST; +} +extern "C" { + pub fn grin_get_adjacent_list_by_edge_type_select_master_neighbor( + arg1: GRIN_GRAPH, + arg2: GRIN_DIRECTION, + arg3: GRIN_VERTEX, + arg4: GRIN_EDGE_TYPE, + ) -> GRIN_ADJACENT_LIST; +} +extern "C" { + pub fn grin_get_adjacent_list_by_edge_type_select_mirror_neighbor( + arg1: GRIN_GRAPH, + arg2: GRIN_DIRECTION, + arg3: GRIN_VERTEX, + arg4: GRIN_EDGE_TYPE, + ) -> GRIN_ADJACENT_LIST; +} +extern "C" { + pub fn grin_get_adjacent_list_by_edge_type_select_partition_neighbor( + arg1: GRIN_GRAPH, + arg2: GRIN_DIRECTION, + arg3: GRIN_VERTEX, + arg4: GRIN_EDGE_TYPE, + arg5: GRIN_PARTITION, + ) -> GRIN_ADJACENT_LIST; +} +extern "C" { + pub fn grin_get_one_to_one_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; +} +extern "C" { + pub fn grin_get_one_to_many_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; +} +extern "C" { + pub fn grin_get_many_to_one_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; +} +extern "C" { + pub fn grin_get_many_to_many_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; +} +extern "C" { + #[doc = " @brief Get the vertex types that have primary keys\n In some graph, not every vertex type has primary keys.\n @param GRIN_GRAPH The graph\n @return The vertex type list of types that have primary keys"] + pub fn grin_get_vertex_types_with_primary_keys(arg1: GRIN_GRAPH) -> GRIN_VERTEX_TYPE_LIST; +} +extern "C" { + #[doc = " @brief Get the primary keys properties of a vertex type\n The primary keys properties are the properties that can be used to identify a vertex.\n They are a subset of the properties of a vertex type.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @return The primary keys properties list"] + pub fn grin_get_primary_keys_by_vertex_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> GRIN_VERTEX_PROPERTY_LIST; +} +extern "C" { + #[doc = " @brief Get the primary keys values row of a vertex\n The values in the row are in the same order as the primary keys properties.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @return The primary keys values row"] + pub fn grin_get_vertex_primary_keys_row(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_ROW; +} +extern "C" { + pub fn grin_get_edge_types_with_primary_keys(arg1: GRIN_GRAPH) -> GRIN_EDGE_TYPE_LIST; +} +extern "C" { + pub fn grin_get_primary_keys_by_edge_type( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> GRIN_EDGE_PROPERTY_LIST; +} +extern "C" { + pub fn grin_get_edge_primary_keys_row(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_ROW; +} +extern "C" { + pub fn grin_destroy_string_value(arg1: GRIN_GRAPH, arg2: *const ::std::os::raw::c_char); +} +extern "C" { + #[doc = " @brief Get the vertex property name\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type that the property belongs to\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The property's name as string"] + pub fn grin_get_vertex_property_name( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_VERTEX_PROPERTY, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + #[doc = " @brief Get the vertex property with a given name under a specific vertex type\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The specific vertex type\n @param name The name\n @return The vertex property"] + pub fn grin_get_vertex_property_by_name( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + name: *const ::std::os::raw::c_char, + ) -> GRIN_VERTEX_PROPERTY; +} +extern "C" { + #[doc = " @brief Get properties under all types with a given name.\n For example, vertex type \"person\" and \"company\" both have a property\n called \"name\". When this API is called given \"name\", it will return a list\n of \"name\" properties under both types.\n @param GRIN_GRAPH The graph\n @param name The name\n @return The vertex property list of properties with the given name"] + pub fn grin_get_vertex_properties_by_name( + arg1: GRIN_GRAPH, + name: *const ::std::os::raw::c_char, + ) -> GRIN_VERTEX_PROPERTY_LIST; +} +extern "C" { + pub fn grin_get_edge_property_name( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + arg3: GRIN_EDGE_PROPERTY, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_get_edge_property_by_name( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + name: *const ::std::os::raw::c_char, + ) -> GRIN_EDGE_PROPERTY; +} +extern "C" { + pub fn grin_get_edge_properties_by_name( + arg1: GRIN_GRAPH, + name: *const ::std::os::raw::c_char, + ) -> GRIN_EDGE_PROPERTY_LIST; +} +extern "C" { + pub fn grin_equal_vertex_property( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_PROPERTY, + arg3: GRIN_VERTEX_PROPERTY, + ) -> bool; +} +extern "C" { + pub fn grin_destroy_vertex_property(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_PROPERTY); +} +extern "C" { + #[doc = " @brief Get the datatype of the vertex property\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The datatype of the vertex property"] + pub fn grin_get_vertex_property_datatype( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_PROPERTY, + ) -> GRIN_DATATYPE; +} +extern "C" { + #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_int32( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " @brief Get the value of uint32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_uint32( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_uint; +} +extern "C" { + #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_int64( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief Get the value of uint64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_uint64( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_ulonglong; +} +extern "C" { + #[doc = " @brief Get the value of float, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype float.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_float( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> f32; +} +extern "C" { + #[doc = " @brief Get the value of double, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype double.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_double( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> f64; +} +extern "C" { + #[doc = " @brief Get the value of string, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype string.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_string( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype date32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_date32( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype time32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_time32( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype timestamp64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] + pub fn grin_get_vertex_property_value_of_timestamp64( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief Get the vertex type that a given vertex property belongs to.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The vertex type"] + pub fn grin_get_vertex_type_from_property( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_PROPERTY, + ) -> GRIN_VERTEX_TYPE; +} +extern "C" { + pub fn grin_get_vertex_property_value( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX, + arg3: GRIN_VERTEX_PROPERTY, + ) -> *const ::std::os::raw::c_void; +} +extern "C" { + pub fn grin_equal_edge_property( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_PROPERTY, + arg3: GRIN_EDGE_PROPERTY, + ) -> bool; +} +extern "C" { + pub fn grin_destroy_edge_property(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_PROPERTY); +} +extern "C" { + pub fn grin_get_edge_property_datatype( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_PROPERTY, + ) -> GRIN_DATATYPE; +} +extern "C" { + pub fn grin_get_edge_property_value_of_int32( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn grin_get_edge_property_value_of_uint32( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn grin_get_edge_property_value_of_int64( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn grin_get_edge_property_value_of_uint64( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_ulonglong; +} +extern "C" { + pub fn grin_get_edge_property_value_of_float( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> f32; +} +extern "C" { + pub fn grin_get_edge_property_value_of_double( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> f64; +} +extern "C" { + pub fn grin_get_edge_property_value_of_string( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_get_edge_property_value_of_date32( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn grin_get_edge_property_value_of_time32( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn grin_get_edge_property_value_of_timestamp64( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn grin_get_edge_type_from_property( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_PROPERTY, + ) -> GRIN_EDGE_TYPE; +} +extern "C" { + pub fn grin_get_edge_property_value( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE, + arg3: GRIN_EDGE_PROPERTY, + ) -> *const ::std::os::raw::c_void; +} +extern "C" { + #[doc = " @brief Get the vertex property list of the graph.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @return The vertex property list."] + pub fn grin_get_vertex_property_list_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> GRIN_VERTEX_PROPERTY_LIST; +} +extern "C" { + pub fn grin_get_vertex_property_list_size( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_PROPERTY_LIST, + ) -> usize; +} +extern "C" { + pub fn grin_get_vertex_property_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_PROPERTY_LIST, + arg3: usize, + ) -> GRIN_VERTEX_PROPERTY; +} +extern "C" { + pub fn grin_create_vertex_property_list(arg1: GRIN_GRAPH) -> GRIN_VERTEX_PROPERTY_LIST; +} +extern "C" { + pub fn grin_destroy_vertex_property_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_PROPERTY_LIST); +} +extern "C" { + pub fn grin_insert_vertex_property_to_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_PROPERTY_LIST, + arg3: GRIN_VERTEX_PROPERTY, + ) -> bool; +} +extern "C" { + #[doc = " @brief Get the vertex property handle by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @param GRIN_VERTEX_PROPERTY_ID The vertex property id.\n @return The vertex property handle."] + pub fn grin_get_vertex_property_by_id( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_VERTEX_PROPERTY_ID, + ) -> GRIN_VERTEX_PROPERTY; +} +extern "C" { + #[doc = " @brief Get the vertex property's natural id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @param GRIN_VERTEX_PROPERTY The vertex property handle.\n @return The vertex property id."] + pub fn grin_get_vertex_property_id( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_VERTEX_PROPERTY, + ) -> GRIN_VERTEX_PROPERTY_ID; +} +extern "C" { + pub fn grin_get_edge_property_list_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> GRIN_EDGE_PROPERTY_LIST; +} +extern "C" { + pub fn grin_get_edge_property_list_size( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_PROPERTY_LIST, + ) -> usize; +} +extern "C" { + pub fn grin_get_edge_property_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_PROPERTY_LIST, + arg3: usize, + ) -> GRIN_EDGE_PROPERTY; +} +extern "C" { + pub fn grin_create_edge_property_list(arg1: GRIN_GRAPH) -> GRIN_EDGE_PROPERTY_LIST; +} +extern "C" { + pub fn grin_destroy_edge_property_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_PROPERTY_LIST); +} +extern "C" { + pub fn grin_insert_edge_property_to_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_PROPERTY_LIST, + arg3: GRIN_EDGE_PROPERTY, + ) -> bool; +} +extern "C" { + pub fn grin_get_edge_property_by_id( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + arg3: GRIN_EDGE_PROPERTY_ID, + ) -> GRIN_EDGE_PROPERTY; +} +extern "C" { + #[doc = " We must specify the edge type here, because the edge property id is unique only under a specific edge type"] + pub fn grin_get_edge_property_id( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + arg3: GRIN_EDGE_PROPERTY, + ) -> GRIN_EDGE_PROPERTY_ID; +} +extern "C" { + pub fn grin_destroy_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW); +} +extern "C" { + pub fn grin_get_int32_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn grin_get_uint32_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_uint; +} +extern "C" { + pub fn grin_get_int64_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn grin_get_uint64_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_ulonglong; +} +extern "C" { + pub fn grin_get_float_from_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: usize) -> f32; +} +extern "C" { + pub fn grin_get_double_from_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: usize) -> f64; +} +extern "C" { + pub fn grin_get_string_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_get_date32_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn grin_get_time32_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn grin_get_timestamp64_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: usize, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief Create a row.\n Row works as carrier of property values in GRIN.\n It is a pure value array, and users can only get the value by the array index.\n That means users should understand the property that each value is\n representing when using the row.\n Currently rows are used in two scenarios:\n 1. Users can create a row of values for primary keys properties,\n and then query the vertex/edge using the row if pk indexing is enabled.\n 2. Users can get the row of values for the entire property list of\n a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``.\n However this API is not recommended if the user only wants to get the\n properties values, in which case, the user can get property values\n one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``."] + pub fn grin_create_row(arg1: GRIN_GRAPH) -> GRIN_ROW; +} +extern "C" { + pub fn grin_insert_int32_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_int, + ) -> bool; +} +extern "C" { + pub fn grin_insert_uint32_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_uint, + ) -> bool; +} +extern "C" { + pub fn grin_insert_int64_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_longlong, + ) -> bool; +} +extern "C" { + pub fn grin_insert_uint64_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_ulonglong, + ) -> bool; +} +extern "C" { + pub fn grin_insert_float_to_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: f32) -> bool; +} +extern "C" { + pub fn grin_insert_double_to_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: f64) -> bool; +} +extern "C" { + pub fn grin_insert_string_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: *const ::std::os::raw::c_char, + ) -> bool; +} +extern "C" { + pub fn grin_insert_date32_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_int, + ) -> bool; +} +extern "C" { + pub fn grin_insert_time32_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_int, + ) -> bool; +} +extern "C" { + pub fn grin_insert_timestamp64_to_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: ::std::os::raw::c_longlong, + ) -> bool; +} +extern "C" { + pub fn grin_get_value_from_row( + arg1: GRIN_GRAPH, + arg2: GRIN_ROW, + arg3: GRIN_DATATYPE, + arg4: usize, + ) -> *const ::std::os::raw::c_void; +} +extern "C" { + #[doc = " @brief Get row of values for the entire property list of a vertex.\n Later users can get property values from the row using APIs like\n ``grin_get_int32_from_row``.\n However this two-step value getting is not recommended if the user\n only wants to get the value of one property, in which case, the user\n should use APIs like ``grin_get_vertex_property_value_of_int32``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex"] + pub fn grin_get_vertex_row(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_ROW; +} +extern "C" { + pub fn grin_get_edge_row(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_ROW; +} +extern "C" { + #[doc = " @brief Get the vertex number of a given type in the graph.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex number."] + pub fn grin_get_vertex_num_by_type(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE) -> usize; +} +extern "C" { + pub fn grin_get_edge_num_by_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE) -> usize; +} +extern "C" { + #[doc = " @brief Get the vertex list of a given type.\n This API is only available for property graph.\n To get a vertex list chain of all types, using APIs in GRIN extension.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex list of the given type."] + pub fn grin_get_vertex_list_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> GRIN_VERTEX_LIST; +} +extern "C" { + pub fn grin_get_edge_list_by_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE) -> GRIN_EDGE_LIST; +} +extern "C" { + #[doc = " @brief Get the adjacent list of given direction, vertex and edge type.\n This API is only available for property graph.\n To get a adjacent list chain of all types, using APIs in GRIN extension.\n @param GRIN_GRAPH The graph.\n @param GRIN_DIRECTION The direction of the adjacent list.\n @param GRIN_VERTEX The vertex.\n @return The adjacent list."] + pub fn grin_get_adjacent_list_by_edge_type( + arg1: GRIN_GRAPH, + arg2: GRIN_DIRECTION, + arg3: GRIN_VERTEX, + arg4: GRIN_EDGE_TYPE, + ) -> GRIN_ADJACENT_LIST; +} +extern "C" { + pub fn grin_equal_vertex_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_VERTEX_TYPE, + ) -> bool; +} +extern "C" { + pub fn grin_get_vertex_type(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_VERTEX_TYPE; +} +extern "C" { + pub fn grin_destroy_vertex_type(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE); +} +extern "C" { + #[doc = " @brief Get the vertex type list of the graph\n This API is only available for property graph.\n It lists all the vertex types in the graph.\n @param GRIN_GRAPH The graph.\n @return The vertex type list."] + pub fn grin_get_vertex_type_list(arg1: GRIN_GRAPH) -> GRIN_VERTEX_TYPE_LIST; +} +extern "C" { + pub fn grin_destroy_vertex_type_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE_LIST); +} +extern "C" { + pub fn grin_create_vertex_type_list(arg1: GRIN_GRAPH) -> GRIN_VERTEX_TYPE_LIST; +} +extern "C" { + pub fn grin_insert_vertex_type_to_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE_LIST, + arg3: GRIN_VERTEX_TYPE, + ) -> bool; +} +extern "C" { + pub fn grin_get_vertex_type_list_size(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE_LIST) -> usize; +} +extern "C" { + pub fn grin_get_vertex_type_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE_LIST, + arg3: usize, + ) -> GRIN_VERTEX_TYPE; +} +extern "C" { + #[doc = " @brief Get the vertex type name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex type name of string."] + pub fn grin_get_vertex_type_name( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + #[doc = " @brief Get the vertex type by name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GRIN_GRAPH The graph.\n @param name The vertex type name.\n @return The vertex type."] + pub fn grin_get_vertex_type_by_name( + arg1: GRIN_GRAPH, + name: *const ::std::os::raw::c_char, + ) -> GRIN_VERTEX_TYPE; +} +extern "C" { + #[doc = " @brief Get the vertex type id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex type id."] + pub fn grin_get_vertex_type_id(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE) + -> GRIN_VERTEX_TYPE_ID; +} +extern "C" { + #[doc = " @brief Get the vertex type by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE_ID The vertex type id.\n @return The vertex type."] + pub fn grin_get_vertex_type_by_id( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE_ID, + ) -> GRIN_VERTEX_TYPE; +} +extern "C" { + pub fn grin_equal_edge_type( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + arg3: GRIN_EDGE_TYPE, + ) -> bool; +} +extern "C" { + pub fn grin_get_edge_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_EDGE_TYPE; +} +extern "C" { + pub fn grin_destroy_edge_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE); +} +extern "C" { + pub fn grin_get_edge_type_list(arg1: GRIN_GRAPH) -> GRIN_EDGE_TYPE_LIST; +} +extern "C" { + pub fn grin_destroy_edge_type_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE_LIST); +} +extern "C" { + pub fn grin_create_edge_type_list(arg1: GRIN_GRAPH) -> GRIN_EDGE_TYPE_LIST; +} +extern "C" { + pub fn grin_insert_edge_type_to_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE_LIST, + arg3: GRIN_EDGE_TYPE, + ) -> bool; +} +extern "C" { + pub fn grin_get_edge_type_list_size(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE_LIST) -> usize; +} +extern "C" { + pub fn grin_get_edge_type_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE_LIST, + arg3: usize, + ) -> GRIN_EDGE_TYPE; +} +extern "C" { + pub fn grin_get_edge_type_name( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_get_edge_type_by_name( + arg1: GRIN_GRAPH, + arg2: *const ::std::os::raw::c_char, + ) -> GRIN_EDGE_TYPE; +} +extern "C" { + pub fn grin_get_edge_type_id(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE) -> GRIN_EDGE_TYPE_ID; +} +extern "C" { + pub fn grin_get_edge_type_by_id(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE_ID) -> GRIN_EDGE_TYPE; +} +extern "C" { + #[doc = " @brief Get source vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE_TYPE The edge type.\n @return The vertex type list of source."] + pub fn grin_get_src_types_by_edge_type( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> GRIN_VERTEX_TYPE_LIST; +} +extern "C" { + #[doc = " @brief Get destination vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE_TYPE The edge type.\n @return The vertex type list of destination."] + pub fn grin_get_dst_types_by_edge_type( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + ) -> GRIN_VERTEX_TYPE_LIST; +} +extern "C" { + #[doc = " @brief Get edge types related to a pair of vertex types.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The source vertex type.\n @param GRIN_VERTEX_TYPE The destination vertex type.\n @return The related edge type list."] + pub fn grin_get_edge_types_by_vertex_type_pair( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_VERTEX_TYPE, + ) -> GRIN_EDGE_TYPE_LIST; +} +extern "C" { + pub fn grin_get_label_by_name( + arg1: GRIN_GRAPH, + arg2: *const ::std::os::raw::c_char, + ) -> GRIN_LABEL; +} +extern "C" { + pub fn grin_destroy_label(arg1: GRIN_GRAPH, arg2: GRIN_LABEL); +} +extern "C" { + pub fn grin_get_label_name(arg1: GRIN_GRAPH, arg2: GRIN_LABEL) + -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn grin_destroy_label_list(arg1: GRIN_GRAPH, arg2: GRIN_LABEL_LIST); +} +extern "C" { + pub fn grin_get_label_list_size(arg1: GRIN_GRAPH, arg2: GRIN_LABEL_LIST) -> usize; +} +extern "C" { + pub fn grin_get_label_from_list( + arg1: GRIN_GRAPH, + arg2: GRIN_LABEL_LIST, + arg3: usize, + ) -> GRIN_LABEL; +} +extern "C" { + #[doc = " @brief assign a label to a vertex\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label\n @param GRIN_VERTEX the vertex\n @return whether succeed"] + pub fn grin_assign_label_to_vertex( + arg1: GRIN_GRAPH, + arg2: GRIN_LABEL, + arg3: GRIN_VERTEX, + ) -> bool; +} +extern "C" { + #[doc = " @brief get the label list of a vertex\n @param GRIN_GRAPH the graph\n @param GRIN_VERTEX the vertex"] + pub fn grin_get_vertex_label_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_LABEL_LIST; +} +extern "C" { + #[doc = " @brief get the vertex list by label\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label"] + pub fn grin_get_vertex_list_by_label(arg1: GRIN_GRAPH, arg2: GRIN_LABEL) -> GRIN_VERTEX_LIST; +} +extern "C" { + #[doc = " @brief filtering an existing vertex list by label\n @param GRIN_VERTEX_LIST the existing vertex list\n @param GRIN_LABEL the label"] + pub fn grin_select_label_for_vertex_list( + arg1: GRIN_GRAPH, + arg2: GRIN_LABEL, + arg3: GRIN_VERTEX_LIST, + ) -> GRIN_VERTEX_LIST; +} +extern "C" { + #[doc = " @brief assign a label to a edge\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label\n @param GRIN_EDGE the edge\n @return whether succeed"] + pub fn grin_assign_label_to_edge(arg1: GRIN_GRAPH, arg2: GRIN_LABEL, arg3: GRIN_EDGE) -> bool; +} +extern "C" { + #[doc = " @brief get the label list of a edge\n @param GRIN_GRAPH the graph\n @param GRIN_EDGE the edge"] + pub fn grin_get_edge_label_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_LABEL_LIST; +} +extern "C" { + #[doc = " @brief get the edge list by label\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label"] + pub fn grin_get_edge_list_by_label(arg1: GRIN_GRAPH, arg2: GRIN_LABEL) -> GRIN_EDGE_LIST; +} +extern "C" { + #[doc = " @brief filtering an existing edge list by label\n @param GRIN_EDGE_LIST the existing edge list\n @param GRIN_LABEL the label"] + pub fn grin_select_label_for_edge_list( + arg1: GRIN_GRAPH, + arg2: GRIN_LABEL, + arg3: GRIN_EDGE_LIST, + ) -> GRIN_EDGE_LIST; +} +extern "C" { + pub fn grin_smaller_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX, arg3: GRIN_VERTEX) -> bool; +} +extern "C" { + #[doc = " @brief Get the position of a vertex in a sorted list\n caller must guarantee the input vertex list is sorted to get the correct result\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_LIST The sorted vertex list\n @param GRIN_VERTEX The vertex to find\n @return The position of the vertex"] + pub fn grin_get_position_of_vertex_from_sorted_list( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_LIST, + arg3: GRIN_VERTEX, + ) -> usize; +} +extern "C" { + #[doc = " @brief Get the int64 internal id of a vertex\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @return The int64 internal id of the vertex"] + pub fn grin_get_vertex_internal_id_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_VERTEX, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief Get the vertex by internal id under type\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @param id The internal id of the vertex under type\n @return The vertex"] + pub fn grin_get_vertex_by_internal_id_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + id: ::std::os::raw::c_longlong, + ) -> GRIN_VERTEX; +} +extern "C" { + #[doc = " @brief Get the upper bound of internal id under type.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @return The upper bound of internal id under type"] + pub fn grin_get_vertex_internal_id_upper_bound_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief Get the lower bound internal id under type.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @return The lower bound internal id under type"] + pub fn grin_get_vertex_internal_id_lower_bound_by_type( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + #[doc = " @brief Get the vertex by primary keys row.\n The values in the row must be in the same order as the primary keys\n properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @param GRIN_ROW The values row of primary keys properties.\n @return The vertex."] + pub fn grin_get_vertex_by_primary_keys_row( + arg1: GRIN_GRAPH, + arg2: GRIN_VERTEX_TYPE, + arg3: GRIN_ROW, + ) -> GRIN_VERTEX; +} +extern "C" { + pub fn grin_get_edge_by_primary_keys_row( + arg1: GRIN_GRAPH, + arg2: GRIN_EDGE_TYPE, + arg3: GRIN_ROW, + ) -> GRIN_EDGE; +} +extern "C" { + pub static mut grin_error_code: GRIN_ERROR_CODE; +} +extern "C" { + #[doc = " @brief Get the last error code.\n The error code is thread local.\n Currently users only need to check the error code when using\n getting-value APIs whose return has no predefined invalid value."] + pub fn grin_get_last_error_code() -> GRIN_ERROR_CODE; +} +extern "C" { + #[doc = " @brief Get the static feature prototype message of the storage.\n This proto describes the features of the storage, such as whether\n it supports property graph or partitioned graph.\n @return The serialized proto message."] + pub fn grin_get_static_storage_feature_msg() -> *const ::std::os::raw::c_char; +} +extern "C" { + #[doc = " GRIN_FEATURES_ENABLE_ALL\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_DATA: GrinVertexData = 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_DATA: GrinEdgeData = 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 = std::ptr::null_mut();\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 = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut();\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 = std::ptr::null_mut();\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 = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut();\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_LABEL: GrinLabel = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;"] + pub static mut __rust_keep_grin_null: ::std::os::raw::c_int; +} diff --git a/flex/engines/graph_db/grin/include/rust/grin_v6d.h b/flex/engines/graph_db/grin/include/rust/grin_v6d.h new file mode 100644 index 000000000000..820ff02ab7b6 --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/grin_v6d.h @@ -0,0 +1,38 @@ +#define GRIN_FEATURES_ENABLE_V6D +#define GRIN_RUST_CODEGEN + +#include "storage/v6d/predefine.h" + +#ifdef GRIN_RUST_CODEGEN +/// GRIN_FEATURES_ENABLE_V6D +/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; +/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX; +/// 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}; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = GrinAdjacentList{begin: std::ptr::null(), end: std::ptr::null(), vid: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX}; +/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; +/// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); +/// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX; +int __rust_keep_grin_null; +#endif diff --git a/flex/engines/graph_db/grin/include/rust/grin_v6d.rs b/flex/engines/graph_db/grin/include/rust/grin_v6d.rs new file mode 100644 index 000000000000..2b6b26011a31 --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/grin_v6d.rs @@ -0,0 +1,97 @@ +/* automatically generated by rust-bindgen 0.64.0 */ + +pub const true_: u32 = 1; +pub const false_: u32 = 0; +pub const __bool_true_false_are_defined: u32 = 1; +pub const GRIN_NULL_VERTEX_REF: i32 = -1; +pub type wchar_t = ::std::os::raw::c_int; +pub type max_align_t = u128; +#[doc = "< incoming"] +pub const GRIN_DIRECTION_IN: GRIN_DIRECTION = 0; +#[doc = "< outgoing"] +pub const GRIN_DIRECTION_OUT: GRIN_DIRECTION = 1; +#[doc = "< incoming & outgoing"] +pub const GRIN_DIRECTION_BOTH: GRIN_DIRECTION = 2; +#[doc = " Enumerates the directions of edges with respect to a certain vertex"] +pub type GRIN_DIRECTION = ::std::os::raw::c_uint; +#[doc = "< other unknown types"] +pub const GRIN_DATATYPE_Undefined: GRIN_DATATYPE = 0; +#[doc = "< int"] +pub const GRIN_DATATYPE_Int32: GRIN_DATATYPE = 1; +#[doc = "< unsigned int"] +pub const GRIN_DATATYPE_UInt32: GRIN_DATATYPE = 2; +#[doc = "< long int"] +pub const GRIN_DATATYPE_Int64: GRIN_DATATYPE = 3; +#[doc = "< unsigned long int"] +pub const GRIN_DATATYPE_UInt64: GRIN_DATATYPE = 4; +#[doc = "< float"] +pub const GRIN_DATATYPE_Float: GRIN_DATATYPE = 5; +#[doc = "< double"] +pub const GRIN_DATATYPE_Double: GRIN_DATATYPE = 6; +#[doc = "< string"] +pub const GRIN_DATATYPE_String: GRIN_DATATYPE = 7; +#[doc = "< date"] +pub const GRIN_DATATYPE_Date32: GRIN_DATATYPE = 8; +#[doc = "< Time32"] +pub const GRIN_DATATYPE_Time32: GRIN_DATATYPE = 9; +#[doc = "< Timestamp"] +pub const GRIN_DATATYPE_Timestamp64: GRIN_DATATYPE = 10; +#[doc = " Enumerates the datatype supported in the storage"] +pub type GRIN_DATATYPE = ::std::os::raw::c_uint; +#[doc = "< success"] +pub const GRIN_ERROR_CODE_NO_ERROR: GRIN_ERROR_CODE = 0; +#[doc = "< unknown error"] +pub const GRIN_ERROR_CODE_UNKNOWN_ERROR: GRIN_ERROR_CODE = 1; +#[doc = "< invalid value"] +pub const GRIN_ERROR_CODE_INVALID_VALUE: GRIN_ERROR_CODE = 2; +#[doc = "< unknown datatype"] +pub const GRIN_ERROR_CODE_UNKNOWN_DATATYPE: GRIN_ERROR_CODE = 3; +#[doc = " Enumerates the error codes of grin"] +pub type GRIN_ERROR_CODE = ::std::os::raw::c_uint; +pub type GRIN_GRAPH = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX = ::std::os::raw::c_ulonglong; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct GRIN_EDGE { + pub src: GRIN_VERTEX, + pub dst: GRIN_VERTEX, + pub dir: GRIN_DIRECTION, + pub etype: ::std::os::raw::c_uint, + pub eid: ::std::os::raw::c_ulonglong, +} +pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct GRIN_ADJACENT_LIST { + pub begin: *const ::std::os::raw::c_void, + pub end: *const ::std::os::raw::c_void, + pub vid: GRIN_VERTEX, + pub dir: GRIN_DIRECTION, + pub etype: ::std::os::raw::c_uint, +} +pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITION = ::std::os::raw::c_uint; +pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint; +pub type GRIN_VERTEX_REF = ::std::os::raw::c_longlong; +pub type GRIN_VERTEX_TYPE = ::std::os::raw::c_uint; +pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_PROPERTY = ::std::os::raw::c_ulonglong; +pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint; +pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint; +pub type GRIN_EDGE_TYPE = ::std::os::raw::c_uint; +pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_VEV_TYPE = *mut ::std::os::raw::c_void; +pub type GRIN_VEV_TYPE_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_PROPERTY = ::std::os::raw::c_ulonglong; +pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void; +pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint; +pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint; +pub type GRIN_ROW = *mut ::std::os::raw::c_void; +extern "C" { + #[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 = GrinAdjacentList{begin: std::ptr::null(), end: std::ptr::null(), vid: 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_VEV_TYPE: GrinVevType = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = 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;"] + pub static mut __rust_keep_grin_null: ::std::os::raw::c_int; +} diff --git a/flex/engines/graph_db/grin/include/rust/parse.py b/flex/engines/graph_db/grin/include/rust/parse.py new file mode 100644 index 000000000000..93c07cb95ce7 --- /dev/null +++ b/flex/engines/graph_db/grin/include/rust/parse.py @@ -0,0 +1,257 @@ +import os +from pathlib import Path + +def get_func_name(line): + return line.split('(')[0].strip().split(' ')[-1].strip() + +def get_macro_name(line): + return ('one', [('yes', line.split(' ')[1].strip())]) + +def parse_expr(line): + line = line.strip() + assert(line.startswith('#if ')) + line = line[4:] + defs = line.split() + res = [] + rel = '' + for d in defs: + if d.startswith('!'): + res.append(('not', d[1+8: -1])) + elif d.startswith('defined'): + res.append(('yes', d[8: -1])) + elif d == '&&': + assert(rel == '' or rel == 'and') + rel = 'and' + elif d == '||': + assert(rel == '' or rel == 'or') + rel = 'or' + else: + assert False, f'unknown: {d}' + assert(rel != '') + return (rel, res) + +def parse(path): + res = {} + macros = [] + prefix = '' + with open(path) as f: + for _line in f: + if _line.strip().endswith('\\'): + prefix += _line.strip()[:-1] + continue + line = prefix + _line + prefix = '' + if line.startswith(('GRIN_', 'void', 'bool', 'size_t', 'const', 'int', 'long long int', + 'unsigned int', 'unsigned long long int', + 'float', 'double', 'const char*', 'struct')): + func_name = get_func_name(line) + res[func_name] = macros.copy() + elif line.startswith('#ifdef'): + assert(len(macros) == 0) + macro_name = get_macro_name(line) + macros.append(macro_name) + elif line.startswith('#endif'): + assert(len(macros) <= 1) + if len(macros) == 1: + macros = macros[:-1] + elif line.startswith('#if '): + assert(len(macros) == 0) + macro_name = parse_expr(line) + macros.append(macro_name) + return res + +def to_rust(deps): + if len(deps) == 0: + return '' + assert(len(deps) == 1) + one_foramt = '#[cfg(feature = \"{}\")]' + yes_format = 'feature = \"{}\"' + not_format = 'not(feature = \"{}\")' + all_format = '#[cfg(all({}))]' + any_format = '#[cfg(any({}))]' + + deps = deps[0] + if deps[0] == 'one': + assert(len(deps[1]) == 1) + assert(deps[1][0][0] == 'yes') + return one_foramt.format(deps[1][0][1].lower()) + elif deps[0] == 'and': + conds = [not_format.format(d[1].lower()) if d[0] == 'not' else yes_format.format(d[1].lower()) for d in deps[1]] + return all_format.format(", ".join(conds)) + elif deps[0] == 'or': + conds = [not_format.format(d[1].lower()) if d[0] == 'not' else yes_format.format(d[1].lower()) for d in deps[1]] + return any_format.format(", ".join(conds)) + else: + assert False, f'unknown: {deps}' + +def snake_to_camel(s): + if s.startswith(('GRIN_DATATYPE_', 'GRIN_DIRECTION_', 'GRIN_ERROR_CODE_', 'GRIN_FEATURES_ENABLE')): + return s.upper() + return ''.join([w.capitalize() for w in s.split('_')]) + +def snake_to_camel_line(line): + segs = line.split(' ') + return ' '.join([snake_to_camel(s) if s.startswith('GRIN_') and s.find('NULL') == -1 else s for s in segs]) + +def static_replace(line): + replaces = { + '::std::os::raw::c_uint': 'u32', + '::std::os::raw::c_int': 'i32', + '::std::os::raw::c_ulonglong': 'u64', + '::std::os::raw::c_longlong': 'i64', + 'Copy, Clone': 'Copy, Clone, PartialEq', + } + for k in replaces: + line = line.replace(k, replaces[k]) + return line + + +def rewrite(file, r, strip=7): + with open(file) as f: + lines = f.readlines() + externc_flag = True + need_ending_line = True + parts = [[], [], [], []] + p = 0 + for i, line in enumerate(lines): + if i < strip: + continue + line = snake_to_camel_line(line) + line = static_replace(line) + if line.startswith('extern '): + if externc_flag: + p += 1 + parts[p].append('extern "C" {') + externc_flag = False + continue + if line.startswith('}'): + if i < len(lines) - 1: + if externc_flag: + parts[p].append('}') + else: + parts[p].append('') + else: + need_ending_line = False + parts[p].append('}') + continue + if line.find('pub fn') != -1: + func_name = line + func_name = func_name[func_name.find('pub fn')+7:] + func_name = func_name.split('(')[0] + if func_name in r and r[func_name]: + parts[p].append(f' {r[func_name]}') + parts[p].append(' #[allow(unused)]') + if line.find('pub type') != -1: + func_name = line + func_name = func_name[func_name.find('pub type')+9:] + func_name = func_name.split(' ')[0] + if func_name in r and r[func_name]: + parts[p].append(f'{r[func_name]}') + parts[p].append('#[allow(unused)]') + if line.find('RUST_KEEP') != -1: + macro_name = line[line.find('GRIN'):line.find('RUST_KEEP')-3].lower() + if need_ending_line: + parts[p][-1] = '}' + p += 1 + segs = line.split('RUST_KEEP') + for s in segs[1:]: + parts[p].append(s[1:s.find(';')+1]) + break + if line.find('pub type GrinGraph') != -1: + p += 1 + parts[p].append(line[:-1]) + return parts + + +def parse_to_rs(path, dst, predefine, strip=7): + r = {} + r |= parse(path / predefine) + for f in path.glob('include/**/*.h'): + r |= parse(f) + for k in r: + r[k] = to_rust(r[k]) + return rewrite(f'{dst}.rs', r, strip=strip) + +def get_features(path, storage): + macros = [] + with open(path / f'storage/{storage}/predefine.h') as f: + lines = f.readlines() + for line in lines: + if line.startswith('#define') and line.find('GRIN_NULL') == -1: + macros.append(line[8:].strip().lower()) + return macros + +def parse_to_toml(path, storages): + features = {} + for s in storages: + features[f'grin_features_enable_{s}'] = get_features(path, s) + with open(path / 'template/predefine.h') as f: + lines = f.readlines() + macros = [] + for line in lines: + if line.startswith('#define') and line.find('GRIN_NULL') == -1: + macros.append(line[8:].strip().lower()) + with open('Cargo.toml', 'w') as f: + f.write('[package]\n') + f.write(f'name = \"grin\"\n') + f.write('version = \"0.1.1\"\n') + f.write('authors = [\"dijie\"]\n') + f.write('\n') + f.write('[dependencies]\n') + f.write('cfg-if = \"0.1\"\n\n') + f.write('[features]\n') + for k in macros: + f.write(f'{k} = []\n') + for feat in features: + f.write(f'{feat} = {features[feat]}\n') + +def bindgen(src, dst): + os.system(f'bindgen {src} -o {dst}.rs --no-layout-tests -- -I"../include" -I".."') + +def all(path): + src = 'grin_all.h' + dst = 'grin_all' + predefine = 'template/predefine.h' + bindgen(src, dst) + return parse_to_rs(path, dst, predefine) + +def v6d(path): + src = 'grin_v6d.h' + dst = 'grin_v6d' + predefine = 'storage/v6d/predefine.h' + bindgen(src, dst) + return parse_to_rs(path, dst, predefine, strip=50) + +def merge(partss): + with open('grin.rs', 'w') as outfile: + # write allparts 0 + outfile.write('\n'.join(partss['all'][0])) + outfile.write('\n') + # write every parts 1 & 3 + outfile.write('cfg_if::cfg_if! {\n') + first = True + for k in partss: + if k != 'all': + if first: + first = False + outfile.write(' if') + else: + outfile.write(' elif') + outfile.write(f' #[cfg(feature = \"grin_features_enable_{k}\")]') + else: + outfile.write(' else ') + outfile.write('{\n') + outfile.write('\n'.join([f' {x}' for x in partss[k][1] + partss[k][3]])) + outfile.write('\n }') + outfile.write('\n}\n') + # write allparts 2 + outfile.write('\n'.join(partss['all'][2])) + outfile.write('\n') + + +if __name__ == '__main__': + path = Path('..') + allparts = all(path) + v6dparts = v6d(path) + merge({'v6d': v6dparts, 'all': allparts}) + parse_to_toml(path, ['v6d']) \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/storage/GART/predefine.h b/flex/engines/graph_db/grin/include/storage/GART/predefine.h new file mode 100644 index 000000000000..8009c9efca2b --- /dev/null +++ b/flex/engines/graph_db/grin/include/storage/GART/predefine.h @@ -0,0 +1,237 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file predefine.h + * @brief This template file consists of four parts: + * 1. The predefined enumerate types of GRIN, which should NOT be modified. + * 2. The supported macros which should be specified by storage implementors + * based on storage features. + * 3. The typedefs of the enabled handles. This should be specified by storage. + * 4. The corresponding null values of the enabled handles. This should be + * specified by storage. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* 1. Predefined enumerate types of GRIN */ +/// Enumerates the directions of edges with respect to a certain vertex +typedef enum { + IN = 0, ///< incoming + OUT = 1, ///< outgoing + BOTH = 2, ///< incoming & outgoing +} GRIN_DIRECTION; + +/// Enumerates the datatype supported in the storage +typedef enum { + Undefined = 0, ///< other unknown types + Int32 = 1, ///< int + UInt32 = 2, ///< unsigned int + Int64 = 3, ///< long int + UInt64 = 4, ///< unsigned long int + Float = 5, ///< float + Double = 6, ///< double + String = 7, ///< string + Date32 = 8, ///< date + Time32 = 9, ///< Time32 + Timestamp64 = 10, ///< Timestamp +} GRIN_DATATYPE; + +/// Enumerates the error codes of grin +typedef enum { + NO_ERROR = 0, ///< success + UNKNOWN_ERROR = 1, ///< unknown error + INVALID_VALUE = 2, ///< invalid value + UNKNOWN_DATATYPE = 3, ///< unknown datatype +} GRIN_ERROR_CODE; + +/* Define supported macros based on storage features */ +// Topology +#define GRIN_ASSUME_HAS_DIRECTED_GRAPH +#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH +#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +#define GRIN_ENABLE_VERTEX_LIST +#define GRIN_ENABLE_VERTEX_LIST_ITERATOR +#define GRIN_ENABLE_ADJACENT_LIST +#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR +// Partition +#define GRIN_ENABLE_GRAPH_PARTITION +#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +#define GRIN_ENABLE_VERTEX_REF +#define GRIN_TRAIT_FAST_VERTEX_REF +#define GRIN_ASSUME_EDGE_CUT_PARTITION +#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST +// Property +#define GRIN_ENABLE_ROW +#define GRIN_WITH_VERTEX_PROPERTY +#define GRIN_WITH_VERTEX_PROPERTY_NAME +#define GRIN_WITH_VERTEX_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY_NAME +#define GRIN_WITH_EDGE_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +// Index +#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + +/* Define the handles using typedef */ +typedef void* GRIN_GRAPH; +typedef unsigned long long int GRIN_VERTEX; + +#ifdef GRIN_WITH_VERTEX_DATA +typedef void* GRIN_VERTEX_DATA; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +typedef void* GRIN_VERTEX_LIST; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +typedef void* GRIN_VERTEX_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +typedef void* GRIN_ADJACENT_LIST_ITERATOR; +#endif + +#ifdef GRIN_WITH_EDGE_DATA +typedef void* GRIN_EDGE_DATA; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST +typedef void* GRIN_EDGE_LIST; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR +typedef void* GRIN_EDGE_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +typedef void* GRIN_PARTITIONED_GRAPH; +typedef unsigned GRIN_PARTITION; +typedef void* GRIN_PARTITION_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +typedef unsigned GRIN_PARTITION_ID; +#endif + +#ifdef GRIN_ENABLE_VERTEX_REF +typedef long long int GRIN_VERTEX_REF; +#endif + +#ifdef GRIN_ENABLE_EDGE_REF +typedef void* GRIN_EDGE_REF; +#endif + +#ifdef GRIN_WITH_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_TYPE; +typedef void* GRIN_VERTEX_TYPE_LIST; +typedef unsigned long long int GRIN_VERTEX_PROPERTY; +typedef void* GRIN_VERTEX_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +typedef unsigned GRIN_VERTEX_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_PROPERTY_ID; +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_TYPE; +typedef void* GRIN_EDGE_TYPE_LIST; +typedef void* GRIN_VEV_TYPE; +typedef void* GRIN_VEV_TYPE_LIST; +typedef unsigned long long int GRIN_EDGE_PROPERTY; +typedef void* GRIN_EDGE_PROPERTY_LIST; +#endif + +typedef struct GRIN_EDGE { + GRIN_VERTEX src; + GRIN_VERTEX dst; + GRIN_DIRECTION dir; + GRIN_EDGE_TYPE etype; + char* edata; +} GRIN_EDGE; + +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef struct GRIN_ADJACENT_LIST { + GRIN_VERTEX v; + GRIN_DIRECTION dir; + GRIN_EDGE_TYPE etype; +} GRIN_ADJACENT_LIST; +#endif + + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +typedef unsigned GRIN_EDGE_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_PROPERTY_ID; +#endif + +#ifdef GRIN_ENABLE_ROW +typedef void* GRIN_ROW; +#endif + +#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) +typedef void* GRIN_LABEL; +typedef void* GRIN_LABEL_LIST; +#endif + +/* Define invalid values for returns of handles */ +#define GRIN_NULL_GRAPH NULL +#define GRIN_NULL_VERTEX (unsigned long long int)~0 +#define GRIN_NULL_VERTEX_LIST NULL +#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL +#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL +#define GRIN_NULL_PARTITIONED_GRAPH NULL +#define GRIN_NULL_PARTITION (unsigned)~0 +#define GRIN_NULL_PARTITION_LIST NULL +#define GRIN_NULL_PARTITION_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_REF -1 +#define GRIN_NULL_VERTEX_TYPE (unsigned)~0 +#define GRIN_NULL_VERTEX_TYPE_LIST NULL +#define GRIN_NULL_VERTEX_PROPERTY (unsigned long long int)~0 +#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL +#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE_LIST NULL +#define GRIN_NULL_VEV_TYPE NULL +#define GRIN_NULL_VEV_TYPE_LIST NULL +#define GRIN_NULL_EDGE_PROPERTY (unsigned long long int)~0 +#define GRIN_NULL_EDGE_PROPERTY_LIST NULL +#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 +#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_ROW NULL +#define GRIN_NULL_SIZE (unsigned)~0 +#define GRIN_NULL_NAME NULL +#define GRIN_NULL_EDGE GRIN_EDGE{GRIN_NULL_VERTEX, GRIN_NULL_VERTEX, BOTH, GRIN_NULL_EDGE_TYPE_ID, NULL} +#define GRIN_NULL_ADJACENT_LIST GRIN_ADJACENT_LIST{GRIN_NULL_VERTEX, BOTH, GRIN_NULL_EDGE_TYPE_ID} + +#ifdef __cplusplus +} +#endif diff --git a/flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h b/flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h new file mode 100644 index 000000000000..b675ee947b6a --- /dev/null +++ b/flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h @@ -0,0 +1,243 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file predefine.h + * @brief This template file consists of four parts: + * 1. The predefined enumerate types of GRIN, which should NOT be modified. + * 2. The supported macros which should be specified by storage implementors + * based on storage features. + * 3. The typedefs of the enabled handles. This should be specified by storage. + * 4. The corresponding null values of the enabled handles. This should be + * specified by storage. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* 1. Predefined enumerate types of GRIN */ +/// Enumerates the directions of edges with respect to a certain vertex +typedef enum { + IN = 0, ///< incoming + OUT = 1, ///< outgoing + BOTH = 2, ///< incoming & outgoing +} GRIN_DIRECTION; + +/// Enumerates the datatype supported in the storage +typedef enum { + Undefined = 0, ///< other unknown types + Int32 = 1, ///< int + UInt32 = 2, ///< unsigned int + Int64 = 3, ///< long int + UInt64 = 4, ///< unsigned long int + Float = 5, ///< float + Double = 6, ///< double + String = 7, ///< string + Date32 = 8, ///< date + Time32 = 9, ///< Time32 + Timestamp64 = 10, ///< Timestamp +} GRIN_DATATYPE; + +/// Enumerates the error codes of grin +typedef enum { + NO_ERROR = 0, ///< success + UNKNOWN_ERROR = 1, ///< unknown error + INVALID_VALUE = 2, ///< invalid value + UNKNOWN_DATATYPE = 3, ///< unknown datatype +} GRIN_ERROR_CODE; + +/* 2. Define supported macros based on storage features */ +// Topology +#define GRIN_ASSUME_HAS_DIRECTED_GRAPH +#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +#define GRIN_ENABLE_VERTEX_LIST +#define GRIN_ENABLE_VERTEX_LIST_ARRAY +#define GRIN_ENABLE_VERTEX_LIST_ITERATOR +#define GRIN_ENABLE_EDGE_LIST +#define GRIN_ENABLE_EDGE_LIST_ITERATOR +#define GRIN_ENABLE_ADJACENT_LIST +#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR +// Partition +#define GRIN_ENABLE_GRAPH_PARTITION +#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +#define GRIN_ENABLE_VERTEX_REF +#define GRIN_TRAIT_FAST_VERTEX_REF +#define GRIN_ASSUME_ALL_REPLICATE_PARTITION +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA +#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST +#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST +// Property +#define GRIN_ENABLE_ROW +#define GRIN_WITH_VERTEX_PROPERTY +#define GRIN_WITH_VERTEX_PROPERTY_NAME +#define GRIN_WITH_VERTEX_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY_NAME +#define GRIN_WITH_EDGE_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +// Index +#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED +#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + +/* 3. Define the handles using typedef */ +typedef void* GRIN_GRAPH; +typedef void* GRIN_VERTEX; +typedef void* GRIN_EDGE; + +#ifdef GRIN_WITH_VERTEX_DATA +typedef void* GRIN_VERTEX_DATA; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +typedef void* GRIN_VERTEX_LIST; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +typedef void* GRIN_VERTEX_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef void* GRIN_ADJACENT_LIST; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +typedef void* GRIN_ADJACENT_LIST_ITERATOR; +#endif + +#ifdef GRIN_WITH_EDGE_DATA +typedef void* GRIN_EDGE_DATA; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST +typedef void* GRIN_EDGE_LIST; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR +typedef void* GRIN_EDGE_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +typedef void* GRIN_PARTITIONED_GRAPH; +typedef unsigned GRIN_PARTITION; +typedef void* GRIN_PARTITION_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +typedef unsigned GRIN_PARTITION_ID; +#endif + +#ifdef GRIN_ENABLE_VERTEX_REF +typedef long long int GRIN_VERTEX_REF; +#endif + +#ifdef GRIN_ENABLE_EDGE_REF +typedef void* GRIN_EDGE_REF; +#endif + +#ifdef GRIN_WITH_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_TYPE; +typedef void* GRIN_VERTEX_TYPE_LIST; +typedef unsigned GRIN_VERTEX_PROPERTY; +typedef void* GRIN_VERTEX_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +typedef unsigned GRIN_VERTEX_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_PROPERTY_ID; +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_TYPE; +typedef void* GRIN_EDGE_TYPE_LIST; +typedef void* GRIN_VEV_TYPE; +typedef void* GRIN_VEV_TYPE_LIST; +typedef unsigned GRIN_EDGE_PROPERTY; +typedef void* GRIN_EDGE_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +typedef unsigned GRIN_EDGE_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_PROPERTY_ID; +#endif + +#ifdef GRIN_ENABLE_ROW +typedef void* GRIN_ROW; +#endif + +#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) +typedef void* GRIN_LABEL; +typedef void* GRIN_LABEL_LIST; +#endif + +/* 4. Define invalid values for returns of handles */ +#define GRIN_NULL_GRAPH NULL +#define GRIN_NULL_VERTEX NULL +#define GRIN_NULL_EDGE NULL +#define GRIN_NULL_VERTEX_DATA NULL +#define GRIN_NULL_VERTEX_LIST NULL +#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL +#define GRIN_NULL_ADJACENT_LIST NULL +#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL +#define GRIN_NULL_EDGE_DATA NULL +#define GRIN_NULL_EDGE_LIST NULL +#define GRIN_NULL_EDGE_LIST_ITERATOR NULL +#define GRIN_NULL_PARTITIONED_GRAPH NULL +#define GRIN_NULL_PARTITION (unsigned) ~0 +#define GRIN_NULL_PARTITION_LIST NULL +#define GRIN_NULL_PARTITION_ID (unsigned) ~0 +#define GRIN_NULL_VERTEX_REF -1 +#define GRIN_NULL_EDGE_REF NULL +#define GRIN_NULL_VERTEX_TYPE (unsigned) ~0 +#define GRIN_NULL_VERTEX_TYPE_LIST NULL +#define GRIN_NULL_VERTEX_PROPERTY (unsigned) ~0 +#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL +#define GRIN_NULL_VERTEX_TYPE_ID (unsigned) ~0 +#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned) ~0 +#define GRIN_NULL_EDGE_TYPE (unsigned) ~0 +#define GRIN_NULL_EDGE_TYPE_LIST NULL +#define GRIN_NULL_VEV_TYPE NULL +#define GRIN_NULL_VEV_TYPE_LIST NULL +#define GRIN_NULL_EDGE_PROPERTY (unsigned) ~0 +#define GRIN_NULL_EDGE_PROPERTY_LIST NULL +#define GRIN_NULL_EDGE_TYPE_ID (unsigned) ~0 +#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned) ~0 +#define GRIN_NULL_ROW NULL +#define GRIN_NULL_LABEL NULL +#define GRIN_NULL_LABEL_LIST NULL +#define GRIN_NULL_SIZE (unsigned) ~0 +#define GRIN_NULL_NAME NULL + +#ifdef __cplusplus +} +#endif diff --git a/flex/engines/graph_db/grin/include/storage/v6d/predefine.h b/flex/engines/graph_db/grin/include/storage/v6d/predefine.h new file mode 100644 index 000000000000..e1daea396fbb --- /dev/null +++ b/flex/engines/graph_db/grin/include/storage/v6d/predefine.h @@ -0,0 +1,241 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file predefine.h + * @brief This template file consists of four parts: + * 1. The predefined enumerate types of GRIN, which should NOT be modified. + * 2. The supported macros which should be specified by storage implementors + * based on storage features. + * 3. The typedefs of the enabled handles. This should be specified by storage. + * 4. The corresponding null values of the enabled handles. This should be + * specified by storage. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* 1. Predefined enumerate types of GRIN */ +/// Enumerates the directions of edges with respect to a certain vertex +typedef enum { + IN = 0, ///< incoming + OUT = 1, ///< outgoing + BOTH = 2, ///< incoming & outgoing +} GRIN_DIRECTION; + +/// Enumerates the datatype supported in the storage +typedef enum { + Undefined = 0, ///< other unknown types + Int32 = 1, ///< int + UInt32 = 2, ///< unsigned int + Int64 = 3, ///< long int + UInt64 = 4, ///< unsigned long int + Float = 5, ///< float + Double = 6, ///< double + String = 7, ///< string + Date32 = 8, ///< date + Time32 = 9, ///< Time32 + Timestamp64 = 10, ///< Timestamp +} GRIN_DATATYPE; + +/// Enumerates the error codes of grin +typedef enum { + NO_ERROR = 0, ///< success + UNKNOWN_ERROR = 1, ///< unknown error + INVALID_VALUE = 2, ///< invalid value + UNKNOWN_DATATYPE = 3, ///< unknown datatype +} GRIN_ERROR_CODE; + +/* Define supported macros based on storage features */ +// Topology +#define GRIN_ASSUME_HAS_DIRECTED_GRAPH +#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH +#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +#define GRIN_ENABLE_VERTEX_LIST +#define GRIN_ENABLE_VERTEX_LIST_ARRAY +#define GRIN_ENABLE_VERTEX_LIST_ITERATOR +#define GRIN_ENABLE_ADJACENT_LIST +#define GRIN_ENABLE_ADJACENT_LIST_ARRAY +#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR +// Partition +#define GRIN_ENABLE_GRAPH_PARTITION +#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +#define GRIN_ENABLE_VERTEX_REF +#define GRIN_TRAIT_FAST_VERTEX_REF +#define GRIN_ASSUME_EDGE_CUT_PARTITION +#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST +// Property +#define GRIN_ENABLE_ROW +#define GRIN_WITH_VERTEX_PROPERTY +#define GRIN_WITH_VERTEX_PROPERTY_NAME +#define GRIN_WITH_VERTEX_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY_NAME +#define GRIN_WITH_EDGE_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS +// Index +#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX +#define GRIN_ENABLE_VERTEX_PK_INDEX + +/* Define the handles using typedef */ +typedef void* GRIN_GRAPH; +typedef unsigned long long int GRIN_VERTEX; +typedef struct GRIN_EDGE { + GRIN_VERTEX src; + GRIN_VERTEX dst; + GRIN_DIRECTION dir; + unsigned etype; + unsigned long long int eid; +} GRIN_EDGE; + +#ifdef GRIN_WITH_VERTEX_DATA +typedef void* GRIN_VERTEX_DATA; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +typedef void* GRIN_VERTEX_LIST; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +typedef void* GRIN_VERTEX_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef struct GRIN_ADJACENT_LIST { + const void* begin; + const void* end; + GRIN_VERTEX vid; + GRIN_DIRECTION dir; + unsigned etype; +} GRIN_ADJACENT_LIST; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +typedef void* GRIN_ADJACENT_LIST_ITERATOR; +#endif + +#ifdef GRIN_WITH_EDGE_DATA +typedef void* GRIN_EDGE_DATA; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST +typedef void* GRIN_EDGE_LIST; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR +typedef void* GRIN_EDGE_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +typedef void* GRIN_PARTITIONED_GRAPH; +typedef unsigned GRIN_PARTITION; +typedef void* GRIN_PARTITION_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +typedef unsigned GRIN_PARTITION_ID; +#endif + +#ifdef GRIN_ENABLE_VERTEX_REF +typedef long long int GRIN_VERTEX_REF; +#endif + +#ifdef GRIN_ENABLE_EDGE_REF +typedef void* GRIN_EDGE_REF; +#endif + +#ifdef GRIN_WITH_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_TYPE; +typedef void* GRIN_VERTEX_TYPE_LIST; +typedef unsigned long long int GRIN_VERTEX_PROPERTY; +typedef void* GRIN_VERTEX_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +typedef unsigned GRIN_VERTEX_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_PROPERTY_ID; +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_TYPE; +typedef void* GRIN_EDGE_TYPE_LIST; +typedef void* GRIN_VEV_TYPE; +typedef void* GRIN_VEV_TYPE_LIST; +typedef unsigned long long int GRIN_EDGE_PROPERTY; +typedef void* GRIN_EDGE_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +typedef unsigned GRIN_EDGE_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_PROPERTY_ID; +#endif + +#ifdef GRIN_ENABLE_ROW +typedef void* GRIN_ROW; +#endif + +#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) +typedef void* GRIN_LABEL; +typedef void* GRIN_LABEL_LIST; +#endif + +/* Define invalid values for returns of handles */ +#define GRIN_NULL_GRAPH NULL +#define GRIN_NULL_VERTEX (unsigned long long int)~0 +#define GRIN_NULL_EDGE GRIN_EDGE{GRIN_NULL_VERTEX, GRIN_NULL_VERTEX, BOTH, (unsigned)~0, (unsigned long long int)~0} +#define GRIN_NULL_VERTEX_LIST NULL +#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL +#define GRIN_NULL_ADJACENT_LIST GRIN_ADJACENT_LIST{NULL, NULL, GRIN_NULL_VERTEX, BOTH, (unsigned)~0} +#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL +#define GRIN_NULL_PARTITIONED_GRAPH NULL +#define GRIN_NULL_PARTITION (unsigned)~0 +#define GRIN_NULL_PARTITION_LIST NULL +#define GRIN_NULL_PARTITION_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_REF -1 +#define GRIN_NULL_VERTEX_TYPE (unsigned)~0 +#define GRIN_NULL_VERTEX_TYPE_LIST NULL +#define GRIN_NULL_VERTEX_PROPERTY (unsigned long long int)~0 +#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL +#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE_LIST NULL +#define GRIN_NULL_VEV_TYPE NULL +#define GRIN_NULL_VEV_TYPE_LIST NULL +#define GRIN_NULL_EDGE_PROPERTY (unsigned long long int)~0 +#define GRIN_NULL_EDGE_PROPERTY_LIST NULL +#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 +#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_ROW NULL +#define GRIN_NULL_SIZE (unsigned)~0 +#define GRIN_NULL_NAME NULL + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/template/features.h b/flex/engines/graph_db/grin/include/template/features.h new file mode 100644 index 000000000000..d3ab7431e33f --- /dev/null +++ b/flex/engines/graph_db/grin/include/template/features.h @@ -0,0 +1,506 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file features.h + * @brief This file lists ALL the pre-defined macros for storage features, + * and it should NOT be included by users. + * Users should use the predefine.h of the specific storage. + * The macros are organized into several sections such as topology, + * partition, and so on. + * Storage implementors should Turn-ON (i.e., define) the specific + * macros in their predefine.h based the features of the storage. +*/ + +/* Section 1: Toplogy */ + +/** @name TopologyMacros + * @brief Macros for basic graph topology features + */ +///@{ +/** @ingroup TopologyMacros + * @brief The storage supports directed graphs. + */ +#define GRIN_ASSUME_HAS_DIRECTED_GRAPH + +/** @ingroup TopologyMacros + * @brief The storage supports undirected graphs. + */ +#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH + +/** @ingroup TopologyMacros + * @brief The storage supports multiple edges between a pair of vertices. + */ +#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH + +/** @ingroup TopologyMacros + * @brief There is data on vertex. E.g., the PageRank value of a vertex. + */ +#define GRIN_WITH_VERTEX_DATA + +/** @ingroup TopologyMacros + * @brief There is data on edge. E.g., the weight of an edge. +*/ +#define GRIN_WITH_EDGE_DATA + +/** @ingroup TopologyMacros + * @brief Enable the vertex list structure. + * It follows the design for Topology Lists. +*/ +#define GRIN_ENABLE_VERTEX_LIST + +/** @ingroup TopologyMacros + * @brief Enable the vertex list array-style retrieval. +*/ +#define GRIN_ENABLE_VERTEX_LIST_ARRAY + +/** @ingroup TopologyMacros + * @brief Enable the vertex list iterator. +*/ +#define GRIN_ENABLE_VERTEX_LIST_ITERATOR + +/** @ingroup TopologyMacros + * @brief Enable the edge list structure. + * It follows the design for Topology Lists. +*/ +#define GRIN_ENABLE_EDGE_LIST + +/** @ingroup TopologyMacros + * @brief Enable the edge list array-style retrieval. +*/ +#define GRIN_ENABLE_EDGE_LIST_ARRAY + +/** @ingroup TopologyMacros + * @brief Enable the edge list iterator. +*/ +#define GRIN_ENABLE_EDGE_LIST_ITERATOR + +/** @ingroup TopologyMacros + * @brief Enable the adjacent list structure. + * It follows the design for Topology Lists. +*/ +#define GRIN_ENABLE_ADJACENT_LIST + +/** @ingroup TopologyMacros + * @brief Enable the adjacent list array-style retrieval. +*/ +#define GRIN_ENABLE_ADJACENT_LIST_ARRAY + +/** @ingroup TopologyMacros + * @brief Enable the adjacent list iterator. +*/ +#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR +///@} + +/* End of Section 1 */ + +/* Section 2. Partition */ + +/** @name PartitionMacros + * @brief Macros for partitioned graph features + */ +///@{ +/** @ingroup PartitionMacros + * @brief Enable partitioned graph. A partitioned graph usually contains + * several fragments (i.e., local graphs) that are distributedly stored + * in a cluster. In GRIN, GRIN_GRAPH represents to a single fragment that can + * be locally accessed. + */ +#define GRIN_ENABLE_GRAPH_PARTITION + +/** @ingroup PartitionMacros + * @brief The storage provides natural number IDs for partitions. + * It follows the design of natural number ID trait in GRIN. +*/ +#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION + +/** @ingroup PartitionMacros + * @brief The storage provides reference of vertex that can be + * recognized in other partitions where the vertex also appears. +*/ +#define GRIN_ENABLE_VERTEX_REF + +/** @ingroup PartitionMacros + * @brief The storage provides fast reference of vertex, which means + * the vertex ref can be serialized into a int64 using + * grin_serialize_vertex_ref_as_int64 +*/ +#define GRIN_TRAIT_FAST_VERTEX_REF + +/** @ingroup PartitionMacros + * @brief The storage provides reference of edge that can be + * recognized in other partitions where the edge also appears. +*/ +#define GRIN_ENABLE_EDGE_REF +///@} + +/** @name PartitionStrategyMacros + * @brief Macros to define partition strategy assumptions, a partition strategy + * can be seen as a combination of detail partition assumptions which are defined after + * the strategies. Please refer to the documents for strategy details. +*/ +///@{ +/** @ingroup PartitionStrategyMacros + * @brief The storage ONLY uses all-replicate partition strategy. This means the + * storage's replicate the graph among all partitions. +*/ +#define GRIN_ASSUME_ALL_REPLICATE_PARTITION + +/** @ingroup PartitionStrategyMacros + * @brief The storage ONLY uses edge-cut partition strategy. This means the + * storage's entire partition strategy complies with edge-cut strategy + * definition in GRIN. +*/ +#define GRIN_ASSUME_EDGE_CUT_PARTITION + +/** @ingroup PartitionStrategyMacros + * @brief The storage ONLY uses edge-cut partition & edges only follow src strategy. + * This means the storage's entire partition strategy complies with edge-cut strategy + * definition in GRIN, and edges are partitioned to the partition of the source vertex. +*/ +#define GRIN_ASSUME_EDGE_CUT_FOLLOW_SRC_PARTITION + +/** @ingroup PartitionStrategyMacros + * @brief The storage ONLY uses edge-cut partition & edges only follow dst strategy. + * This means the storage's entire partition strategy complies with edge-cut strategy + * definition in GRIN, and edges are partitioned to the partition of the destination vertex. +*/ +#define GRIN_ASSUME_EDGE_CUT_FOLLOW_DST_PARTITION + + +/** @ingroup PartitionStrategyMacros + * @brief The storage ONLY uses vertex-cut partition strategy. This means the + * storage's entire partition strategy complies with vertex-cut strategy + * definition in GRIN. +*/ +#define GRIN_ASSUME_VERTEX_CUT_PARTITION +///@} + +/** @name PartitionAssumptionMacros + * @brief Macros to define detailed partition assumptions with respect to the + * concept of local complete. Please refer to the documents for the meaning of + * local complete. +*/ +///@{ +/** @ingroup PartitionAssumptionMacros + * @brief Assume the vertex data are only stored together with master vertices. +*/ +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_DATA + +/** @ingroup PartitionAssumptionMacros + * @brief Assume the vertex data are replicated on both master and mirror vertices. +*/ +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA + +/** @ingroup PartitionAssumptionMacros + * @brief Assume the edge data are only stored together with master edges. +*/ +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_DATA + +/** @ingroup PartitionAssumptionMacros + * @brief Assume the edge data are replicated on both master and mirror edges. +*/ +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA +///@} + +/** @name TraitMirrorPartitionMacros + * @brief Macros for storage that provides the partition list where the mirror + * vertices are located. This trait is usually enabled by storages using vertex-cut + * partition strategy. +*/ +///@{ +/** @ingroup TraitMirrorPartitionMacros + * @brief The storage provides the partition list where the mirror + * vertices are located of a local master vertex. +*/ +#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST + +/** @ingroup TraitMirrorPartitionMacros + * @brief The storage provides the partition list where the mirror + * vertices are located of a local mirror vertex +*/ +#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST + +/** @ingroup TraitMirrorPartitionMacros + * @brief The storage provides the partition list where the mirror + * edges are located of a local master edge +*/ +#define GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST + +/** @ingroup TraitMirrorPartitionMacros + * @brief The storage provides the partition list where the mirror + * edges are located of a local mirror edge +*/ +#define GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST +///@} + +/** @name TraitFilterMacros + * @brief Macros for storage that provides filtering ability of partitions for + * topology lists. This trait is usually enabled for efficient graph traversal. +*/ +///@{ +/** @ingroup TraitFilterMacros + * @brief The storage provides master vertex filtering for vertex list. + * This means suffix ``_select_master`` or ``_select_mirror`` can be added to a + * ``grin_get_vertex_list`` API to get a master-only or mirror-only vertex list. + * For example, ``grin_get_vertex_list_by_type_select_mirror`` returns + * a vertex list of a given type with mirror vertices only. +*/ +#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST + +/** @ingroup TraitFilterMacros + * @brief The storage provides per partition vertex filtering for vertex list. + * The suffix is ``_select_partition``. +*/ +#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST + +/** @ingroup TraitFilterMacros + * @brief The storage provides master edge filtering for edge list. + * The suffixes ``_select_master`` and ``_select_mirror`` + * are the same as vertex list. +*/ +#define GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST + +/** @ingroup TraitFilterMacros + * @brief The storage provides per partition edge filtering for edge list. + * The suffix is ``_select_partition``. +*/ +#define GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST + +/** @ingroup TraitFilterMacros + * @brief The storage provides master neighbor filtering for adjacent list. + * The suffixes are ``_select_master_neighbor`` and ``_select_mirror_neighbor``. +*/ +#define GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST + +/** @ingroup TraitFilterMacros + * @brief The storage provides per partition neighbor filtering for adjacent list. + * The suffix is ``_select_neighbor_partition``. +*/ +#define GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST +///@} + +/* End of Section 2 */ + +/* Section 3. Property */ + +/** @name PropertyMacros + * @brief Macros for basic property graph features + */ +///@{ +/** @ingroup PropertyMacros + * @brief Enable the pure value structure Row +*/ +#define GRIN_ENABLE_ROW + +/** @ingroup PropertyMacros + * @brief This trait is used to indicate the storage can return a pointer to the + * value of a property. However, this trait is going to be deprecated, because + * it is too complex to use related APIs in the computing side. +*/ +#define GRIN_TRAIT_CONST_VALUE_PTR + +/** @ingroup PropertyMacros + * @brief The graph has vertex properties, meaning it is a property graph. +*/ +#define GRIN_WITH_VERTEX_PROPERTY + +/** @ingroup PropertyMacros + * @brief There are property names for vertex properties. + * The relationship between property name and properties is one-to-many, + * because properties bound to different vertex types are distinguished + * even they may share the same property name. +*/ +#define GRIN_WITH_VERTEX_PROPERTY_NAME + +/** @ingroup PropertyMacros + * @brief There are unique names for each vertex type. +*/ +#define GRIN_WITH_VERTEX_TYPE_NAME + +/** @ingroup PropertyMacros + * @brief The storage provides natural number IDs for vertex types. + * It follows the design of natural ID trait in GRIN. +*/ +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE + +/** @ingroup PropertyMacros + * @brief There are primary keys for vertices. + * Consider each vertex type as a table in relational database, where + * the properties are the columns of the table. + * The storage supports setting a subset of the properties as the primary keys, + * meaning that each vertex of a certain type has its unique property values + * on the primary keys. +*/ +#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS + +/** @ingroup PropertyMacros + * @brief The storage provides natural number IDs for properties bound to + * a certain vertex type. + * It follows the design of natural ID trait in GRIN. +*/ +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY + +/** @ingroup PropertyMacros + * @brief The graph has edge properties, meaning it is a property graph. +*/ +#define GRIN_WITH_EDGE_PROPERTY + +/** @ingroup PropertyMacros + * @brief There are property names for edge properties. + * The relationship between property name and properties is one-to-many, + * because properties bound to different edge types are distinguished + * even they may share the same property name. +*/ +#define GRIN_WITH_EDGE_PROPERTY_NAME + +/** @ingroup PropertyMacros + * @brief There are unique names for each edge type. +*/ +#define GRIN_WITH_EDGE_TYPE_NAME + +/** @ingroup PropertyMacros + * @brief The storage provides natural number IDs for edge types. + * It follows the design of natural ID trait in GRIN. +*/ +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE + +/** @ingroup PropertyMacros + * @brief There are primary keys for edges. + * Consider each edge type as a table in relational database, where + * the properties are the columns of the table. + * The storage supports setting a subset of the properties as the primary keys, + * meaning that each edge of a certain type has its unique property values + * on the primary keys. +*/ +#define GRIN_ENABLE_EDGE_PRIMARY_KEYS + +/** @ingroup PropertyMacros + * @brief The storage provides natural number IDs for properties bound to + * a certain edge type. + * It follows the design of natural ID trait in GRIN. +*/ +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +///@} + +/** @name TraitFilterTypeMacros + * @brief Macros of traits to filter vertex/edge type for + * structures like vertex list and adjacent list. + */ +///@{ +/** @ingroup TraitFilterTypeMacros + * @brief The storage provides specific relationship description for each + * vertex-edge-vertex type traid. This means further optimizations can be + * applied by the callers for vev traid under certain relationships, such as + * one-to-one, one-to-many, or many-to-one. +*/ +#define GRIN_TRAIT_SPECIFIC_VEV_RELATION +///@} + +/** @name PropetyAssumptionMacros + * @brief Macros of assumptions for property local complete, and particularly define + * the by type local complete assumptions for hybrid partiton strategy. + */ +///@{ +/** @ingroup PropetyAssumptionMacros + * @brief Assume full property values of a vertex are ONLY stored with master vertices. +*/ +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY + +/** @ingroup PropetyAssumptionMacros + * @brief Assume full property values of a vertex are replicated with master and mirror vertices. +*/ +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY + +/** @ingroup PropetyAssumptionMacros + * @brief Assume full property values of a vertex are split among master and mirror vertices. +*/ +#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY + +/** @ingroup PropetyAssumptionMacros + * @brief Assume full property values of an edge are ONLY stored with master edges. +*/ +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY + +/** @ingroup PropetyAssumptionMacros + * @brief Assume full property values of an edge are replicated with master and mirror edges. +*/ +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY + +/** @ingroup PropetyAssumptionMacros + * @brief Assume full property values of an edge are split among master and mirror edges. +*/ +#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +///@} + +/* End of Section 3 */ + +/* Section 4. Index */ +/** @name IndexLabelMacros + * @brief Macros for label features + */ +///@{ +/** @ingroup IndexLabelMacros + * @brief Enable vertex label on graph. +*/ +#define GRIN_WITH_VERTEX_LABEL + +/** @ingroup IndexLabelMacros + * @brief Enable edge label on graph. +*/ +#define GRIN_WITH_EDGE_LABEL +///@} + +/** @name IndexOrderMacros + * @brief Macros for ordering features. + */ +///@{ +/** @ingroup IndexOrderMacros + * @brief assume all vertex list are sorted. + * We will expend the assumption to support master/mirror or + * by type in the future if needed. +*/ +#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED +///@} + +/** @name IndexInternalIDMacros + * @brief Macros for internal ID indexing features + */ +///@{ +/** @ingroup IndexInternalIDMacros + * @brief There is a unique internal ID of type int64 for each vertex, + * and most importantly the internal ID has a range. + */ +#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX +///@} + +/** @name IndexPKMacros + * @brief Macros for pk indexing features + */ +///@{ +/** @ingroup IndexPKMacros + * @brief Enable vertex indexing on primary keys, meaning that + * users can get a vertex handle using its primary key(s) value(s). + */ +#define GRIN_ENABLE_VERTEX_PK_INDEX + +/** @ingroup IndexPKMacros + * @brief Enable edge indexing on primary keys, meaning that + * users can get an edge handle using its primary key(s) value(s). + */ +#define GRIN_ENABLE_EDGE_PK_INDEX +///@} + +/* End of Section 4 */ diff --git a/flex/engines/graph_db/grin/include/template/predefine.h b/flex/engines/graph_db/grin/include/template/predefine.h new file mode 100644 index 000000000000..0a9e66ba433c --- /dev/null +++ b/flex/engines/graph_db/grin/include/template/predefine.h @@ -0,0 +1,273 @@ +/** Copyright 2020 Alibaba Group Holding Limited. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +/** + * @file predefine.h + * @brief This template file consists of four parts: + * 1. The predefined enumerate types of GRIN, which should NOT be modified. + * 2. The supported macros which should be specified by storage implementors + * based on storage features. + * 3. The typedefs of the enabled handles. This should be specified by storage. + * 4. The corresponding null values of the enabled handles. This should be + * specified by storage. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* 1. Predefined enumerate types of GRIN */ +/// Enumerates the directions of edges with respect to a certain vertex +typedef enum { + IN = 0, ///< incoming + OUT = 1, ///< outgoing + BOTH = 2, ///< incoming & outgoing +} GRIN_DIRECTION; + +/// Enumerates the datatype supported in the storage +typedef enum { + Undefined = 0, ///< other unknown types + Int32 = 1, ///< int + UInt32 = 2, ///< unsigned int + Int64 = 3, ///< long int + UInt64 = 4, ///< unsigned long int + Float = 5, ///< float + Double = 6, ///< double + String = 7, ///< string + Date32 = 8, ///< date + Time32 = 9, ///< Time32 + Timestamp64 = 10, ///< Timestamp +} GRIN_DATATYPE; + +/// Enumerates the error codes of grin +typedef enum { + NO_ERROR = 0, ///< success + UNKNOWN_ERROR = 1, ///< unknown error + INVALID_VALUE = 2, ///< invalid value + UNKNOWN_DATATYPE = 3, ///< unknown datatype +} GRIN_ERROR_CODE; + +/* 2. Define supported macros based on storage features */ +// Topology +#define GRIN_ASSUME_HAS_DIRECTED_GRAPH +#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH +#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH +#define GRIN_WITH_VERTEX_DATA +#define GRIN_WITH_EDGE_DATA +#define GRIN_ENABLE_VERTEX_LIST +#define GRIN_ENABLE_VERTEX_LIST_ARRAY +#define GRIN_ENABLE_VERTEX_LIST_ITERATOR +#define GRIN_ENABLE_EDGE_LIST +#define GRIN_ENABLE_EDGE_LIST_ARRAY +#define GRIN_ENABLE_EDGE_LIST_ITERATOR +#define GRIN_ENABLE_ADJACENT_LIST +#define GRIN_ENABLE_ADJACENT_LIST_ARRAY +#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR +// Partition +#define GRIN_ENABLE_GRAPH_PARTITION +#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +#define GRIN_ENABLE_VERTEX_REF +#define GRIN_TRAIT_FAST_VERTEX_REF +#define GRIN_ENABLE_EDGE_REF +#define GRIN_ASSUME_ALL_REPLICATE_PARTITION +#define GRIN_ASSUME_EDGE_CUT_PARTITION +#define GRIN_ASSUME_EDGE_CUT_FOLLOW_SRC_PARTITION +#define GRIN_ASSUME_EDGE_CUT_FOLLOW_DST_PARTITION +#define GRIN_ASSUME_VERTEX_CUT_PARTITION +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_DATA +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_DATA +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA +#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST +#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST +#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST +#define GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST +#define GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST +#define GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST +#define GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST +// Property +#define GRIN_ENABLE_ROW +#define GRIN_TRAIT_CONST_VALUE_PTR +#define GRIN_WITH_VERTEX_PROPERTY +#define GRIN_WITH_VERTEX_PROPERTY_NAME +#define GRIN_WITH_VERTEX_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS +#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY +#define GRIN_WITH_EDGE_PROPERTY_NAME +#define GRIN_WITH_EDGE_TYPE_NAME +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +#define GRIN_ENABLE_EDGE_PRIMARY_KEYS +#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +#define GRIN_TRAIT_SPECIFIC_VEV_RELATION +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY +#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY +#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY +// Index +#define GRIN_WITH_VERTEX_LABEL +#define GRIN_WITH_EDGE_LABEL +#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED +#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX +#define GRIN_ENABLE_VERTEX_PK_INDEX +#define GRIN_ENABLE_EDGE_PK_INDEX + +/* 3. Define the handles using typedef */ +typedef void* GRIN_GRAPH; +typedef void* GRIN_VERTEX; +typedef void* GRIN_EDGE; + +#ifdef GRIN_WITH_VERTEX_DATA +typedef void* GRIN_VERTEX_DATA; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST +typedef void* GRIN_VERTEX_LIST; +#endif + +#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR +typedef void* GRIN_VERTEX_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef void* GRIN_ADJACENT_LIST; +#endif + +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +typedef void* GRIN_ADJACENT_LIST_ITERATOR; +#endif + +#ifdef GRIN_WITH_EDGE_DATA +typedef void* GRIN_EDGE_DATA; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST +typedef void* GRIN_EDGE_LIST; +#endif + +#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR +typedef void* GRIN_EDGE_LIST_ITERATOR; +#endif + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +typedef void* GRIN_PARTITIONED_GRAPH; +typedef void* GRIN_PARTITION; +typedef void* GRIN_PARTITION_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION +typedef unsigned GRIN_PARTITION_ID; +#endif + +#ifdef GRIN_ENABLE_VERTEX_REF +typedef void* GRIN_VERTEX_REF; +#endif + +#ifdef GRIN_ENABLE_EDGE_REF +typedef void* GRIN_EDGE_REF; +#endif + + +#ifdef GRIN_WITH_VERTEX_PROPERTY +typedef void* GRIN_VERTEX_TYPE; +typedef void* GRIN_VERTEX_TYPE_LIST; +typedef void* GRIN_VERTEX_PROPERTY; +typedef void* GRIN_VERTEX_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE +typedef unsigned GRIN_VERTEX_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY +typedef unsigned GRIN_VERTEX_PROPERTY_ID; +#endif + +#ifdef GRIN_WITH_EDGE_PROPERTY +typedef void* GRIN_EDGE_TYPE; +typedef void* GRIN_EDGE_TYPE_LIST; +typedef void* GRIN_VEV_TYPE; +typedef void* GRIN_VEV_TYPE_LIST; +typedef void* GRIN_EDGE_PROPERTY; +typedef void* GRIN_EDGE_PROPERTY_LIST; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE +typedef unsigned GRIN_EDGE_TYPE_ID; +#endif + +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY +typedef unsigned GRIN_EDGE_PROPERTY_ID; +#endif + +#ifdef GRIN_ENABLE_ROW +typedef void* GRIN_ROW; +#endif + +#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) +typedef void* GRIN_LABEL; +typedef void* GRIN_LABEL_LIST; +#endif + +/* 4. Define invalid values for returns of handles */ +#define GRIN_NULL_GRAPH NULL +#define GRIN_NULL_VERTEX NULL +#define GRIN_NULL_EDGE NULL +#define GRIN_NULL_VERTEX_DATA NULL +#define GRIN_NULL_VERTEX_LIST NULL +#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL +#define GRIN_NULL_ADJACENT_LIST NULL +#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL +#define GRIN_NULL_EDGE_DATA NULL +#define GRIN_NULL_EDGE_LIST NULL +#define GRIN_NULL_EDGE_LIST_ITERATOR NULL +#define GRIN_NULL_PARTITIONED_GRAPH NULL +#define GRIN_NULL_PARTITION NULL +#define GRIN_NULL_PARTITION_LIST NULL +#define GRIN_NULL_PARTITION_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_REF NULL +#define GRIN_NULL_EDGE_REF NULL +#define GRIN_NULL_VERTEX_TYPE NULL +#define GRIN_NULL_VERTEX_TYPE_LIST NULL +#define GRIN_NULL_VERTEX_PROPERTY NULL +#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL +#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 +#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_EDGE_TYPE NULL +#define GRIN_NULL_EDGE_TYPE_LIST NULL +#define GRIN_NULL_VEV_TYPE NULL +#define GRIN_NULL_VEV_TYPE_LIST NULL +#define GRIN_NULL_EDGE_PROPERTY NULL +#define GRIN_NULL_EDGE_PROPERTY_LIST NULL +#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 +#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 +#define GRIN_NULL_ROW NULL +#define GRIN_NULL_LABEL NULL +#define GRIN_NULL_LABEL_LIST NULL +#define GRIN_NULL_SIZE (unsigned)~0 +#define GRIN_NULL_NAME NULL + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/test/test.c b/flex/engines/graph_db/grin/include/test/test.c new file mode 100644 index 000000000000..af77a0917521 --- /dev/null +++ b/flex/engines/graph_db/grin/include/test/test.c @@ -0,0 +1,1052 @@ +#include +#include +#include +#include +#include "predefine.h" +#include "common/error.h" +#include "index/internal_id.h" +#include "index/label.h" +#include "index/order.h" +#include "index/pk.h" +#include "partition/partition.h" +#include "partition/reference.h" +#include "partition/topology.h" +#include "property/partition.h" +#include "property/primarykey.h" +#include "property/property.h" +#include "property/propertylist.h" +#include "property/row.h" +#include "property/topology.h" +#include "property/type.h" +#include "topology/adjacentlist.h" +#include "topology/edgelist.h" +#include "topology/structure.h" +#include "topology/vertexlist.h" + + +#define FOR_VERTEX_BEGIN(g, vl, v) \ + GRIN_VERTEX_LIST_ITERATOR __vli = grin_get_vertex_list_begin(g, vl); \ + unsigned __vcnt = 0; \ + while (!grin_is_vertex_list_end(g, __vli)) { \ + GRIN_VERTEX v = grin_get_vertex_from_iter(g, __vli); \ + +#ifdef GRIN_WITH_VERTEX_PROPERTY +#define FOR_VERTEX_END(g, vl, v) \ + grin_destroy_vertex(g, v); \ + __vcnt++; \ + grin_get_next_vertex_list_iter(g, __vli); \ + } \ + printf("vertex type %s, checked: %u\n", vt_names[__vtl_i], __vcnt); + +#define FOR_VERTEX_LIST_BEGIN(g, vl) \ +{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ +{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ +{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ + size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ + for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ + GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_mirror(g, __vt); \ + grin_destroy_vertex_type(g, __vt); + +#define FOR_VERTEX_LIST_END(g, vl) \ + grin_destroy_vertex_list(g, vl); \ + } \ + grin_destroy_vertex_type_list(g, __vtl);} +#else +#define FOR_VERTEX_END(g, vl) \ + grin_destroy_vertex(g, v); \ + __vcnt++; \ + grin_get_next_vertex_list_iter(g, __vli); \ + } \ + printf("vertex checked: %u\n", __vcnt); + +#define FOR_VERTEX_LIST_BEGIN(g, vl) \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list(g); + +#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_master(g); + +#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ + GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_mirror(g); + +#define FOR_VERTEX_LIST_END(g, vl) \ + grin_destroy_vertex_list(g, vl); +#endif + + + +#ifdef GRIN_WITH_EDGE_PROPERTY +#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ +{ GRIN_EDGE_TYPE_LIST __etl = grin_get_edge_type_list(g); \ + size_t __etl_size = grin_get_edge_type_list_size(g, __etl); \ + for (size_t __etl_i = 0; __etl_i < __etl_size; ++__etl_i) { \ + GRIN_EDGE_TYPE __et = grin_get_edge_type_from_list(g, __etl, __etl_i); \ + GRIN_ADJACENT_LIST al = grin_get_adjacent_list_by_edge_type(g, dir, v, __et); \ + grin_destroy_edge_type(g, __et); +#define FOR_ADJ_LIST_END(g, al) \ + grin_destroy_adjacent_list(g, al); \ + } \ + grin_destroy_edge_type_list(g, __etl);} +#else +#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ + GRIN_ADJACENT_LIST al = grin_get_adjacent_list(g, dir, v); +#define FOR_ADJ_LIST_END(g, al) \ + grin_destroy_adjacent_list(g, al); +#endif + + +const char *vt_names[] = {"person", "software"}; +const char *et_names[] = {"created", "knows"}; + +const char *v_names[][4] = { + {"josh", "vadas", "peter", "marko"}, + {"lop", "ripple", "wrong", "wrong"} +}; // TODO align with order in local graph + +GRIN_GRAPH get_graph(int argc, char** argv, int p) { +#ifdef GRIN_ENABLE_GRAPH_PARTITION + GRIN_PARTITIONED_GRAPH pg = + grin_get_partitioned_graph_from_storage(argv[1]); + GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); + assert(p < grin_get_partition_list_size(pg, local_partitions)); + GRIN_PARTITION partition = + grin_get_partition_from_list(pg, local_partitions, p); + GRIN_PARTITION_ID partition_id = grin_get_partition_id(pg, partition); + GRIN_PARTITION p1 = grin_get_partition_by_id(pg, partition_id); + if (!grin_equal_partition(pg, partition, p1)) { + printf("partition not match\n"); + } + grin_destroy_partition(pg, p1); + GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition); + grin_destroy_partition(pg, partition); + grin_destroy_partition_list(pg, local_partitions); + grin_destroy_partitioned_graph(pg); +#else + GRIN_GRAPH g = grin_get_graph_from_storage(argv[1]); +#endif + return g; +} + + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +GRIN_VERTEX get_one_master_person(GRIN_GRAPH g) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, vt); + grin_destroy_vertex_type(g, vt); + GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin(g, vl); + GRIN_VERTEX v = grin_get_vertex_from_iter(g, vli); + grin_destroy_vertex_list_iter(g, vli); + grin_destroy_vertex_list(g, vl); +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); +#endif + return v; +} +#endif + + +GRIN_VERTEX get_one_person(GRIN_GRAPH g) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, vt); + grin_destroy_vertex_type(g, vt); + GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin(g, vl); + GRIN_VERTEX v = grin_get_vertex_from_iter(g, vli); + grin_destroy_vertex_list_iter(g, vli); + grin_destroy_vertex_list(g, vl); +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); +#endif + return v; +} + + +void test_property_type(int argc, char** argv) { + printf("+++++++++++++++++++++ Test property/type +++++++++++++++++++++\n"); + + GRIN_GRAPH g = get_graph(argc, argv, 0); + + printf("------------ Vertex Type ------------\n"); + GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); + size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); + printf("vertex type list size: %zu\n", vtl_size); + + for (size_t i = 0; i < vtl_size; ++i) { + printf("------------ Iterate the %zu-th vertex type ------------\n", i); + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); +#ifdef GRIN_WITH_VERTEX_TYPE_NAME + const char* vt_name = grin_get_vertex_type_name(g, vt); + printf("vertex type name: %s\n", vt_name); + GRIN_VERTEX_TYPE vt0 = grin_get_vertex_type_by_name(g, vt_name); + if (!grin_equal_vertex_type(g, vt, vt0)) { + printf("vertex type name not match\n"); + } + grin_destroy_vertex_type(g, vt0); +#endif +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE + printf("vertex type id: %u\n", grin_get_vertex_type_id(g, vt)); + GRIN_VERTEX_TYPE vt1 = + grin_get_vertex_type_by_id(g, grin_get_vertex_type_id(g, vt)); + if (!grin_equal_vertex_type(g, vt, vt1)) { + printf("vertex type id not match\n"); + } + grin_destroy_vertex_type(g, vt1); +#endif + } + grin_destroy_vertex_type_list(g, vtl); + + printf( + "------------ Create a vertex type list of one type \"person\" " + "------------\n"); + GRIN_VERTEX_TYPE_LIST vtl2 = grin_create_vertex_type_list(g); +#ifdef GRIN_WITH_VERTEX_TYPE_NAME + GRIN_VERTEX_TYPE vt2_w = grin_get_vertex_type_by_name(g, "knows"); + if (vt2_w == GRIN_NULL_VERTEX_TYPE) { + printf("(Correct) vertex type of knows does not exists\n"); + } + GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "person"); + if (vt2 == GRIN_NULL_VERTEX_TYPE) { + printf("(Wrong) vertex type of person can not be found\n"); + } else { + const char* vt2_name = grin_get_vertex_type_name(g, vt2); + printf("vertex type name: %s\n", vt2_name); + } +#else + GRIN_VERTEX_TYPE vt2 = get_one_vertex_type(g); +#endif + grin_insert_vertex_type_to_list(g, vtl2, vt2); + size_t vtl2_size = grin_get_vertex_type_list_size(g, vtl2); + printf("created vertex type list size: %zu\n", vtl2_size); + GRIN_VERTEX_TYPE vt3 = grin_get_vertex_type_from_list(g, vtl2, 0); + if (!grin_equal_vertex_type(g, vt2, vt3)) { + printf("vertex type not match\n"); + } + grin_destroy_vertex_type(g, vt2); + grin_destroy_vertex_type(g, vt3); + grin_destroy_vertex_type_list(g, vtl2); + + // edge + printf("------------ Edge Type ------------\n"); + GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); + size_t etl_size = grin_get_edge_type_list_size(g, etl); + printf("edge type list size: %zu\n", etl_size); + + for (size_t i = 0; i < etl_size; ++i) { + printf("------------ Iterate the %zu-th edge type ------------\n", i); + GRIN_EDGE_TYPE et = grin_get_edge_type_from_list(g, etl, i); +#ifdef GRIN_WITH_EDGE_TYPE_NAME + const char* et_name = grin_get_edge_type_name(g, et); + printf("edge type name: %s\n", et_name); + GRIN_EDGE_TYPE et0 = grin_get_edge_type_by_name(g, et_name); + if (!grin_equal_edge_type(g, et, et0)) { + printf("edge type name not match\n"); + } + grin_destroy_edge_type(g, et0); +#endif +#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE + printf("edge type id: %u\n", grin_get_edge_type_id(g, et)); + GRIN_EDGE_TYPE et1 = + grin_get_edge_type_by_id(g, grin_get_edge_type_id(g, et)); + if (!grin_equal_edge_type(g, et, et1)) { + printf("edge type id not match\n"); + } + grin_destroy_edge_type(g, et1); +#endif + // relation + GRIN_VERTEX_TYPE_LIST src_vtl = grin_get_src_types_by_edge_type(g, et); + size_t src_vtl_size = grin_get_vertex_type_list_size(g, src_vtl); + printf("source vertex type list size: %zu\n", src_vtl_size); + + GRIN_VERTEX_TYPE_LIST dst_vtl = grin_get_dst_types_by_edge_type(g, et); + size_t dst_vtl_size = grin_get_vertex_type_list_size(g, dst_vtl); + printf("destination vertex type list size: %zu\n", dst_vtl_size); + + if (src_vtl_size != dst_vtl_size) { + printf("source and destination vertex type list size not match\n"); + } + for (size_t j = 0; j < src_vtl_size; ++j) { + GRIN_VERTEX_TYPE src_vt = grin_get_vertex_type_from_list(g, src_vtl, j); + GRIN_VERTEX_TYPE dst_vt = grin_get_vertex_type_from_list(g, dst_vtl, j); + const char* src_vt_name = grin_get_vertex_type_name(g, src_vt); + const char* dst_vt_name = grin_get_vertex_type_name(g, dst_vt); + const char* et_name = grin_get_edge_type_name(g, et); + printf("edge type name: %s-%s-%s\n", src_vt_name, et_name, dst_vt_name); + grin_destroy_vertex_type(g, src_vt); + grin_destroy_vertex_type(g, dst_vt); + } + grin_destroy_vertex_type_list(g, src_vtl); + grin_destroy_vertex_type_list(g, dst_vtl); + } + grin_destroy_edge_type_list(g, etl); + + printf( + "------------ Create an edge type list of one type \"created\" " + "------------\n"); + GRIN_EDGE_TYPE_LIST etl2 = grin_create_edge_type_list(g); +#ifdef GRIN_WITH_EDGE_TYPE_NAME + GRIN_EDGE_TYPE et2_w = grin_get_edge_type_by_name(g, "person"); + if (et2_w == GRIN_NULL_EDGE_TYPE) { + printf("(Correct) edge type of person does not exists\n"); + } + GRIN_EDGE_TYPE et2 = grin_get_edge_type_by_name(g, "created"); + if (et2 == GRIN_NULL_EDGE_TYPE) { + printf("(Wrong) edge type of created can not be found\n"); + } else { + const char* et2_name = grin_get_edge_type_name(g, et2); + printf("edge type name: %s\n", et2_name); + } +#else + GRIN_EDGE_TYPE et2 = get_one_edge_type(g); +#endif + grin_insert_edge_type_to_list(g, etl2, et2); + size_t etl2_size = grin_get_edge_type_list_size(g, etl2); + printf("created edge type list size: %zu\n", etl2_size); + GRIN_EDGE_TYPE et3 = grin_get_edge_type_from_list(g, etl2, 0); + if (!grin_equal_edge_type(g, et2, et3)) { + printf("edge type not match\n"); + } + grin_destroy_edge_type(g, et2); + grin_destroy_edge_type(g, et3); + grin_destroy_edge_type_list(g, etl2); + + grin_destroy_graph(g); +} + +void test_property_vertex_property_value(int argc, char** argv) { + printf("------------ Test Vertex property value ------------\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + +// value check + printf("------ check value ------\n"); +FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, __vt); + size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + #else + long long int vid = __vcnt; + #endif + #ifdef GRIN_ENABLE_ROW + GRIN_ROW row = grin_get_vertex_row(g, v); + #endif + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); + if (dt == Int64) { + long long int pv = + grin_get_vertex_property_value_of_int64(g, v, vp); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + long long int rv = grin_get_int64_from_row(g, row, j); + assert(pv == rv); + #endif + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + printf("%s %s: %lld\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); + #else + printf("%s %zu: %lld\n", v_names[__vt][vid], j, pv); + #endif + } else if (dt == String) { + const char* pv = + grin_get_vertex_property_value_of_string(g, v, vp); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + const char* rv = grin_get_string_from_row(g, row, j); + assert(strcmp(pv, rv) == 0); + #endif + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + printf("%s %s: %s\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); + #else + printf("%s %zu: %s\n", v_names[__vt][vid], j, pv); + #endif + grin_destroy_string_value(g, pv); + grin_destroy_string_value(g, rv); + } + grin_destroy_vertex_property(g, vp); + } + #ifdef GRIN_ENABLE_ROW + grin_destroy_row(g, row); + #endif + FOR_VERTEX_END(g, vl, v) + grin_destroy_vertex_property_list(g, vpl); +FOR_VERTEX_LIST_END(g, vl) + +// check schema + printf("------ check schema ------\n"); + GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); + size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); + for (size_t i = 0; i < vtl_size; ++i) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, vt); + size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_from_property(g, vp); + assert(grin_equal_vertex_type(g, vt, vt1)); + grin_destroy_vertex_type(g, vt1); + + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY + unsigned int id = grin_get_vertex_property_id(g, vt, vp); + GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id); + assert(grin_equal_vertex_property(g, vp, vp1)); + grin_destroy_vertex_property(g, vp1); + #else + unsigned int id = i; + #endif + + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + const char* vp_name = grin_get_vertex_property_name(g, vt, vp); + GRIN_VERTEX_PROPERTY vp2 = + grin_get_vertex_property_by_name(g, vt, vp_name); + assert(grin_equal_vertex_property(g, vp, vp2)); + #else + const char* vp_name = "unknown"; + #endif + printf("%s %u %s checked\n", vt_names[i], id, vp_name); + } + grin_destroy_vertex_property_list(g, vpl); + + // corner case + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY + GRIN_VERTEX_PROPERTY vp3 = grin_get_vertex_property_by_id(g, vt, vpl_size); + assert(vp3 == GRIN_NULL_VERTEX_PROPERTY); + #endif + + #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + GRIN_VERTEX_PROPERTY vp4 = + grin_get_vertex_property_by_name(g, vt, "unknown"); + assert(vp4 == GRIN_NULL_VERTEX_PROPERTY); + #endif + grin_destroy_vertex_type(g, vt); + } + grin_destroy_vertex_type_list(g, vtl); + + // corner case +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + GRIN_VERTEX_PROPERTY_LIST vpl1 = + grin_get_vertex_properties_by_name(g, "unknown"); + assert(vpl1 == GRIN_NULL_VERTEX_PROPERTY_LIST); + + GRIN_VERTEX_PROPERTY_LIST vpl2 = + grin_get_vertex_properties_by_name(g, "name"); + assert(vpl2 != GRIN_NULL_VERTEX_PROPERTY_LIST); + + size_t vpl2_size = grin_get_vertex_property_list_size(g, vpl2); + for (size_t i = 0; i < vpl2_size; ++i) { + GRIN_VERTEX_PROPERTY vp5 = + grin_get_vertex_property_from_list(g, vpl2, i); + GRIN_VERTEX_TYPE vt5 = grin_get_vertex_type_from_property(g, vp5); + const char* vp5_name = grin_get_vertex_property_name(g, vt5, vp5); + assert(strcmp(vp5_name, "name") == 0); + } + grin_destroy_vertex_property_list(g, vpl2); +#endif + + grin_destroy_graph(g); +} + +void test_property_edge_property_value(int argc, char** argv, GRIN_DIRECTION dir) { + printf("------------ Test Edge property value ------------\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + +// value check + printf("------ check value ------\n"); +FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + FOR_ADJ_LIST_BEGIN(g, dir, v, al) + GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, __et); + size_t epl_size = grin_get_edge_property_list_size(g, epl); + + GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); + size_t acnt = 0; + while (!grin_is_adjacent_list_end(g, ali)) { + GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); + GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); + #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + GRIN_VERTEX_TYPE ut = grin_get_vertex_type(g, u); + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + long long int uid = grin_get_vertex_internal_id_by_type(g, ut, u); + grin_destroy_vertex_type(g, ut); + #else + long long int vid = __vcnt; + long long int uid = acnt; + #endif + #ifdef GRIN_ENABLE_ROW + GRIN_ROW row = grin_get_edge_row(g, e); + #endif + for (size_t j = 0; j < epl_size; ++j) { + GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); + GRIN_DATATYPE dt = grin_get_edge_property_datatype(g, ep); + if (dt == Int64) { + long long int pv = + grin_get_edge_property_value_of_int64(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + long long int rv = grin_get_int64_from_row(g, row, j); + assert(pv == rv); + #endif + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %lld\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); + #else + printf("%s %zu %lld: %lld\n", v_names[__vt][vid], j, uid, pv); + #endif + } else if (dt == Double) { + double pv = grin_get_edge_property_value_of_double(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + double rv = grin_get_double_from_row(g, row, j); + assert(pv == rv); + #endif + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %lf\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); + #else + printf("%s %zu %lld: %lf\n", v_names[__vt][vid], j, uid, pv); + #endif + } else if (dt == String) { + const char* pv = grin_get_edge_property_value_of_string(g, e, ep); + assert(grin_get_last_error_code() == NO_ERROR); + #ifdef GRIN_ENABLE_ROW + const char* rv = grin_get_string_from_row(g, row, j); + assert(strcmp(pv, rv) == 0); + #endif + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + printf("%s %s %s: %s\n", v_names[__vt][vid], v_names[ut][uid], + grin_get_edge_property_name(g, __et, ep), pv); + #else + printf("%s %zu %lld: %s\n", v_names[__vt][vid], j, uid, pv); + #endif + } + } + #ifdef GRIN_ENABLE_ROW + grin_destroy_row(g, row); + #endif + grin_destroy_edge(g, e); + grin_destroy_vertex(g, u); + acnt++; + grin_get_next_adjacent_list_iter(g, ali); + } + grin_destroy_adjacent_list_iter(g, ali); + grin_destroy_edge_property_list(g, epl); + FOR_ADJ_LIST_END(g, al) + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + +// check schema + printf("------ check schema ------\n"); + GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); + size_t etl_size = grin_get_edge_type_list_size(g, etl); + for (size_t i = 0; i < etl_size; ++i) { + GRIN_EDGE_TYPE et = grin_get_edge_type_from_list(g, etl, i); + GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, et); + size_t epl_size = grin_get_edge_property_list_size(g, epl); + for (size_t j = 0; j < epl_size; ++j) { + GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); + GRIN_EDGE_TYPE et1 = grin_get_edge_type_from_property(g, ep); + assert(grin_equal_edge_type(g, et, et1)); + grin_destroy_edge_type(g, et1); + + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY + unsigned int id = grin_get_edge_property_id(g, et, ep); + GRIN_EDGE_PROPERTY ep1 = grin_get_edge_property_by_id(g, et, id); + assert(grin_equal_edge_property(g, ep, ep1)); + grin_destroy_edge_property(g, ep1); + #else + unsigned int id = i; + #endif + + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + const char* ep_name = grin_get_edge_property_name(g, et, ep); + GRIN_EDGE_PROPERTY ep2 = + grin_get_edge_property_by_name(g, et, ep_name); + assert(grin_equal_edge_property(g, ep, ep2)); + #else + const char* ep_name = "unknown"; + #endif + printf("%s %u %s checked\n", et_names[i], id, ep_name); + } + grin_destroy_edge_property_list(g, epl); + + // corner case + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY + GRIN_EDGE_PROPERTY ep3 = grin_get_edge_property_by_id(g, et, epl_size); + assert(ep3 == GRIN_NULL_EDGE_PROPERTY); + #endif + + #ifdef GRIN_WITH_EDGE_PROPERTY_NAME + GRIN_EDGE_PROPERTY ep4 = + grin_get_edge_property_by_name(g, et, "unknown"); + assert(ep4 == GRIN_NULL_EDGE_PROPERTY); + #endif + grin_destroy_edge_type(g, et); + } + grin_destroy_edge_type_list(g, etl); + + // corner case +#ifdef GRIN_WITH_EDGE_PROPERTY_NAME + GRIN_EDGE_PROPERTY_LIST epl1 = + grin_get_edge_properties_by_name(g, "unknown"); + assert(epl1 == GRIN_NULL_EDGE_PROPERTY_LIST); + + GRIN_EDGE_PROPERTY_LIST epl2 = + grin_get_edge_properties_by_name(g, "weight"); + assert(epl2 != GRIN_NULL_EDGE_PROPERTY_LIST); + + size_t epl2_size = grin_get_edge_property_list_size(g, epl2); + for (size_t i = 0; i < epl2_size; ++i) { + GRIN_EDGE_PROPERTY ep5 = + grin_get_edge_property_from_list(g, epl2, i); + GRIN_EDGE_TYPE et5 = grin_get_edge_type_from_property(g, ep5); + const char* ep5_name = grin_get_edge_property_name(g, et5, ep5); + assert(strcmp(ep5_name, "weight") == 0); + } + grin_destroy_edge_property_list(g, epl2); +#endif + + grin_destroy_graph(g); +} + + +#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS +void test_property_primary_key(int argc, char** argv) { + printf( + "+++++++++++++++++++++ Test property/primary key " + "+++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_types_with_primary_keys(g); + size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); + printf("vertex type num with primary key: %zu\n", vtl_size); + + unsigned id_type[7] = {~0, 0, 0, 1, 0, 1, 0}; + + for (size_t i = 0; i < vtl_size; ++i) { + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); + const char* vt_name = grin_get_vertex_type_name(g, vt); + printf("vertex type name: %s\n", vt_name); + + GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_primary_keys_by_vertex_type(g, vt); + size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); + assert(vpl_size == 1); + + for (size_t j = 0; j < vpl_size; ++j) { + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); + const char* vp_name = grin_get_vertex_property_name(g, vt, vp); + printf("primary key name: %s\n", vp_name); + grin_destroy_vertex_property(g, vp); + } + + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, 0); + GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); + + for (size_t j = 1; j <= 6; ++j) { + GRIN_ROW r = grin_create_row(g); + assert(dt == Int64); + grin_insert_int64_to_row(g, r, j); +#ifdef GRIN_ENABLE_VERTEX_PK_INDEX + GRIN_VERTEX v = grin_get_vertex_by_primary_keys_row(g, vt, r); + if (v != GRIN_NULL_VERTEX && id_type[j] == i) { + GRIN_ROW nr = grin_get_vertex_primary_keys_row(g, v); + long long int k = grin_get_int64_from_row(g, nr, 0); + assert(k == j); + grin_destroy_row(g, nr); + grin_destroy_vertex(g, v); + } +#endif + grin_destroy_row(g, r); + } + + grin_destroy_vertex_property(g, vp); + grin_destroy_vertex_property_list(g, vpl); + grin_destroy_vertex_type(g, vt); + } + + grin_destroy_vertex_type_list(g, vtl); + grin_destroy_graph(g); +} +#endif + +void test_error_code(int argc, char** argv) { + printf("+++++++++++++++++++++ Test error code +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + + GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "software"); + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt2, "lang"); +#ifdef GRIN_ENABLE_GRAPH_PARTITION + GRIN_VERTEX v = get_one_master_person(g); +#else + GRIN_VERTEX v = get_one_person(g); +#endif + + const char* value = grin_get_vertex_property_value_of_string(g, v, vp); + assert(grin_get_last_error_code() == INVALID_VALUE); +} + + +void test_property(int argc, char** argv) { + test_property_type(argc, argv); + test_property_vertex_property_value(argc, argv); + test_property_edge_property_value(argc, argv, OUT); + test_property_edge_property_value(argc, argv, IN); +#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS + test_property_primary_key(argc, argv); +#endif +#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME + // test_error_code(argc, argv); +#endif +} + + +void test_partition_reference(int argc, char** argv) { + printf("+++++++++++++++++++++ Test partition/reference +++++++++++++++++++++\n"); + GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(argv[1]); + GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); + assert(grin_get_partition_list_size(pg, local_partitions) >= 2); + + GRIN_PARTITION p0 = grin_get_partition_from_list(pg, local_partitions, 0); + GRIN_PARTITION p1 = grin_get_partition_from_list(pg, local_partitions, 1); + GRIN_GRAPH g0 = grin_get_local_graph_by_partition(pg, p0); + GRIN_GRAPH g1 = grin_get_local_graph_by_partition(pg, p1); + +FOR_VERTEX_LIST_BEGIN(g0, vl0) + size_t mcnt = 0; + FOR_VERTEX_BEGIN(g0, vl0, v0) + GRIN_VERTEX_REF vref0 = grin_get_vertex_ref_by_vertex(g0, v0); + if (grin_is_master_vertex(g0, v0)) { + mcnt++; +#ifdef GRIN_TRAIT_FAST_VERTEX_REF + long long int sref = grin_serialize_vertex_ref_as_int64(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_int64_to_vertex_ref(g0, sref); +#else + const char* sref = grin_serialize_vertex_ref(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_vertex_ref(g0, sref); + grin_destroy_string_value(g0, sref); +#endif + GRIN_VERTEX v1 = grin_get_vertex_from_vertex_ref(g0, vref1); + if (!grin_equal_vertex(g0, v0, v1)) { + printf("vertex not match after deserialize\n"); + } + GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); + if (!grin_equal_partition(g0, p, p0)) { + printf("(Wrong) partition not match in vertex ref\n"); + } + grin_destroy_partition(pg, p); + grin_destroy_vertex(g0, v1); + grin_destroy_vertex_ref(g0, vref1); + } else if (grin_is_mirror_vertex(g0, v0)) { +#ifdef GRIN_TRAIT_FAST_VERTEX_REF + long long int sref = grin_serialize_vertex_ref_as_int64(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_int64_to_vertex_ref(g1, sref); +#else + const char* sref = grin_serialize_vertex_ref(g0, vref0); + GRIN_VERTEX_REF vref1 = grin_deserialize_vertex_ref(g1, sref); + grin_destroy_string_value(g0, sref); +#endif + GRIN_VERTEX v1 = grin_get_vertex_from_vertex_ref(g1, vref1); + if (!grin_is_master_vertex(g1, v1)) { + printf("(Wrong) vertex not master after deserialize\n"); + } + GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); + if (!grin_equal_partition(g0, p, p1)) { + printf("(Wrong) partition not match in vertex ref\n"); + } + grin_destroy_partition(pg, p); + grin_destroy_vertex(g1, v1); + grin_destroy_vertex_ref(g1, vref1); + } else { + printf("(Wrong) vertex other than master or mirror\n"); + } + grin_destroy_vertex_ref(g0, vref0); + FOR_VERTEX_END(g0, vl0, v0) + printf("master checked: %zu\n", mcnt); +FOR_VERTEX_LIST_END(g0, vl0) + + grin_destroy_partition(pg, p0); + grin_destroy_partition(pg, p1); + grin_destroy_graph(g0); + grin_destroy_graph(g1); + grin_destroy_partition_list(pg, local_partitions); + grin_destroy_partitioned_graph(pg); +} + + +void test_partition_topology(int argc, char** argv) { + printf("+++++++++++++++++++++ Test partition/topology +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + + printf("----- check master ----- \n"); +FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + #endif + assert(grin_is_master_vertex(g, v)); + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + printf("----- check mirror ----- \n"); +FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + #endif + assert(grin_is_mirror_vertex(g, v)); + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} + +void test_partition(int argc, char** argv) { +#ifdef GRIN_ENABLE_GRAPH_PARTITION + test_partition_reference(argc, argv); + test_partition_topology(argc, argv); +#endif +} + + +void test_topology_structure(int argc, char** argv) { + printf("+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); +#ifndef GRIN_WITH_VERTEX_PROPERTY + printf("vertex num: %zu\n", grin_get_vertex_num(g)); +#endif + +#ifndef GRIN_WITH_EDGE_PROPERTY + printf("edge num: %zu\n", grin_get_edge_num(g)); +#endif + grin_destroy_graph(g); +} + + +void test_topology_vertex_list(int argc, char** argv) { + printf("+++++++++++++++++++++ Test topology/vertex_list +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + #endif + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} + + +void test_topology_adjacent_list(int argc, char** argv, GRIN_DIRECTION dir) { + if (dir == IN) { + printf("+++++++++++++++++++++ Test topology/adjacent_list IN +++++++++++++++++++++\n"); + } else { + printf("+++++++++++++++++++++ Test topology/adjacent_list OUT +++++++++++++++++++++\n"); + } + + GRIN_GRAPH g = get_graph(argc, argv, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); + #else + long long int vid = __vcnt; + #endif + #ifdef GRIN_ENABLE_GRAPH_PARTITION + if (!grin_is_master_vertex(g, v)) { + grin_destroy_vertex(g, v); + grin_get_next_vertex_list_iter(g, __vli); + continue; + } + #endif + + FOR_ADJ_LIST_BEGIN(g, dir, v, al) + GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); + size_t acnt = 0; + while (!grin_is_adjacent_list_end(g, ali)) { + GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); + GRIN_VERTEX v1 = grin_get_src_vertex_from_edge(g, e); + GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge(g, e); + GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); + + #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY + GRIN_EDGE e1 = grin_get_edge_from_adjacent_list(g, al, acnt); + GRIN_VERTEX e1v1 = grin_get_src_vertex_from_edge(g, e1); + GRIN_VERTEX e1v2 = grin_get_dst_vertex_from_edge(g, e1); + assert(grin_equal_vertex(g, v1, e1v1)); + assert(grin_equal_vertex(g, v2, e1v2)); + grin_destroy_edge(g, e1); + grin_destroy_vertex(g, e1v1); + grin_destroy_vertex(g, e1v2); + #endif + + if (dir == OUT) { + assert(grin_equal_vertex(g, v, v1)); + assert(grin_equal_vertex(g, v2, u)); + } else { + assert(grin_equal_vertex(g, v, v2)); + assert(grin_equal_vertex(g, v1, u)); + } + + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v2); + grin_destroy_vertex(g, u); + grin_destroy_edge(g, e); + + acnt++; + grin_get_next_adjacent_list_iter(g, ali); + } + #ifdef GRIN_ENABLE_ADJAECENT_LIST_ARRAY + assert(acnt == grin_get_adjacent_list_size(g, al)); + #endif + grin_destroy_adjacent_list_iter(g, ali); + #ifdef GRIN_WITH_EDGE_PROPERTY + printf("vertex %s adjlist, edgetype: %s, checked num: %zu\n", v_names[__vt][vid], et_names[__etl_i], acnt); + #else + printf("vertex %s adjlist, checked num: %zu\n", v_names[__vt][vid], acnt); + #endif + FOR_ADJ_LIST_END(g, al) + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + grin_destroy_graph(g); +} + + +void test_topology(int argc, char** argv) { + test_topology_structure(argc, argv); + test_topology_vertex_list(argc, argv); + test_topology_adjacent_list(argc, argv, OUT); + test_topology_adjacent_list(argc, argv, IN); +} + +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) +void test_index_order(int argc, char** argv) { + printf("+++++++++++++++++++++ Test index order +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + FOR_VERTEX_BEGIN(g, vl, v) + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + assert(pos == __vcnt); + FOR_VERTEX_END(g, vl, v) + +#ifdef GRIN_ENABLE_GRAPH_PARTITION +{ + GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_master(g, __vt); + size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); + for (size_t i = 0; i < mvlist_sz; ++i) { + GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); + assert(pos == i); + size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v); + } + grin_destroy_vertex_list(g, mvlist); +} +{ + GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_mirror(g, __vt); + size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); + for (size_t i = 0; i < mvlist_sz; ++i) { + GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); + size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); + assert(pos == i); + size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); + GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); + grin_destroy_vertex(g, v); + } + grin_destroy_vertex_list(g, mvlist); +} +#endif +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} +#endif + +void test_index_internal_id(int argc, char** argv) { + printf("+++++++++++++++++++++ Test index internal id +++++++++++++++++++++\n"); + GRIN_GRAPH g = get_graph(argc, argv, 0); + +FOR_VERTEX_LIST_BEGIN(g, vl) + long long int min = grin_get_vertex_internal_id_lower_bound_by_type(g, __vt); + long long int max = grin_get_vertex_internal_id_upper_bound_by_type(g, __vt); + FOR_VERTEX_BEGIN(g, vl, v) +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + long long int oid = grin_get_vertex_internal_id_by_type(g, __vt, v); + assert(oid >= min && oid < max); + GRIN_VERTEX v1 = grin_get_vertex_by_internal_id_by_type(g, __vt, oid); + assert(grin_equal_vertex(g, v, v1)); + grin_destroy_vertex(g, v1); +#endif + FOR_VERTEX_END(g, vl, v) +FOR_VERTEX_LIST_END(g, vl) + + grin_destroy_graph(g); +} + + +void test_index(int argc, char** argv) { +#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) + test_index_order(argc, argv); +#endif +#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX + test_index_internal_id(argc, argv); +#endif +} + +void test_vertex_property_value(int argc, char** argv) { + GRIN_GRAPH g = get_graph(argc, argv, 0); + GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); + GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt, "age"); + GRIN_VERTEX v = get_one_master_person(g); + struct timeval t1, t2; + gettimeofday(&t1, NULL); + for (int i = 0; i < 1000000; ++i) { + long long int age = grin_get_vertex_property_value_of_int64(g, v, vp); + } + gettimeofday(&t2, NULL); + double elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; + elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; + printf("%f ms.\n", elapsedTime); + grin_destroy_vertex(g, v); + grin_destroy_vertex_property(g, vp); + grin_destroy_vertex_type(g, vt); + grin_destroy_graph(g); +} + +void test_perf(int argc, char** argv) { + test_vertex_property_value(argc, argv); +} + +int main(int argc, char** argv) { + test_index(argc, argv); + test_property(argc, argv); + test_partition(argc, argv); + test_topology(argc, argv); + test_perf(argc, argv); + return 0; +} diff --git a/flex/engines/graph_db/grin/include/yaml/schema.yaml b/flex/engines/graph_db/grin/include/yaml/schema.yaml new file mode 100644 index 000000000000..b35dd38283e0 --- /dev/null +++ b/flex/engines/graph_db/grin/include/yaml/schema.yaml @@ -0,0 +1,69 @@ +gs.gie.dbms.graph: + name: modern + graph: + snapshotId: xx + schema: + vertexTypes: + - typeId: 0 + typeName: person + properties: + - propertyId: 0 + propertyName: id + propertyType: + enumType: DT_UNSIGNED_INT64 + - propertyId: 1 + propertyName: name + propertyType: + enumType: DT_STRING + - propertyId: 2 + propertyName: age + propertyType: + enumType: DT_UNSIGNED_INT32 + primaryKeyIds: + - 0 + - typeId: 1 + typeName: software + properties: + - propertyId: 0 + propertyName: id + propertyType: + enumType: DT_UNSIGNED_INT64 + - propertyId: 1 + propertyName: name + propertyType: + enumType: DT_STRING + - propertyId: 2 + propertyName: lang + propertyType: + enumType: DT_STRING + - propertyId: 3 + propertyName: creationDateTime + propertyType: + dateTime: + dateTimeFormat: DTF_YYYY_MM_DD_HH_MM_SS_SSS + timeZoneFormat: TZF_UTC + primaryKeyIds: + - 0 + edgeTypes: + - typeId: 0 + typeName: knows + properties: + - propertyId: 0 + propertyName: weight + propertyType: + enumType: DT_DOUBLE + vertexTypePairRelations: + - srcTypeId: 0 + dstTypeId: 0 + relation: MANY_TO_MANY + - typeId: 1 + typeName: created + properties: + - propertyId: 0 + propertyName: weight + propertyType: + enumType: DT_DOUBLE + vertexTypePairRelations: + - srcTypeId: 0 + dstTypeId: 1 + relation: MANY_TO_MANY diff --git a/flex/grin/predefine.h b/flex/engines/graph_db/grin/predefine.h similarity index 100% rename from flex/grin/predefine.h rename to flex/engines/graph_db/grin/predefine.h diff --git a/flex/grin/src/common/error.cc b/flex/engines/graph_db/grin/src/common/error.cc similarity index 100% rename from flex/grin/src/common/error.cc rename to flex/engines/graph_db/grin/src/common/error.cc diff --git a/flex/grin/src/index/internal_id.cc b/flex/engines/graph_db/grin/src/index/internal_id.cc similarity index 100% rename from flex/grin/src/index/internal_id.cc rename to flex/engines/graph_db/grin/src/index/internal_id.cc diff --git a/flex/grin/src/index/pk.cc b/flex/engines/graph_db/grin/src/index/pk.cc similarity index 100% rename from flex/grin/src/index/pk.cc rename to flex/engines/graph_db/grin/src/index/pk.cc diff --git a/flex/grin/src/predefine.cc b/flex/engines/graph_db/grin/src/predefine.cc similarity index 100% rename from flex/grin/src/predefine.cc rename to flex/engines/graph_db/grin/src/predefine.cc diff --git a/flex/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h similarity index 95% rename from flex/grin/src/predefine.h rename to flex/engines/graph_db/grin/src/predefine.h index cd9c45f7ee35..0fba5dd2ee5f 100644 --- a/flex/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -1,6 +1,6 @@ #include "grin/predefine.h" -#include "storages/rt_mutable_graph/mutable_property_fragment.h" +#include "../../storages/rt_mutable_graph/mutable_property_fragment.h" typedef gs::oid_t GRIN_OID_T; typedef gs::vid_t GRIN_VID_T; diff --git a/flex/grin/src/property/primarykey.cc b/flex/engines/graph_db/grin/src/property/primarykey.cc similarity index 100% rename from flex/grin/src/property/primarykey.cc rename to flex/engines/graph_db/grin/src/property/primarykey.cc diff --git a/flex/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc similarity index 100% rename from flex/grin/src/property/property.cc rename to flex/engines/graph_db/grin/src/property/property.cc diff --git a/flex/grin/src/property/propertylist.cc b/flex/engines/graph_db/grin/src/property/propertylist.cc similarity index 100% rename from flex/grin/src/property/propertylist.cc rename to flex/engines/graph_db/grin/src/property/propertylist.cc diff --git a/flex/grin/src/property/row.cc b/flex/engines/graph_db/grin/src/property/row.cc similarity index 100% rename from flex/grin/src/property/row.cc rename to flex/engines/graph_db/grin/src/property/row.cc diff --git a/flex/grin/src/property/topology.cc b/flex/engines/graph_db/grin/src/property/topology.cc similarity index 100% rename from flex/grin/src/property/topology.cc rename to flex/engines/graph_db/grin/src/property/topology.cc diff --git a/flex/grin/src/property/type.cc b/flex/engines/graph_db/grin/src/property/type.cc similarity index 100% rename from flex/grin/src/property/type.cc rename to flex/engines/graph_db/grin/src/property/type.cc diff --git a/flex/grin/src/topology/adjacentlist.cc b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc similarity index 100% rename from flex/grin/src/topology/adjacentlist.cc rename to flex/engines/graph_db/grin/src/topology/adjacentlist.cc diff --git a/flex/grin/src/topology/structure.cc b/flex/engines/graph_db/grin/src/topology/structure.cc similarity index 100% rename from flex/grin/src/topology/structure.cc rename to flex/engines/graph_db/grin/src/topology/structure.cc diff --git a/flex/grin/src/topology/vertexlist.cc b/flex/engines/graph_db/grin/src/topology/vertexlist.cc similarity index 100% rename from flex/grin/src/topology/vertexlist.cc rename to flex/engines/graph_db/grin/src/topology/vertexlist.cc diff --git a/flex/grin/test/test.c b/flex/engines/graph_db/grin/test/test.c similarity index 100% rename from flex/grin/test/test.c rename to flex/engines/graph_db/grin/test/test.c diff --git a/flex/grin/include b/flex/grin/include deleted file mode 160000 index bcafca761f7a..000000000000 --- a/flex/grin/include +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bcafca761f7ac44f2fb20f599d8ce7c13daae3d9 From 8318312bfe07e7cb91a4ae9fa270b830fec089b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 15:39:34 +0800 Subject: [PATCH 06/30] rm include --- .gitmodules | 3 + flex/engines/graph_db/grin/CMakeLists.txt | 1 + flex/engines/graph_db/grin/include | 1 + flex/engines/graph_db/grin/include/.gitignore | 2 - flex/engines/graph_db/grin/include/LICENSE | 201 -- flex/engines/graph_db/grin/include/README.md | 11 - .../graph_db/grin/include/docs/Makefile | 20 - .../graph_db/grin/include/docs/make.bat | 35 - .../include/docs/source/0.get_started.rst | 65 - .../include/docs/source/1.return_value.rst | 116 -- .../grin/include/docs/source/2.api_naming.rst | 71 - .../include/docs/source/3.topology_api.rst | 42 - .../include/docs/source/4.partition_api.rst | 64 - .../include/docs/source/5.property_api.rst | 56 - .../grin/include/docs/source/6.index_api.rst | 43 - .../grin/include/docs/source/7.extension.rst | 20 - .../graph_db/grin/include/docs/source/conf.py | 28 - .../grin/include/docs/source/index.rst | 43 - .../extension/include/predefine.template.h | 45 - .../extension/include/topology/list_chain.h | 89 - .../grin/include/include/common/error.h | 40 - .../grin/include/include/common/message.h | 37 - .../grin/include/include/index/internal_id.h | 98 - .../grin/include/include/index/label.h | 108 -- .../grin/include/include/index/order.h | 46 - .../graph_db/grin/include/include/index/pk.h | 46 - .../include/include/partition/partition.h | 89 - .../include/include/partition/reference.h | 159 -- .../grin/include/include/partition/topology.h | 126 -- .../grin/include/include/property/partition.h | 80 - .../include/include/property/primarykey.h | 67 - .../grin/include/include/property/property.h | 269 --- .../include/include/property/propertylist.h | 98 - .../grin/include/include/property/row.h | 115 -- .../grin/include/include/property/topology.h | 74 - .../grin/include/include/property/type.h | 176 -- .../include/include/topology/adjacentlist.h | 117 -- .../grin/include/include/topology/edgelist.h | 54 - .../grin/include/include/topology/structure.h | 121 -- .../include/include/topology/vertexlist.h | 94 - .../proto/gie_data_model/data_type.proto | 127 -- .../include/proto/gie_data_model/graph.proto | 13 - .../proto/gie_data_model/partition.proto | 123 -- .../include/proto/gie_data_model/schema.proto | 46 - .../proto/gie_data_model/statistics.proto | 30 - .../graph_db/grin/include/proto/graph.proto | 141 -- .../graph_db/grin/include/rust/Cargo.toml | 75 - .../graph_db/grin/include/rust/grin.rs | 1693 ----------------- .../graph_db/grin/include/rust/grin_all.h | 83 - .../graph_db/grin/include/rust/grin_all.rs | 1368 ------------- .../graph_db/grin/include/rust/grin_v6d.h | 38 - .../graph_db/grin/include/rust/grin_v6d.rs | 97 - .../graph_db/grin/include/rust/parse.py | 257 --- .../grin/include/storage/GART/predefine.h | 237 --- .../grin/include/storage/GraphAr/predefine.h | 243 --- .../grin/include/storage/v6d/predefine.h | 241 --- .../graph_db/grin/include/template/features.h | 506 ----- .../grin/include/template/predefine.h | 273 --- .../engines/graph_db/grin/include/test/test.c | 1052 ---------- .../graph_db/grin/include/yaml/schema.yaml | 69 - 60 files changed, 5 insertions(+), 9677 deletions(-) create mode 160000 flex/engines/graph_db/grin/include delete mode 100644 flex/engines/graph_db/grin/include/.gitignore delete mode 100644 flex/engines/graph_db/grin/include/LICENSE delete mode 100644 flex/engines/graph_db/grin/include/README.md delete mode 100644 flex/engines/graph_db/grin/include/docs/Makefile delete mode 100644 flex/engines/graph_db/grin/include/docs/make.bat delete mode 100644 flex/engines/graph_db/grin/include/docs/source/0.get_started.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/1.return_value.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/5.property_api.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/6.index_api.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/7.extension.rst delete mode 100644 flex/engines/graph_db/grin/include/docs/source/conf.py delete mode 100644 flex/engines/graph_db/grin/include/docs/source/index.rst delete mode 100644 flex/engines/graph_db/grin/include/extension/include/predefine.template.h delete mode 100644 flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h delete mode 100644 flex/engines/graph_db/grin/include/include/common/error.h delete mode 100644 flex/engines/graph_db/grin/include/include/common/message.h delete mode 100644 flex/engines/graph_db/grin/include/include/index/internal_id.h delete mode 100644 flex/engines/graph_db/grin/include/include/index/label.h delete mode 100644 flex/engines/graph_db/grin/include/include/index/order.h delete mode 100644 flex/engines/graph_db/grin/include/include/index/pk.h delete mode 100644 flex/engines/graph_db/grin/include/include/partition/partition.h delete mode 100644 flex/engines/graph_db/grin/include/include/partition/reference.h delete mode 100644 flex/engines/graph_db/grin/include/include/partition/topology.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/partition.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/primarykey.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/property.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/propertylist.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/row.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/topology.h delete mode 100644 flex/engines/graph_db/grin/include/include/property/type.h delete mode 100644 flex/engines/graph_db/grin/include/include/topology/adjacentlist.h delete mode 100644 flex/engines/graph_db/grin/include/include/topology/edgelist.h delete mode 100644 flex/engines/graph_db/grin/include/include/topology/structure.h delete mode 100644 flex/engines/graph_db/grin/include/include/topology/vertexlist.h delete mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto delete mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto delete mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto delete mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto delete mode 100644 flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto delete mode 100644 flex/engines/graph_db/grin/include/proto/graph.proto delete mode 100644 flex/engines/graph_db/grin/include/rust/Cargo.toml delete mode 100644 flex/engines/graph_db/grin/include/rust/grin.rs delete mode 100644 flex/engines/graph_db/grin/include/rust/grin_all.h delete mode 100644 flex/engines/graph_db/grin/include/rust/grin_all.rs delete mode 100644 flex/engines/graph_db/grin/include/rust/grin_v6d.h delete mode 100644 flex/engines/graph_db/grin/include/rust/grin_v6d.rs delete mode 100644 flex/engines/graph_db/grin/include/rust/parse.py delete mode 100644 flex/engines/graph_db/grin/include/storage/GART/predefine.h delete mode 100644 flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h delete mode 100644 flex/engines/graph_db/grin/include/storage/v6d/predefine.h delete mode 100644 flex/engines/graph_db/grin/include/template/features.h delete mode 100644 flex/engines/graph_db/grin/include/template/predefine.h delete mode 100644 flex/engines/graph_db/grin/include/test/test.c delete mode 100644 flex/engines/graph_db/grin/include/yaml/schema.yaml diff --git a/.gitmodules b/.gitmodules index f038d8b178ac..54582c5e0b39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "learning_engine/graph-learn"] path = learning_engine/graph-learn url = https://github.com/alibaba/graph-learn.git +[submodule "flex/engines/graph_db/grin/include"] + path = flex/engines/graph_db/grin/include + url = https://github.com/GraphScope/GRIN.git diff --git a/flex/engines/graph_db/grin/CMakeLists.txt b/flex/engines/graph_db/grin/CMakeLists.txt index 1fdc6341eeeb..566d1d538c12 100644 --- a/flex/engines/graph_db/grin/CMakeLists.txt +++ b/flex/engines/graph_db/grin/CMakeLists.txt @@ -51,6 +51,7 @@ set(YAML_CPP_LIBRARIES "/usr/local/Cellar/yaml-cpp/0.7.0/lib/libyaml-cpp.0.7.0.d include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../..) message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../storages/rt_mutable_graph) diff --git a/flex/engines/graph_db/grin/include b/flex/engines/graph_db/grin/include new file mode 160000 index 000000000000..bcafca761f7a --- /dev/null +++ b/flex/engines/graph_db/grin/include @@ -0,0 +1 @@ +Subproject commit bcafca761f7ac44f2fb20f599d8ce7c13daae3d9 diff --git a/flex/engines/graph_db/grin/include/.gitignore b/flex/engines/graph_db/grin/include/.gitignore deleted file mode 100644 index 97424860a106..000000000000 --- a/flex/engines/graph_db/grin/include/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/docs/build -.vscode/ diff --git a/flex/engines/graph_db/grin/include/LICENSE b/flex/engines/graph_db/grin/include/LICENSE deleted file mode 100644 index 261eeb9e9f8b..000000000000 --- a/flex/engines/graph_db/grin/include/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/flex/engines/graph_db/grin/include/README.md b/flex/engines/graph_db/grin/include/README.md deleted file mode 100644 index 69145a54035b..000000000000 --- a/flex/engines/graph_db/grin/include/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# GRIN -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 engines in GraphScope, and to simplify the integration of these engines with each other. - -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 engine. - -These operations include: -* Traversal: navigating the graph structure to explore relationships between vertices -* Retrieval: retrieving the data and properties of vertices and edges -* Filter: filtering data structures with partitioning or property conditions - -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 engine. diff --git a/flex/engines/graph_db/grin/include/docs/Makefile b/flex/engines/graph_db/grin/include/docs/Makefile deleted file mode 100644 index d0c3cbf1020d..000000000000 --- a/flex/engines/graph_db/grin/include/docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/flex/engines/graph_db/grin/include/docs/make.bat b/flex/engines/graph_db/grin/include/docs/make.bat deleted file mode 100644 index 747ffb7b3033..000000000000 --- a/flex/engines/graph_db/grin/include/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "" goto help - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/flex/engines/graph_db/grin/include/docs/source/0.get_started.rst b/flex/engines/graph_db/grin/include/docs/source/0.get_started.rst deleted file mode 100644 index da51dc905793..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/0.get_started.rst +++ /dev/null @@ -1,65 +0,0 @@ -Getting Started ----------------- - -Get Graph from Storage -^^^^^^^^^^^^^^^^^^^^^^ -To use GRIN, the first API we need is to get a graph handle for the graph in storage. -Here we introduce the ``grin_get_graph_from_storage`` API. - -:: - - GRIN_GRAPH grin_get_graph_from_storage(const char* uri); - -This API takes a URI as its parameter, which is a string that identifies the graph in storage. - -Different storage systems may define different required parameters in the URI: - - gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version} - - graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy} - - v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional. - -The return value of this API is a GRIN graph handle. - -Partitioned Graph -^^^^^^^^^^^^^^^^^ -In GRIN, a partitioned graph is a graph that is split into multiple fragments, -which can be stored separately. - -To work with a partitioned graph, we first need to get a handle to the partitioned graph. -We can do this using the `grin_get_partitioned_graph_from_storage` function. - -:: - - GRIN_PARTITIONED_GRAPH grin_get_partitioned_graph_from_storage(const char* uri); - -The parameters of this API are the same as the ``grin_get_graph_from_storage`` API. -The return value of this API is a GRIN partitioned graph handle. - -Once we have a handle to the partitioned graph, we can access the individual -graph fragments using the `grin_get_local_partition_list` and `grin_get_graph_by_partition` functions. - -:: - - GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(uri); - GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); - size_t num_partitions = grin_get_partition_list_size(local_partitions); - - if (num_partitions == 1) { // suppose we have only one local partition - GRIN_PARTITION partition = grin_get_partition_from_list(pg, local_partitions, 0); - GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition); - } - -We can then perform operations on each fragment of the partitioned graph, -just as we would with a regular graph. - -Note that partitioned graphs can be useful for working with large graphs -that are too large to be stored in memory all at once. By splitting the graph -into smaller fragments, we can work with the graph more efficiently. - -In the above code, all the types with ``GRIN_`` prefix are GRIN handle types. -A GRIN handle is an opaque value that identifies an object in GRIN. -It is important to note that the specific type of the handle, -whether it be an integer, a pointer, or something else, is not specified by -GRIN APIs and may vary between different implementations of GRIN from different storage systems. -Therefore, it is not safe to make assumptions about the type of a handle and -its properties based on its value. -Instead, you should use the GRIN APIs to access the object associated with the handle. diff --git a/flex/engines/graph_db/grin/include/docs/source/1.return_value.rst b/flex/engines/graph_db/grin/include/docs/source/1.return_value.rst deleted file mode 100644 index 1be0347027c1..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/1.return_value.rst +++ /dev/null @@ -1,116 +0,0 @@ -Return Values --------------- -Handle -^^^^^^^ - -In most cases, the return value of a GRIN API call is a GRIN handle. -A GRIN handle represents a GRIN object, such as a vertex or edge, and can be -used as a parameter for another GRIN API call. -For example, in the previous section, we obtained a GRIN_GRAPH handle g, -which we can use to get a vertex list of the graph: - -:: - - #ifdef GRIN_WITH_VERTEX_PROPERTY - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); - GRIN_VERTEX_LIST vlist = grin_get_vertex_list_by_type(g, vt); - #else - GRIN_VERTEX_LIST vlist = grin_get_vertex_list(g); - #endif - - #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY - size_t vlist_size = grin_get_vertex_list_size(g, vlist); - - for (unsigned int i = 0; i < vlist_size; ++i){ - GRIN_VERTEX v = grin_get_vertex_from_list(g, vlist, i); - // use v - grin_destroy_vertex(g, v); - } - #endif - - #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR - GRIN_VERTEX_LIST_ITERATOR vlist_iter = grin_get_vertex_list_begin(g, vlist); - - while (grin_is_vertex_list_end(g, vlist_iter)) { - GRIN_VERTEX v = grin_get_vertex_from_iter(g, vlist_iter); - // use v - grin_destroy_vertex(g, v); - grin_get_next_vertex_list_iter(g, vlist_iter); - } - - grin_destroy_vertex_list_iter(g, vlist_iter); - #endif - - grin_destroy_vertex_list(g, vlist); - -In the first step, we obtain a vertex list handle from a graph handle. -Note that when vertex property is supported (i.e., GRIN_WITH_VERTEX_PROPERTY is defined), -GRIN only provides the API to get the vertex list of a single type (e.g., person). -This is based on the low-level API design principle of GRIN, which means -GRIN APIs are a set of low-level abstractions for graph-retrieval actions. -Please refer to the low-level API subsection in the topology API section for more details. -However, GRIN does provide high-level APIs in its extensions. -Please refer to the extension section for more details. - -In the next step, the vertex list can be accessed in two ways: array and iterator. -This is also controlled by the macros enabled by the storage. -Some storage may only support one type of access, while some may support both. - -In the final step, we have to destroy every handle we obtain from GRIN to avoid memory leaks. - -Others -^^^^^^ -Exceptionally, there are three types of values returned by GRIN API calls other than handles: - -- GRIN enumerates: This includes enumerates defined in predefine.h, namely GRIN_DIRECTION, GRIN_DATATYPE, and GRIN_ERROR_CODE. -- Common values: This includes common values such as ``size_t`` for list size, ``bool`` for condition check, ``unsigned int`` for ID, and ``const char*`` for name. -- Property values: This includes property values such as ``int32``, ``int64``, ``float``, ``double``, and ``const char*``. The types are defined in the ``GRIN_DATATYPE`` enumerate. -- Serialized values: This includes serialized ``const char*`` from vertex ref or edge ref. - -Users do NOT have to destroy these return values since they are on the ``"stack"``, -except for the ``const char*`` in property values and serialized values. -In this case, users have to destroy the string value by using ``grin_destroy_string_value`` -and ``grin_destroy_serialized_vertex(edge)_ref``, respectively. -Note that if the ``const char*`` is returned by a GRIN API call for a name, -such as a vertex type name or edge property name, users do NOT have to destroy -it since they are common values. - -Validation -^^^^^^^^^^^ -GRIN provides invalid values for handles to let users check whether a handle -is valid or not. Normally, the invalid value of a GRIN handle ``GRIN_A`` is -defined as ``GRIN_NULL_A``. GRIN also provides invalid values for common values, -namely ``GRIN_NULL_SIZE`` and ``GRIN_NULL_NAME``. GRIN does NOT provide invalid -values for enumerates because each enumerate should cover all possible values. -GRIN also does NOT define invalid values for property values because there is -no specific value that can be defined as invalid for types like ``int32`` or ``double``. -This case is handled by GRIN error codes, as explained in the next section. - -Error Code -^^^^^^^^^^^ -GRIN defines a set of error codes in the ``GRIN_ERROR_CODE`` enumerate. -When a GRIN API call encounters an error but cannot return invalid values -(e.g., the property value case above), it can set the thread_local error code to -indicate the error. Users can get the error code using the ``grin_get_last_error_code`` -API and handle the error case accordingly. - -:: - - int value = grin_get_int32_from_row(g, row, 0); - if (grin_get_last_error_code() != GRIN_ERROR_CODE::GRIN_NO_ERROR) { - // handle error - } - -Summary -^^^^^^^ -To summerize, we list a table for return values of GRIN API calls and related operations: - -=================== =========================== ================= -Return Value Types Check Invalid Destroy Required -=================== =========================== ================= -handle != GRIN_NULL_A grin_destroy_A -GRIN enumerates N/A N/A -Common values != GRIN_NULL_X N/A -Property values grin_get_last_error_code grin_destroy_string_value only -Serialized values N/A grin_destroy_serialized_A_ref only -=================== =========================== ================= diff --git a/flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst b/flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst deleted file mode 100644 index 6e9fc73cb855..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/2.api_naming.rst +++ /dev/null @@ -1,71 +0,0 @@ -API Naming Rules ----------------- -Common Get -^^^^^^^^^^ -=========================== ============== -Format Description -=========================== ============== -grin_get_A return handle A or the value of some statitic A -grin_get_A_of_T return A of type T -grin_get_A_from_B A is an element of B and A must be a handle. In case B is A list, use grin_get_A_from_list for short -grin_get_A_by_B use B to find A, B can be id or name -grin_get_A_B B is an element of A, and B is NOT a handle or value. B can be name, datatype, id, or size -grin_get_As_with_B get A list with B enabled, B can be primary_keys -=========================== ============== - -List -^^^^ -=========================== ============== -Format Description -=========================== ============== -grin_get_A_list_begin return A list begin iterator -grin_get_next_A_list_iter get next iterator -grin_is_A_list_end check if end iterator -grin_get_A_from_iter get A from A list iterator, note that we use **from** but not **by** since A list is not a parameter, meaning that we are NOT using the iterator to find A from A list but simply get A from the iterator -grin_get_A_from_B_iter A != B, e.g., A and B can be neighbor(vertex) and adjacent list -grin_insert_A_to_list insert A to A list -=========================== ============== - -Ref & Serialization -^^^^^^^^^^^^^^^^^^^ -=========================== ============== -Format Description -=========================== ============== -grin_serialize_A serialize A into const char*, in fast ref, use grin_serialize_A_as_int64 -grin_deserialize_to_A deserialze const char* to A, in fast ref, use grin_deserialize_int64_to_A -=========================== ============== - - -Value -^^^^^ -=========================== ============== -Format Description -=========================== ============== -grin_get_A_datatype follow grin_get_A_B and return GRIN_DATATYPE -grin_get_value_from_A follow grin_get_B_from_A and return const void*, A can be row -grin_get_T_from_A follow grin_get_B_from_A and return T, A can be row -grin_insert_value_to_A insert const void* value to A, A can be row -girn_insert_T_to_A insert value of type T to A, A can be row -=========================== ============== - - -Others -^^^^^^ -=========================== ============== -Format Description -=========================== ============== -grin_destroy_A destroy handle of A -grin_is_X check whether condition X statisfied -grin_equal_A check whether two A handles are equal -grin_get_A_list_select_B select elements in A list based on B, B can be master, mirror or certain partition -=========================== ============== - - - -Parameter Order -^^^^^^^^^^^^^^^ -Rules to order parameters of APIs: - -- From larger-range handle to smaller-range handle - - diff --git a/flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst b/flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst deleted file mode 100644 index b4e2b98e4f15..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/3.topology_api.rst +++ /dev/null @@ -1,42 +0,0 @@ -Topology APIs -------------- - -Topology lists -^^^^^^^^^^^^^^^ - -GRIN considers vertex list, edge list, and adjacent list as ``Topology Lists`` -and designs related APIs using the same principle. -GRIN provides low-level abstractions for topology lists. -Thus, in property graphs with various vertex types and edge types, -GRIN only provides APIs to get the vertex list and edge list of a single type -because a vertex list containing vertices of different types can be easily -constructed by merging vertex lists of different types. -GRIN will support such high-level abstractions in the future under ``GRIN extension``. - -Vertex List -^^^^^^^^^^^ - -In a simple graph, GRIN provides the ``grin_get_vertex_list`` API to get the -vertex list of the graph. In a property graph, GRIN provides the -``grin_get_vertex_list_by_type`` API to get the vertex list. Also, in a -partitioned graph, when ``GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST`` features -are enabled, GRIN provides two groups of additional APIs: -``grin_get_vertex_list_select_master, grin_get_vertex_list_select_mirror`` and -``grin_get_vertex_list_by_type_select_master, grin_get_vertex_list_by_type_select_mirror`` -for simple graph and property graph, respectively. - -Edge List -^^^^^^^^^^ - -Similar to the vertex list, GRIN provides the ``grin_get_edge_list`` API to get -the edge list for a simple graph and ``grin_get_edge_list_by_type`` for a property graph. - -Adjacent List -^^^^^^^^^^^^^^ - -GRIN considers the adjacent list as a special case of the edge list and thus -also provides the ``grin_get_adjacent_list_by_edge_type`` API for a property graph, -as well as ``grin_get_adjacent_list`` for a simple graph. -Additional selections can also be attached to adjacent lists of both simple graph -and property graph, such as ``grin_get_adjacent_list_select_neighbor_partition``, -``grin_get_adjacent_list_by_edge_type_select_master_neighbor``, etc. \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst b/flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst deleted file mode 100644 index 13c44238a851..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/4.partition_api.rst +++ /dev/null @@ -1,64 +0,0 @@ -Partition APIs --------------- - -Vertex Reference -^^^^^^^^^^^^^^^^ -``GRIN_VERTEX_REF`` is a reference to a vertex in the graph. It is used to exchange vertex information -with remote partitions. - -To get the ``vertex_ref`` of a ``vertex`` and vice-versa, use: - -:: - - GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH, GRIN_VERTEX); - - GRIN_VERTEX grin_get_vertex_by_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - -Since ``GRIN_VERETX_REF`` is still a handle, we can further serialize it into ``const char*`` or -``int64`` if ``GRIN_TRAIT_FAST_VERTEX_REF`` is defined. - -:: - - const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - - #ifdef GRIN_TRAIT_FAST_VERTEX_REF - long long int grin_serialize_vertex_ref_as_int64(GRIN_GRAPH, GRIN_VERTEX_REF); - #endif - -Accordingly, the ``vertex_ref`` can be deserialized from ``const char*`` or ``int64``. - -:: - - GRIN_VERTEX_REF grin_deserialize_vertex_ref(GRIN_GRAPH, const char*); - - #ifdef GRIN_TRAIT_FAST_VERTEX_REF - GRIN_VERTEX_REF grin_deserialize_int64_to_vertex_ref(GRIN_GRAPH, long long int); - #endif - -Users can also get the master partition of a vertex using its vertex reference. - -:: - - GRIN_PARTITION grin_get_master_partition_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - -Actually vertex reference implies a vertex partition protocol between partitions. - - -Select Master -^^^^^^^^^^^^^ -In partitioned graph, a common need is to select master vertices from a vertex list. -Particularly in edgecut, this stands for the ``inner`` vertices of a partition. - -GRIN provides related APIS to handle this if corresponding traits are defined. - -:: - - GRIN_VERTEX_LIST vlist = grin_get_vertex_list(g); - - #ifdef GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST - GRIN_VERTEX_LIST master_vlist = grin_select_master_for_vertex_list(g, vlist); - - grin_destroy_vertex_list(g, master_vlist); - #endif - - grin_destroy_vertex_list(g, vlist); diff --git a/flex/engines/graph_db/grin/include/docs/source/5.property_api.rst b/flex/engines/graph_db/grin/include/docs/source/5.property_api.rst deleted file mode 100644 index 8e01927f9106..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/5.property_api.rst +++ /dev/null @@ -1,56 +0,0 @@ -Property APIs --------------- - -Get Vertex Property Value -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -GRIN provides APIs to get a single property value of a vertex, as well as all the property values -of a vertex as a row. - -:: - - GRIN_ROW row = grin_get_vertex_row(g, v); - - GRIN_VERTEX_TYPE vtype = grin_get_vertex_type(g, v); - GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, vtype); - size_t vpl_sz = grin_get_vertex_property_list_size(g, vpl); - - for (size_t i = 0; i < vpl_sz; ++i) { - GRIN_VERTEX_PROPERTY vprop = grin_get_vertex_property_from_list(g, vpl, i); - GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vprop); - - if (dt == Int64) { - long long int value = grin_get_vertex_property_value_of_int64(g, v, vprop); - long long int value1 = grin_get_int64_from_row(g, row, i); - // use the value - } else if (dt == String) { - const char* value = grin_get_vertex_property_value_of_string(g, v, vprop); - const char* value1 = grin_get_string_from_row(g, row, i); - // use the value - grin_destroy_string_value(g, value); - grin_destroy_string_value(g, value1); - } else ... - } - - -Primary Key -^^^^^^^^^^^^ -GRIN explicitly distinguishes the concepts of primary keys and indexing based on primary keys. -Primary keys are used to identify a vertex or an edge, and just like in relational databases, -they are unique under a given vertex or edge type. -Indexing based on primary keys is the ability to find a vertex or an edge by its primary key. -These two sets of APIs are defined in ``property/primarykey.h`` and ``index/pk.h`` respectively. -Indexing with PK is discussed in the index section. - -Getting the primary key of a vertex is similar to getting the value of a property. -Users first get a row for the values of PK properties using the API -``grin_get_vertex_primary_keys_row``, and then get values from the row one-by-one. - - - - - - - - - - diff --git a/flex/engines/graph_db/grin/include/docs/source/6.index_api.rst b/flex/engines/graph_db/grin/include/docs/source/6.index_api.rst deleted file mode 100644 index 542e34c2cdd2..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/6.index_api.rst +++ /dev/null @@ -1,43 +0,0 @@ -Index APIs --------------- - -Sorted List and Order -^^^^^^^^^^^^^^^^^^^^^^ -Some storage sort the vertices in a vertex list by default. -This enables the ability to let the user to find the position of a vertex in the list -in sub-linear time complexity (O(log(n)) for binary search). - -To describe this feature, storage can define ``GRIN_ASSUME_ALL_VERTEX_LIST_SORTED`` to show -that all the vertex lists are sorted by default. If ``GRIN_ENABLE_VERTEX_LIST_ARRAY`` is also -defined, the position API is enabled: - -:: - - size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH, GRIN_VERTEX_LIST, GRIN_VERTEX); - -Internal ID -^^^^^^^^^^^ -Internal ID is an integer range indexing for vertices of a certain type. -The key feature of internal ID is that storage can provide lower and upper -bounds (left-closed, right-open) for internal IDs of vertices of a certain type. -This enables the ability to use vertices as an array index in the computing engine. - -PK Indexing -^^^^^^^^^^^^^ -To get a vertex from its PK values, we will first put all the values into a row -according to the PK properties of the vertex's type. Then we can use the row -to get the vertex handle. The following example shows how to get the vertex of -type "person" with name "marko" and age 29 if the PK properties of "person" are -"name" and "age" - -:: - - GRIN_VERTEX_TYPE vtype = grin_get_vertex_type_by_name(g, "person"); - GRIN_ROW row = grin_create_row(g); - if (!grin_insert_string_to_row(g, row, "marko")) { - printf("Failed to insert string to row\n"); - } - if (!grin_insert_int32_to_row(g, row, 29)) { - printf("Failed to insert int32 to row\n"); - } - GRIN_VERTEX v = grin_get_vertex_by_primary_keys(g, vtype, row); \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/docs/source/7.extension.rst b/flex/engines/graph_db/grin/include/docs/source/7.extension.rst deleted file mode 100644 index ae892b2b3f2e..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/7.extension.rst +++ /dev/null @@ -1,20 +0,0 @@ -Extension --------------- - -GRIN Extension offers high-level APIs to expand functionality, as well as a -default implementation using GRIN basic (low-level) APIs. -Certain GRIN Extension APIs can be overwritten by a more efficient -implementation from storage. - -List Chain -^^^^^^^^^^^ - -Starting from v0.1, GRIN provides topology lists (i.e., vertex/edge/adjacent list) -of a single vertex or edge type in property graph to keep the basic APIs -low-level abstraction. However, in many cases, users need to traverse all the -vertices in a property graph. Although the user can first iterate all the vertex -types and then get the vertex list of each vertex type to traverse, this approach -increases boilerplate code. Thus, we provide a high-level handle ``VertexListChain`` -and related APIs in GRIN extension to handle this case. -Since we call them list chains, we only provide iterators to traverse the -list chain, but not array-like access. diff --git a/flex/engines/graph_db/grin/include/docs/source/conf.py b/flex/engines/graph_db/grin/include/docs/source/conf.py deleted file mode 100644 index bf2d996978c4..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/conf.py +++ /dev/null @@ -1,28 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# For the full list of built-in configuration values, see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Project information ----------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information - -project = 'GRIN' -copyright = '2023, grin workers' -author = 'grin workers' -release = '0.1.1' - -# -- General configuration --------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration - -extensions = [] - -templates_path = ['_templates'] -exclude_patterns = [] - - - -# -- Options for HTML output ------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output - -html_theme = 'furo' -html_static_path = ['_static'] diff --git a/flex/engines/graph_db/grin/include/docs/source/index.rst b/flex/engines/graph_db/grin/include/docs/source/index.rst deleted file mode 100644 index b5090b37b420..000000000000 --- a/flex/engines/graph_db/grin/include/docs/source/index.rst +++ /dev/null @@ -1,43 +0,0 @@ -.. GRIN documentation master file, created by - sphinx-quickstart on Thu May 11 17:08:47 2023. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to GRIN's documentation! -================================ - -**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 engines in GraphScope, -and to simplify the integration of these engines with each other. - -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 engine. - -These operations include: - -- *Traversal*: navigating the graph structure to explore relationships between vertices -- *Retrieval*: retrieving the data and properties of vertices and edges -- *Filter*: filtering data structures with partitioning or property conditions - -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 engine. - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - 0.get_started - 1.return_value - 2.api_naming - 3.topology_api - 4.partition_api - 5.property_api - 6.index_api - 7.extension - - - diff --git a/flex/engines/graph_db/grin/include/extension/include/predefine.template.h b/flex/engines/graph_db/grin/include/extension/include/predefine.template.h deleted file mode 100644 index ad65ede10325..000000000000 --- a/flex/engines/graph_db/grin/include/extension/include/predefine.template.h +++ /dev/null @@ -1,45 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @file extension/predefine.h - * @brief Pre-defined macros, handles and null values for - * GRIN extensions. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_EXTENSION_INCLUDE_PREDEFINE_H_ -#define GRIN_EXTENSION_INCLUDE_PREDEFINE_H_ - -typedef void* GRIN_VERTEX_LIST_CHAIN; - -typedef void* GRIN_VERTEX_LIST_CHAIN_ITERATOR; - -typedef void* GRIN_EDGE_LIST_CHAIN; - -typedef void* GRIN_EDGE_LIST_CHAIN_ITERATOR; - -typedef void* GRIN_ADJACENT_LIST_CHAIN; - -typedef void* GRIN_ADJACENT_LIST_CHAIN_ITERATOR; - -#endif // GRIN_EXTENSION_INCLUDE_PREDEFINE_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h b/flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h deleted file mode 100644 index dc859f175f47..000000000000 --- a/flex/engines/graph_db/grin/include/extension/include/topology/list_chain.h +++ /dev/null @@ -1,89 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_EXTENSION_INCLUDE_TOPOLOGY_LIST_CHAIN_H_ -#define GRIN_EXTENSION_INCLUDE_TOPOLOGY_LIST_CHAIN_H_ - -#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types(GRIN_GRAPH); - -void grin_destroy_vertex_list_chain(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN); - -GRIN_VERTEX_LIST_CHAIN_ITERATOR grin_get_vertex_list_chain_begin(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN); - -void grin_destroy_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); - -void grin_get_next_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); - -bool grin_is_vertex_list_chain_end(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); - -GRIN_VERTEX grin_get_vertex_from_vertex_list_chain_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_CHAIN_ITERATOR); -#endif - -#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) -GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_master(GRIN_GRAPH); - -GRIN_VERTEX_LIST_CHAIN grin_get_vertex_list_chain_of_all_types_select_mirror(GRIN_GRAPH); -#endif - -#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types(GRIN_GRAPH); - -void grin_destroy_edge_list_chain(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN); - -GRIN_EDGE_LIST_CHAIN_ITERATOR grin_get_edge_list_chain_begin(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN); - -void grin_destroy_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); - -void grin_get_next_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); - -bool grin_is_edge_list_chain_end(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); - -GRIN_EDGE grin_get_edge_from_edge_list_chain_iter(GRIN_GRAPH, GRIN_EDGE_LIST_CHAIN_ITERATOR); -#endif - -#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) -GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types_select_master(GRIN_GRAPH); - -GRIN_EDGE_LIST_CHAIN grin_get_edge_list_chain_of_all_types_select_mirror(GRIN_GRAPH); -#endif - -#if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_ADJACENT_LIST_CHAIN grin_get_adjacent_list_chain_of_all_edge_types(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); - -void grin_destroy_adjacent_list_chain(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN); - -GRIN_ADJACENT_LIST_CHAIN_ITERATOR grin_get_adjacent_list_chain_begin(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN); - -void grin_destroy_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); - -void grin_get_next_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); - -bool grin_is_adjacent_list_chain_end(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); - -GRIN_EDGE grin_get_edge_from_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); - -GRIN_VERTEX grin_get_neighbor_from_adjacent_list_chain_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_CHAIN_ITERATOR); -#endif - -#endif // GRIN_EXTENSION_INCLUDE_TOPOLOGY_VERTEX_LIST_CHAIN_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/common/error.h b/flex/engines/graph_db/grin/include/include/common/error.h deleted file mode 100644 index fccbd1aad186..000000000000 --- a/flex/engines/graph_db/grin/include/include/common/error.h +++ /dev/null @@ -1,40 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file error.h - @brief Define the error code related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_COMMON_ERROR_H_ -#define GRIN_INCLUDE_COMMON_ERROR_H_ - - -extern __thread GRIN_ERROR_CODE grin_error_code; - -/** - * @brief Get the last error code. - * The error code is thread local. - * Currently users only need to check the error code when using - * getting-value APIs whose return has no predefined invalid value. -*/ -GRIN_ERROR_CODE grin_get_last_error_code(); - -#endif // GRIN_INCLUDE_COMMON_ERROR_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/common/message.h b/flex/engines/graph_db/grin/include/include/common/message.h deleted file mode 100644 index 099c49ae5a89..000000000000 --- a/flex/engines/graph_db/grin/include/include/common/message.h +++ /dev/null @@ -1,37 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file message.h - @brief Define storage feature protobuf message -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_COMMON_MESSAGE_H_ -#define GRIN_INCLUDE_COMMON_MESSAGE_H_ - -/** - * @brief Get the static feature prototype message of the storage. - * This proto describes the features of the storage, such as whether - * it supports property graph or partitioned graph. - * @return The serialized proto message. -*/ -const char* grin_get_static_storage_feature_msg(); - -#endif // GRIN_INCLUDE_PROTO_MESSAGE_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/internal_id.h b/flex/engines/graph_db/grin/include/include/index/internal_id.h deleted file mode 100644 index 9622436bec87..000000000000 --- a/flex/engines/graph_db/grin/include/include/index/internal_id.h +++ /dev/null @@ -1,98 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file internal_id.h - @brief Define the internal ID related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_INDEX_INTERNAL_ID_H_ -#define GRIN_INCLUDE_INDEX_INTERNAL_ID_H_ - - -#if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && !defined(GRIN_WITH_VERTEX_PROPERTY) -/** - * @brief Get the int64 internal id of a vertex - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @return The int64 internal id of the vertex -*/ -long long int grin_get_vertex_internal_id(GRIN_GRAPH, GRIN_VERTEX); - -/** - * @brief Get the vertex by internal id. - * Different from pk_of_int64, the internal id is unique over all vertex types. - * @param GRIN_GRAPH The graph - * @param id The internal id of the vertex - * @return The vertex -*/ -GRIN_VERTEX grin_get_vertex_by_internal_id(GRIN_GRAPH, long long int id); - -/** - * @brief Get the upper bound of internal id. - * @param GRIN_GRAPH The graph - * @return The upper bound -*/ -long long int grin_get_vertex_internal_id_upper_bound(GRIN_GRAPH); - -/** - * @brief Get the lower bound of internal id. - * @param GRIN_GRAPH The graph - * @return The lower bound -*/ -long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH); -#endif - -#if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && defined(GRIN_WITH_VERTEX_PROPERTY) -/** - * @brief Get the int64 internal id of a vertex - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @return The int64 internal id of the vertex -*/ -long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX); - -/** - * @brief Get the vertex by internal id under type - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_TYPE The vertex type - * @param id The internal id of the vertex under type - * @return The vertex -*/ -GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, long long int id); - -/** - * @brief Get the upper bound of internal id under type. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_TYPE The vertex type - * @return The upper bound of internal id under type -*/ -long long int grin_get_vertex_internal_id_upper_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -/** - * @brief Get the lower bound internal id under type. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_TYPE The vertex type - * @return The lower bound internal id under type -*/ -long long int grin_get_vertex_internal_id_lower_bound_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); -#endif - -#endif // GRIN_INCLUDE_INDEX_INTERNAL_ID_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/label.h b/flex/engines/graph_db/grin/include/include/index/label.h deleted file mode 100644 index d592460f6c10..000000000000 --- a/flex/engines/graph_db/grin/include/include/index/label.h +++ /dev/null @@ -1,108 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file label.h - @brief Define the label related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_INDEX_LABEL_H_ -#define GRIN_INCLUDE_INDEX_LABEL_H_ - - -#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) -GRIN_LABEL grin_get_label_by_name(GRIN_GRAPH, const char*); - -void grin_destroy_label(GRIN_GRAPH, GRIN_LABEL); - -const char* grin_get_label_name(GRIN_GRAPH, GRIN_LABEL); - -void grin_destroy_label_list(GRIN_GRAPH, GRIN_LABEL_LIST); - -size_t grin_get_label_list_size(GRIN_GRAPH, GRIN_LABEL_LIST); - -GRIN_LABEL grin_get_label_from_list(GRIN_GRAPH, GRIN_LABEL_LIST, size_t); -#endif - -#ifdef GRIN_WITH_VERTEX_LABEL -/** - * @brief assign a label to a vertex - * @param GRIN_GRAPH the graph - * @param GRIN_LABEL the label - * @param GRIN_VERTEX the vertex - * @return whether succeed -*/ -bool grin_assign_label_to_vertex(GRIN_GRAPH, GRIN_LABEL, GRIN_VERTEX); - -/** - * @brief get the label list of a vertex - * @param GRIN_GRAPH the graph - * @param GRIN_VERTEX the vertex -*/ -GRIN_LABEL_LIST grin_get_vertex_label_list(GRIN_GRAPH, GRIN_VERTEX); - -/** - * @brief get the vertex list by label - * @param GRIN_GRAPH the graph - * @param GRIN_LABEL the label -*/ -GRIN_VERTEX_LIST grin_get_vertex_list_by_label(GRIN_GRAPH, GRIN_LABEL); - -/** - * @brief filtering an existing vertex list by label - * @param GRIN_VERTEX_LIST the existing vertex list - * @param GRIN_LABEL the label -*/ -GRIN_VERTEX_LIST grin_select_label_for_vertex_list(GRIN_GRAPH, GRIN_LABEL, GRIN_VERTEX_LIST); -#endif - -#ifdef GRIN_WITH_EDGE_LABEL -/** - * @brief assign a label to a edge - * @param GRIN_GRAPH the graph - * @param GRIN_LABEL the label - * @param GRIN_EDGE the edge - * @return whether succeed -*/ -bool grin_assign_label_to_edge(GRIN_GRAPH, GRIN_LABEL, GRIN_EDGE); - -/** - * @brief get the label list of a edge - * @param GRIN_GRAPH the graph - * @param GRIN_EDGE the edge -*/ -GRIN_LABEL_LIST grin_get_edge_label_list(GRIN_GRAPH, GRIN_EDGE); - -/** - * @brief get the edge list by label - * @param GRIN_GRAPH the graph - * @param GRIN_LABEL the label -*/ -GRIN_EDGE_LIST grin_get_edge_list_by_label(GRIN_GRAPH, GRIN_LABEL); - -/** - * @brief filtering an existing edge list by label - * @param GRIN_EDGE_LIST the existing edge list - * @param GRIN_LABEL the label -*/ -GRIN_EDGE_LIST grin_select_label_for_edge_list(GRIN_GRAPH, GRIN_LABEL, GRIN_EDGE_LIST); -#endif - -#endif // GRIN_INCLUDE_INDEX_LABEL_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/order.h b/flex/engines/graph_db/grin/include/include/index/order.h deleted file mode 100644 index 8321d413a242..000000000000 --- a/flex/engines/graph_db/grin/include/include/index/order.h +++ /dev/null @@ -1,46 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file order.h - @brief Define the vertex ordering predicate APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_INDEX_ORDER_H_ -#define GRIN_INCLUDE_INDEX_ORDER_H_ - - -#ifdef GRIN_ASSUME_ALL_VERTEX_LIST_SORTED -bool grin_smaller_vertex(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX); -#endif - -#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) -/** - * @brief Get the position of a vertex in a sorted list - * caller must guarantee the input vertex list is sorted to get the correct result - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_LIST The sorted vertex list - * @param GRIN_VERTEX The vertex to find - * @return The position of the vertex -*/ -size_t grin_get_position_of_vertex_from_sorted_list(GRIN_GRAPH, GRIN_VERTEX_LIST, GRIN_VERTEX); -#endif - -#endif // GRIN_INCLUDE_INDEX_ORDER_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/index/pk.h b/flex/engines/graph_db/grin/include/include/index/pk.h deleted file mode 100644 index 0b71065c79da..000000000000 --- a/flex/engines/graph_db/grin/include/include/index/pk.h +++ /dev/null @@ -1,46 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file pk.h - @brief Define the primary key indexing related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_INDEX_PK_H_ -#define GRIN_INCLUDE_INDEX_PK_H_ - -#if defined(GRIN_ENABLE_VERTEX_PK_INDEX) && defined(GRIN_ENABLE_VERTEX_PRIMARY_KEYS) -/** - * @brief Get the vertex by primary keys row. - * The values in the row must be in the same order as the primary keys - * properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @param GRIN_ROW The values row of primary keys properties. - * @return The vertex. -*/ -GRIN_VERTEX grin_get_vertex_by_primary_keys_row(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_ROW); -#endif - -#if defined(GRIN_ENABLE_EDGE_PK_INDEX) && defined(GRIN_ENABLE_EDGE_PRIMARY_KEYS) -GRIN_EDGE grin_get_edge_by_primary_keys_row(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_ROW); -#endif - -#endif // GRIN_INCLUDE_INDEX_PK_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/partition/partition.h b/flex/engines/graph_db/grin/include/include/partition/partition.h deleted file mode 100644 index df4c2e392215..000000000000 --- a/flex/engines/graph_db/grin/include/include/partition/partition.h +++ /dev/null @@ -1,89 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file partition.h - @brief Define the partition related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PARTITION_PARTITION_H_ -#define GRIN_INCLUDE_PARTITION_PARTITION_H_ - - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -/** - * @brief Get a partitioned graph from a storage. - * @param uri The URI of the graph. - * Current URI for supported storage includes: - * 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version} - * 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy} - * 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional. - * @return A partitioned graph handle. -*/ -GRIN_PARTITIONED_GRAPH grin_get_partitioned_graph_from_storage(const char* uri); - -void grin_destroy_partitioned_graph(GRIN_PARTITIONED_GRAPH); - -size_t grin_get_total_partitions_number(GRIN_PARTITIONED_GRAPH); - -/** - * @brief Get the local partition list of the partitioned graph. - * For example, a graph may be partitioned into 6 partitions and located in - * 2 machines, then each machine may contain a local partition list of size 3. - * @param GRIN_PARTITIONED_GRAPH The partitioned graph. - * @return A partition list of local partitions. -*/ -GRIN_PARTITION_LIST grin_get_local_partition_list(GRIN_PARTITIONED_GRAPH); - -void grin_destroy_partition_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST); - -GRIN_PARTITION_LIST grin_create_partition_list(GRIN_PARTITIONED_GRAPH); - -bool grin_insert_partition_to_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST, GRIN_PARTITION); - -size_t grin_get_partition_list_size(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST); - -GRIN_PARTITION grin_get_partition_from_list(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_LIST, size_t); - -bool grin_equal_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION, GRIN_PARTITION); - -void grin_destroy_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); - -const void* grin_get_partition_info(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); - -/** - * @brief Get a local graph of the partitioned graph. - * @param GRIN_PARTITIONED_GRAPH The partitioned graph. - * @param GRIN_PARTITION The partition of the graph. - * @return A local graph. -*/ -GRIN_GRAPH grin_get_local_graph_by_partition(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -GRIN_PARTITION grin_get_partition_by_id(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION_ID); - -GRIN_PARTITION_ID grin_get_partition_id(GRIN_PARTITIONED_GRAPH, GRIN_PARTITION); -#endif - -#endif // GRIN_INCLUDE_PARTITION_PARTITION_H_ - -#ifdef __cplusplus -} -#endif diff --git a/flex/engines/graph_db/grin/include/include/partition/reference.h b/flex/engines/graph_db/grin/include/include/partition/reference.h deleted file mode 100644 index 828c693b11d2..000000000000 --- a/flex/engines/graph_db/grin/include/include/partition/reference.h +++ /dev/null @@ -1,159 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file reference.h - @brief Define the reference related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PARTITION_REFERENCE_H_ -#define GRIN_INCLUDE_PARTITION_REFERENCE_H_ - -#ifdef GRIN_ENABLE_VERTEX_REF -/** - * @brief Get the vertex ref of a vertex. - * A vertex ref is a reference for a "local" vertex, and the reference can - * be recognized by other partitions. - * To transfer the vertex ref handle between partitions, users should - * first call serialization methods to serialize the vertex ref handle - * into string or int64 based on the storage's features; - * then send the messages to remote partitions and deserialize the string or - * int64 remotely to get the vertex ref handle on the remote partition; - * finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle - * on the remote partition. - * These two vertices should represent the same vertex in the partitioned graph. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @return The vertex ref -*/ -GRIN_VERTEX_REF grin_get_vertex_ref_by_vertex(GRIN_GRAPH, GRIN_VERTEX); - -void grin_destroy_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - -/** - * @brief get the local vertex handle from the vertex ref handle - * if the vertex ref handle is not recognized, a null vertex is returned - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_REF The vertex ref - * @return The vertex handle - */ -GRIN_VERTEX grin_get_vertex_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - -/** - * @brief get the master partition of a vertex ref. - * Some storage can still provide the master partition of the vertex ref, - * even if the vertex ref can NOT be recognized locally. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_REF The vertex ref - */ -GRIN_PARTITION grin_get_master_partition_from_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - -/** - * @brief serialize the vertex ref handle to string - * The returned string should be freed by ``grin_destroy_serialized_vertex_ref`` - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_REF The vertex ref -*/ -const char* grin_serialize_vertex_ref(GRIN_GRAPH, GRIN_VERTEX_REF); - -void grin_destroy_serialized_vertex_ref(GRIN_GRAPH, const char*); - -/** - * @brief deserialize the string to vertex ref handle - * If the string is invalid, a null vertex ref is returned - * @param GRIN_GRAPH The graph - * @param msg The string message to be deserialized -*/ -GRIN_VERTEX_REF grin_deserialize_to_vertex_ref(GRIN_GRAPH, const char* msg); - -/** - * @brief check if the vertex is a master vertex - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex -*/ -bool grin_is_master_vertex(GRIN_GRAPH, GRIN_VERTEX); - -/** - * @brief check if the vertex is a mirror vertex - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex -*/ -bool grin_is_mirror_vertex(GRIN_GRAPH, GRIN_VERTEX); -#endif - -#ifdef GRIN_TRAIT_FAST_VERTEX_REF -/** - * @brief serialize the vertex ref handle to int64 - * This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref - * can be serialized into int64 instead of string. - * Obviously transferring and serializing int64 is faster than string. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_REF The vertex ref -*/ -long long int grin_serialize_vertex_ref_as_int64(GRIN_GRAPH, GRIN_VERTEX_REF); - -/** - * @brief deserialize the int64 to vertex ref handle - * @param GRIN_GRAPH The graph - * @param msg The int64 message to be deserialized -*/ -GRIN_VERTEX_REF grin_deserialize_int64_to_vertex_ref(GRIN_GRAPH, long long int msg); -#endif - -#ifdef GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST -GRIN_PARTITION_LIST grin_get_master_vertex_mirror_partition_list(GRIN_GRAPH, GRIN_VERTEX); -#endif - -#ifdef GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST -GRIN_PARTITION_LIST grin_get_mirror_vertex_mirror_partition_list(GRIN_GRAPH, GRIN_VERTEX); -#endif - -#ifdef GRIN_ENABLE_EDGE_REF -GRIN_EDGE_REF grin_get_edge_ref_by_edge(GRIN_GRAPH, GRIN_EDGE); - -void grin_destroy_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); - -GRIN_EDGE grin_get_edge_from_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); - -GRIN_PARTITION grin_get_master_partition_from_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); - -const char* grin_serialize_edge_ref(GRIN_GRAPH, GRIN_EDGE_REF); - -void grin_destroy_serialized_edge_ref(GRIN_GRAPH, const char*); - -GRIN_EDGE_REF grin_deserialize_to_edge_ref(GRIN_GRAPH, const char*); - -bool grin_is_master_edge(GRIN_GRAPH, GRIN_EDGE); - -bool grin_is_mirror_edge(GRIN_GRAPH, GRIN_EDGE); -#endif - -#ifdef GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST -GRIN_PARTITION_LIST grin_get_master_edge_mirror_partition_list(GRIN_GRAPH, GRIN_EDGE); -#endif - -#ifdef GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST -GRIN_PARTITION_LIST grin_get_mirror_edge_mirror_partition_list(GRIN_GRAPH, GRIN_EDGE); -#endif - -#endif // GRIN_INCLUDE_PARTITION_REFERENCE_H_ - -#ifdef __cplusplus -} -#endif diff --git a/flex/engines/graph_db/grin/include/include/partition/topology.h b/flex/engines/graph_db/grin/include/include/partition/topology.h deleted file mode 100644 index 829188d1347c..000000000000 --- a/flex/engines/graph_db/grin/include/include/partition/topology.h +++ /dev/null @@ -1,126 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file partition/topology.h - @brief Define the topoloy related APIs under partitioned graph -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PARTITION_TOPOLOGY_H_ -#define GRIN_INCLUDE_PARTITION_TOPOLOGY_H_ - - -#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) -/** - * @brief Get the vertex list of the graph with master vertices only. - * This API is only available for simple graph. - * @param GRIN_GRAPH The graph. - * @return The vertex list of master vertices only. -*/ -GRIN_VERTEX_LIST grin_get_vertex_list_select_master(GRIN_GRAPH); - -/** - * @brief Get the vertex list of the graph with mirror vertices only. - * This API is only available for simple graph. - * @param GRIN_GRAPH The graph. - * @return The vertex list of mirror vertices only. -*/ -GRIN_VERTEX_LIST grin_get_vertex_list_select_mirror(GRIN_GRAPH); -#endif - -#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) -/** - * @brief Get the vertex list of a given type with master vertices only. - * This API is only available for property graph. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @return The vertex list of master vertices only. -*/ -GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_master(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -/** - * @brief Get the vertex list of a given type with mirror vertices only. - * This API is only available for property graph. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @return The vertex list of mirror vertices only. -*/ -GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_mirror(GRIN_GRAPH, GRIN_VERTEX_TYPE); -#endif - - -#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_VERTEX_LIST grin_get_vertex_list_select_partition(GRIN_GRAPH, GRIN_PARTITION); -#endif - -#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_VERTEX_LIST grin_get_vertex_list_by_type_select_partition(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_PARTITION); -#endif - - - -#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST grin_get_edge_list_select_master(GRIN_GRAPH); - -GRIN_EDGE_LIST grin_get_edge_list_select_mirror(GRIN_GRAPH); -#endif - -#if defined(GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST grin_get_edge_list_by_type_select_master(GRIN_GRAPH, GRIN_EDGE_TYPE); - -GRIN_EDGE_LIST grin_get_edge_list_by_type_select_mirror(GRIN_GRAPH, GRIN_EDGE_TYPE); -#endif - - -#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST grin_get_edge_list_select_partition(GRIN_GRAPH, GRIN_PARTITION); -#endif - -#if defined(GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST grin_get_edge_list_by_type_select_partition(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_PARTITION); -#endif - - -#if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_ADJACENT_LIST grin_get_adjacent_list_select_master_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); - -GRIN_ADJACENT_LIST grin_get_adjacent_list_select_mirror_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); -#endif - -#if defined(GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_master_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE); - -GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_mirror_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE); -#endif - - -#if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_ADJACENT_LIST grin_get_adjacent_list_select_partition_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_PARTITION); -#endif - -#if defined(GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) -GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type_select_partition_neighbor(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE, GRIN_PARTITION); -#endif - - -#endif // GRIN_INCLUDE_PARTITION_TOPOLOGY_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/partition.h b/flex/engines/graph_db/grin/include/include/property/partition.h deleted file mode 100644 index 4c7afb5b166b..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/partition.h +++ /dev/null @@ -1,80 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file property/partition.h - @brief Define the partition related APIs under property graph - This file will be deprecated in the future. - Partition schema related APIs will be moved to partition/property.h -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_PARTITION_H_ -#define GRIN_INCLUDE_PROPERTY_PARTITION_H_ - - -#if defined(GRIN_ENABLE_GRAPH_PARTITION) && \ - !defined(GRIN_ASSUME_ALL_REPLICATE_PARTITION) && \ - !defined(GRIN_ASSUME_EDGE_CUT_PARTITION) && \ - !defined(GRIN_ASSUME_VERTEX_CUT_PARTITION) -// vertex partition -GRIN_VERTEX_TYPE_LIST grin_get_all_replicated_partition_vertex_types(GRIN_GRAPH); -GRIN_VERTEX_TYPE_LIST grin_get_disjoint_partition_vertex_types(GRIN_GRAPH); -GRIN_VERTEX_TYPE_LIST grin_get_follow_edge_partition_vertex_types(GRIN_GRAPH); - -// edge partition -GRIN_VEV_TYPE_LIST grin_get_all_replicated_partition_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_disjoint_partition_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_follow_src_partition_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_follow_dst_partition_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_follow_both_partition_vev_types(GRIN_GRAPH); -#endif - - -// vertex property partition -#if defined(GRIN_ENABLE_GRAPH_PARTITION) && \ - defined(GRIN_WITH_VERTEX_PROPERTY) && \ - !defined(GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY) && \ - !defined(GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY) && \ - !defined(GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY) -GRIN_VERTEX_TYPE_LIST grin_get_master_only_partition_vertex_types(GRIN_GRAPH); -GRIN_VERTEX_TYPE_LIST grin_get_replicate_master_mirror_partition_vertex_types(GRIN_GRAPH); -GRIN_VERTEX_TYPE_LIST grin_get_split_master_mirror_partition_vertex_types(GRIN_GRAPH); -#endif - -// edge property partition -#if defined(GRIN_ENABLE_GRAPH_PARTITION) && \ - defined(GRIN_WITH_EDGE_PROPERTY) && \ - !defined(GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY) && \ - !defined(GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY) && \ - !defined(GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY) -GRIN_VEV_TYPE_LIST grin_get_master_only_partition_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_replicate_master_mirror_partition_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_split_master_mirror_partition_vev_types(GRIN_GRAPH); -#endif - -// vev relation -#ifdef GRIN_TRAIT_SPECIFIC_VEV_RELATION -GRIN_VEV_TYPE_LIST grin_get_one_to_one_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_one_to_many_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_many_to_one_vev_types(GRIN_GRAPH); -GRIN_VEV_TYPE_LIST grin_get_many_to_many_vev_types(GRIN_GRAPH); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_PARTITION_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/primarykey.h b/flex/engines/graph_db/grin/include/include/property/primarykey.h deleted file mode 100644 index 8585d1f32e0b..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/primarykey.h +++ /dev/null @@ -1,67 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file primarykey.h - @brief Define the primary key related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_ -#define GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_ - - -#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS -/** - * @brief Get the vertex types that have primary keys - * In some graph, not every vertex type has primary keys. - * @param GRIN_GRAPH The graph - * @return The vertex type list of types that have primary keys -*/ -GRIN_VERTEX_TYPE_LIST grin_get_vertex_types_with_primary_keys(GRIN_GRAPH); - -/** - * @brief Get the primary keys properties of a vertex type - * The primary keys properties are the properties that can be used to identify a vertex. - * They are a subset of the properties of a vertex type. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_TYPE The vertex type - * @return The primary keys properties list -*/ -GRIN_VERTEX_PROPERTY_LIST grin_get_primary_keys_by_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -/** - * @brief Get the primary keys values row of a vertex - * The values in the row are in the same order as the primary keys properties. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @return The primary keys values row -*/ -GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH, GRIN_VERTEX); -#endif - -#ifdef GRIN_ENABLE_EDGE_PRIMARY_KEYS -GRIN_EDGE_TYPE_LIST grin_get_edge_types_with_primary_keys(GRIN_GRAPH); - -GRIN_EDGE_PROPERTY_LIST grin_get_primary_keys_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); - -GRIN_ROW grin_get_edge_primary_keys_row(GRIN_GRAPH, GRIN_EDGE); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_PRIMARY_KEY_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/property.h b/flex/engines/graph_db/grin/include/include/property/property.h deleted file mode 100644 index 924541f7f574..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/property.h +++ /dev/null @@ -1,269 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file property.h - @brief Define the property related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_PROPERTY_H_ -#define GRIN_INCLUDE_PROPERTY_PROPERTY_H_ - - -void grin_destroy_string_value(GRIN_GRAPH, const char*); - -#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME -/** - * @brief Get the vertex property name - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_TYPE The vertex type that the property belongs to - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The property's name as string - */ -const char* grin_get_vertex_property_name(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the vertex property with a given name under a specific vertex type - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_TYPE The specific vertex type - * @param name The name - * @return The vertex property - */ -GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH, GRIN_VERTEX_TYPE, const char* name); - -/** - * @brief Get properties under all types with a given name. - * For example, vertex type "person" and "company" both have a property - * called "name". When this API is called given "name", it will return a list - * of "name" properties under both types. - * @param GRIN_GRAPH The graph - * @param name The name - * @return The vertex property list of properties with the given name - */ -GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH, const char* name); -#endif - -#ifdef GRIN_WITH_EDGE_PROPERTY_NAME -const char* grin_get_edge_property_name(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY); - -GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH, GRIN_EDGE_TYPE, const char* name); - -GRIN_EDGE_PROPERTY_LIST grin_get_edge_properties_by_name(GRIN_GRAPH, const char* name); -#endif - - -#ifdef GRIN_WITH_VERTEX_PROPERTY -bool grin_equal_vertex_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY, GRIN_VERTEX_PROPERTY); - -void grin_destroy_vertex_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the datatype of the vertex property - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The datatype of the vertex property -*/ -GRIN_DATATYPE grin_get_vertex_property_datatype(GRIN_GRAPH, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of int32, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype int32. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -int grin_get_vertex_property_value_of_int32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of uint32, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype uint32. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -unsigned int grin_get_vertex_property_value_of_uint32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of int64, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype int64. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of uint64, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype uint64. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -unsigned long long int grin_get_vertex_property_value_of_uint64(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of float, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype float. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -float grin_get_vertex_property_value_of_float(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of double, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype double. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -double grin_get_vertex_property_value_of_double(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of string, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype string. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * Note that the returned string should be explicitly freed by the user, - * by calling API ``grin_destroy_string_value``. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of int32, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype date32. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -int grin_get_vertex_property_value_of_date32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of int32, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype time32. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * Note that the returned string should be explicitly freed by the user, - * by calling API ``grin_destroy_string_value``. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -int grin_get_vertex_property_value_of_time32(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the value of int64, given a vertex and a vertex property. - * The user should make sure the vertex property is of datatype timestamp64. - * The return int has no predefined invalid value. - * User should use ``grin_get_last_error_code()`` to check if the API call - * is successful. - * Note that the returned string should be explicitly freed by the user, - * by calling API ``grin_destroy_string_value``. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The value of the property -*/ -long long int grin_get_vertex_property_value_of_timestamp64(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); - -/** - * @brief Get the vertex type that a given vertex property belongs to. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX_PROPERTY The vertex property - * @return The vertex type -*/ -GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH, GRIN_VERTEX_PROPERTY); -#endif - -#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) -const void* grin_get_vertex_property_value(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX_PROPERTY); -#endif - - -#ifdef GRIN_WITH_EDGE_PROPERTY -bool grin_equal_edge_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY, GRIN_EDGE_PROPERTY); - -void grin_destroy_edge_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY); - -GRIN_DATATYPE grin_get_edge_property_datatype(GRIN_GRAPH, GRIN_EDGE_PROPERTY); - -int grin_get_edge_property_value_of_int32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -unsigned int grin_get_edge_property_value_of_uint32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -long long int grin_get_edge_property_value_of_int64(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -unsigned long long int grin_get_edge_property_value_of_uint64(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -float grin_get_edge_property_value_of_float(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -double grin_get_edge_property_value_of_double(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -const char* grin_get_edge_property_value_of_string(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -int grin_get_edge_property_value_of_date32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -int grin_get_edge_property_value_of_time32(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -long long int grin_get_edge_property_value_of_timestamp64(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); - -GRIN_EDGE_TYPE grin_get_edge_type_from_property(GRIN_GRAPH, GRIN_EDGE_PROPERTY); -#endif - -#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) -const void* grin_get_edge_property_value(GRIN_GRAPH, GRIN_EDGE, GRIN_EDGE_PROPERTY); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_PROPERTY_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/propertylist.h b/flex/engines/graph_db/grin/include/include/property/propertylist.h deleted file mode 100644 index 07e65c27eb43..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/propertylist.h +++ /dev/null @@ -1,98 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file propertylist.h - @brief Define the property list related and graph projection APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_ -#define GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_ - - -#ifdef GRIN_WITH_VERTEX_PROPERTY -/** - * @brief Get the vertex property list of the graph. - * This API is only available for property graph. - * @param GRIN_GRAPH The graph. - * @return The vertex property list. -*/ -GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -size_t grin_get_vertex_property_list_size(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST); - -GRIN_VERTEX_PROPERTY grin_get_vertex_property_from_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST, size_t); - -GRIN_VERTEX_PROPERTY_LIST grin_create_vertex_property_list(GRIN_GRAPH); - -void grin_destroy_vertex_property_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST); - -bool grin_insert_vertex_property_to_list(GRIN_GRAPH, GRIN_VERTEX_PROPERTY_LIST, GRIN_VERTEX_PROPERTY); -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -/** - * @brief Get the vertex property handle by id. - * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``, - * meaning that the storage has naturally increasing ids for vertex properties - * under a certain vertex type. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @param GRIN_VERTEX_PROPERTY_ID The vertex property id. - * @return The vertex property handle. -*/ -GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY_ID); - -/** - * @brief Get the vertex property's natural id. - * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``, - * meaning that the storage has naturally increasing ids for vertex properties - * under a certain vertex type. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @param GRIN_VERTEX_PROPERTY The vertex property handle. - * @return The vertex property id. -*/ -GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_PROPERTY); -#endif - - -#ifdef GRIN_WITH_EDGE_PROPERTY -GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); - -size_t grin_get_edge_property_list_size(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST); - -GRIN_EDGE_PROPERTY grin_get_edge_property_from_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST, size_t); - -GRIN_EDGE_PROPERTY_LIST grin_create_edge_property_list(GRIN_GRAPH); - -void grin_destroy_edge_property_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST); - -bool grin_insert_edge_property_to_list(GRIN_GRAPH, GRIN_EDGE_PROPERTY_LIST, GRIN_EDGE_PROPERTY); -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -GRIN_EDGE_PROPERTY grin_get_edge_property_by_id(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY_ID); - -/// We must specify the edge type here, because the edge property id is unique only under a specific edge type -GRIN_EDGE_PROPERTY_ID grin_get_edge_property_id(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_PROPERTY); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_PROPERTY_LIST_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/row.h b/flex/engines/graph_db/grin/include/include/property/row.h deleted file mode 100644 index 7533daac105a..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/row.h +++ /dev/null @@ -1,115 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file row.h - @brief Define the row related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_ROW_H_ -#define GRIN_INCLUDE_PROPERTY_ROW_H_ - - -#ifdef GRIN_ENABLE_ROW -void grin_destroy_row(GRIN_GRAPH, GRIN_ROW); - -int grin_get_int32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -unsigned int grin_get_uint32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -long long int grin_get_int64_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -unsigned long long int grin_get_uint64_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -float grin_get_float_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -double grin_get_double_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -const char* grin_get_string_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -int grin_get_date32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -int grin_get_time32_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -long long int grin_get_timestamp64_from_row(GRIN_GRAPH, GRIN_ROW, size_t); - -/** - * @brief Create a row. - * Row works as carrier of property values in GRIN. - * It is a pure value array, and users can only get the value by the array index. - * That means users should understand the property that each value is - * representing when using the row. - * Currently rows are used in two scenarios: - * 1. Users can create a row of values for primary keys properties, - * and then query the vertex/edge using the row if pk indexing is enabled. - * 2. Users can get the row of values for the entire property list of - * a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``. - * However this API is not recommended if the user only wants to get the - * properties values, in which case, the user can get property values - * one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``. -*/ -GRIN_ROW grin_create_row(GRIN_GRAPH); - -bool grin_insert_int32_to_row(GRIN_GRAPH, GRIN_ROW, int); - -bool grin_insert_uint32_to_row(GRIN_GRAPH, GRIN_ROW, unsigned int); - -bool grin_insert_int64_to_row(GRIN_GRAPH, GRIN_ROW, long long int); - -bool grin_insert_uint64_to_row(GRIN_GRAPH, GRIN_ROW, unsigned long long int); - -bool grin_insert_float_to_row(GRIN_GRAPH, GRIN_ROW, float); - -bool grin_insert_double_to_row(GRIN_GRAPH, GRIN_ROW, double); - -bool grin_insert_string_to_row(GRIN_GRAPH, GRIN_ROW, const char*); - -bool grin_insert_date32_to_row(GRIN_GRAPH, GRIN_ROW, int); - -bool grin_insert_time32_to_row(GRIN_GRAPH, GRIN_ROW, int); - -bool grin_insert_timestamp64_to_row(GRIN_GRAPH, GRIN_ROW, long long int); -#endif - -#if defined(GRIN_ENABLE_ROW) && defined(GRIN_TRAIT_CONST_VALUE_PTR) -const void* grin_get_value_from_row(GRIN_GRAPH, GRIN_ROW, GRIN_DATATYPE, size_t); -#endif - - -#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_ENABLE_ROW) -/** - * @brief Get row of values for the entire property list of a vertex. - * Later users can get property values from the row using APIs like - * ``grin_get_int32_from_row``. - * However this two-step value getting is not recommended if the user - * only wants to get the value of one property, in which case, the user - * should use APIs like ``grin_get_vertex_property_value_of_int32``. - * @param GRIN_GRAPH The graph - * @param GRIN_VERTEX The vertex - */ -GRIN_ROW grin_get_vertex_row(GRIN_GRAPH, GRIN_VERTEX); -#endif - - -#if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_ENABLE_ROW) -GRIN_ROW grin_get_edge_row(GRIN_GRAPH, GRIN_EDGE); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_ROW_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/topology.h b/flex/engines/graph_db/grin/include/include/property/topology.h deleted file mode 100644 index 29181d2b8ef9..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/topology.h +++ /dev/null @@ -1,74 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file property/topology.h - @brief Define the topology related APIs under property graph -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_ -#define GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_ - - -#ifdef GRIN_WITH_VERTEX_PROPERTY -/** - * @brief Get the vertex number of a given type in the graph. - * This API is only available for property graph. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @return The vertex number. -*/ -size_t grin_get_vertex_num_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); -#endif - -#ifdef GRIN_WITH_EDGE_PROPERTY -size_t grin_get_edge_num_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); -#endif - -#if defined(GRIN_ENABLE_VERTEX_LIST) && defined(GRIN_WITH_VERTEX_PROPERTY) -/** - * @brief Get the vertex list of a given type. - * This API is only available for property graph. - * To get a vertex list chain of all types, using APIs in GRIN extension. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @return The vertex list of the given type. -*/ -GRIN_VERTEX_LIST grin_get_vertex_list_by_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); -#endif - -#if defined(GRIN_ENABLE_EDGE_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST grin_get_edge_list_by_type(GRIN_GRAPH, GRIN_EDGE_TYPE); -#endif - -#if defined(GRIN_ENABLE_ADJACENT_LIST) && defined(GRIN_WITH_EDGE_PROPERTY) -/** - * @brief Get the adjacent list of given direction, vertex and edge type. - * This API is only available for property graph. - * To get a adjacent list chain of all types, using APIs in GRIN extension. - * @param GRIN_GRAPH The graph. - * @param GRIN_DIRECTION The direction of the adjacent list. - * @param GRIN_VERTEX The vertex. - * @return The adjacent list. -*/ -GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX, GRIN_EDGE_TYPE); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_TOPOLOGY_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/property/type.h b/flex/engines/graph_db/grin/include/include/property/type.h deleted file mode 100644 index 674521b566f4..000000000000 --- a/flex/engines/graph_db/grin/include/include/property/type.h +++ /dev/null @@ -1,176 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - @file type.h - @brief Define the vertex/edge type related APIs -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_PROPERTY_TYPE_H_ -#define GRIN_INCLUDE_PROPERTY_TYPE_H_ - - -#ifdef GRIN_WITH_VERTEX_PROPERTY -bool grin_equal_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_TYPE); - -GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH, GRIN_VERTEX); - -void grin_destroy_vertex_type(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -/** - * @brief Get the vertex type list of the graph - * This API is only available for property graph. - * It lists all the vertex types in the graph. - * @param GRIN_GRAPH The graph. - * @return The vertex type list. -*/ -GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list(GRIN_GRAPH); - -void grin_destroy_vertex_type_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST); - -GRIN_VERTEX_TYPE_LIST grin_create_vertex_type_list(GRIN_GRAPH); - -bool grin_insert_vertex_type_to_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST, GRIN_VERTEX_TYPE); - -size_t grin_get_vertex_type_list_size(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST); - -GRIN_VERTEX_TYPE grin_get_vertex_type_from_list(GRIN_GRAPH, GRIN_VERTEX_TYPE_LIST, size_t); -#endif - -#ifdef GRIN_WITH_VERTEX_TYPE_NAME -/** - * @brief Get the vertex type name. - * This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``, - * meaning that the graph has a unique name for each vertex type. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @return The vertex type name of string. -*/ -const char* grin_get_vertex_type_name(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -/** - * @brief Get the vertex type by name. - * This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``, - * meaning that the graph has a unique name for each vertex type. - * @param GRIN_GRAPH The graph. - * @param name The vertex type name. - * @return The vertex type. -*/ -GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH, const char* name); -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -/** - * @brief Get the vertex type id. - * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``, - * meaning that the graph has naturally increasing ids for vertex types. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The vertex type. - * @return The vertex type id. -*/ -GRIN_VERTEX_TYPE_ID grin_get_vertex_type_id(GRIN_GRAPH, GRIN_VERTEX_TYPE); - -/** - * @brief Get the vertex type by id. - * This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``, - * meaning that the graph has naturally increasing ids for vertex types. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE_ID The vertex type id. - * @return The vertex type. -*/ -GRIN_VERTEX_TYPE grin_get_vertex_type_by_id(GRIN_GRAPH, GRIN_VERTEX_TYPE_ID); -#endif - - -#ifdef GRIN_WITH_EDGE_PROPERTY -bool grin_equal_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE, GRIN_EDGE_TYPE); - -GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH, GRIN_EDGE); - -void grin_destroy_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); - -GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH); - -void grin_destroy_edge_type_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST); - -GRIN_EDGE_TYPE_LIST grin_create_edge_type_list(GRIN_GRAPH); - -bool grin_insert_edge_type_to_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST, GRIN_EDGE_TYPE); - -size_t grin_get_edge_type_list_size(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST); - -GRIN_EDGE_TYPE grin_get_edge_type_from_list(GRIN_GRAPH, GRIN_EDGE_TYPE_LIST, size_t); -#endif - -#ifdef GRIN_WITH_EDGE_TYPE_NAME -const char* grin_get_edge_type_name(GRIN_GRAPH, GRIN_EDGE_TYPE); - -GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH, const char*); -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -GRIN_EDGE_TYPE_ID grin_get_edge_type_id(GRIN_GRAPH, GRIN_EDGE_TYPE); - -GRIN_EDGE_TYPE grin_get_edge_type_by_id(GRIN_GRAPH, GRIN_EDGE_TYPE_ID); -#endif - - -#if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_WITH_EDGE_PROPERTY) -/** - * @brief Get source vertex types related to an edge type. - * GRIN assumes the relation between edge type and pairs of vertex types is - * many-to-many. - * To return the related pairs of vertex types, GRIN provides two APIs to get - * the src and dst vertex types respectively. - * The returned vertex type lists are of the same size, - * and the src/dst vertex types are aligned with their positions in the lists. - * @param GRIN_GRAPH The graph. - * @param GRIN_EDGE_TYPE The edge type. - * @return The vertex type list of source. - */ -GRIN_VERTEX_TYPE_LIST grin_get_src_types_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); - -/** - * @brief Get destination vertex types related to an edge type. - * GRIN assumes the relation between edge type and pairs of vertex types is - * many-to-many. - * To return the related pairs of vertex types, GRIN provides two APIs to get - * the src and dst vertex types respectively. - * The returned vertex type lists are of the same size, - * and the src/dst vertex types are aligned with their positions in the lists. - * @param GRIN_GRAPH The graph. - * @param GRIN_EDGE_TYPE The edge type. - * @return The vertex type list of destination. -*/ -GRIN_VERTEX_TYPE_LIST grin_get_dst_types_by_edge_type(GRIN_GRAPH, GRIN_EDGE_TYPE); - -/** - * @brief Get edge types related to a pair of vertex types. - * GRIN assumes the relation between edge type and pairs of vertex types is - * many-to-many. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_TYPE The source vertex type. - * @param GRIN_VERTEX_TYPE The destination vertex type. - * @return The related edge type list. -*/ -GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair(GRIN_GRAPH, GRIN_VERTEX_TYPE, GRIN_VERTEX_TYPE); -#endif - -#endif // GRIN_INCLUDE_PROPERTY_TYPE_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/topology/adjacentlist.h b/flex/engines/graph_db/grin/include/include/topology/adjacentlist.h deleted file mode 100644 index 6e2a3e8426e3..000000000000 --- a/flex/engines/graph_db/grin/include/include/topology/adjacentlist.h +++ /dev/null @@ -1,117 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_ -#define GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_ - - -#if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) -/** - * @brief Get the adjacent list of a vertex. - * This API is only available when the graph has no edge property. - * Otherwise, use ``grin_get_adjacent_list_by_edge_type`` instead. - * @param GRIN_GRAPH The graph. - * @param GRIN_DIRECTION The direction of the adjacent list. - * @param GRIN_VERTEX The vertex. - * @return The adjacent list. -*/ -GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH, GRIN_DIRECTION, GRIN_VERTEX); -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST -void grin_destroy_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST); -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY -size_t grin_get_adjacent_list_size(GRIN_GRAPH, GRIN_ADJACENT_LIST); - -/** - * @brief Get the neighbor vertex from the adjacent list. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST The adjacent list. - * @param index The index of the edge to/from the neighbor in the adjacent list. - * @return The neighbor vertex. -*/ -GRIN_VERTEX grin_get_neighbor_from_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST, size_t index); - -/** - * @brief Get the edge from the adjacent list. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST The adjacent list. - * @param index The index of the edge in the adjacent list. - * @return The edge. Note that when the direction is OUT, the destination vertex - * of the edge is the neighbor vertex. While the direction is IN, the source - * vertex of the edge is the neighbor vertex. -*/ -GRIN_EDGE grin_get_edge_from_adjacent_list(GRIN_GRAPH, GRIN_ADJACENT_LIST, size_t); -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -/** - * @brief Get the begin iterator of the adjacent list. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST The adjacent list. - * @return The begin iterator of the adjacent list. -*/ -GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin(GRIN_GRAPH, GRIN_ADJACENT_LIST); - -void grin_destroy_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); - -/** - * @brief Update the iterator to the next of the adjacent list. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator to be updated. -*/ -void grin_get_next_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); - -/** - * @brief Check if the adjacent list iterator is at the end. - * Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin`` - * if the adjacent list is empty. - * Users should check if the iterator is at the end before using it. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator. - * @return True if the iterator is at the end, otherwise false. -*/ -bool grin_is_adjacent_list_end(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); - -/** - * @brief Get the neighbor vertex from the adjacent list iterator. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator. - * @return The neighbor vertex. -*/ -GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); - -/** - * @brief Get the edge from the adjacent list iterator. - * @param GRIN_GRAPH The graph. - * @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator. - * @return The edge. Note that when the direction is OUT, the destination vertex - * of the edge is the neighbor vertex. While the direction is IN, the source - * vertex of the edge is the neighbor vertex. -*/ -GRIN_EDGE grin_get_edge_from_adjacent_list_iter(GRIN_GRAPH, GRIN_ADJACENT_LIST_ITERATOR); -#endif - -#endif // GRIN_INCLUDE_TOPOLOGY_ADJACENTLIST_H_ - -#ifdef __cplusplus -} -#endif diff --git a/flex/engines/graph_db/grin/include/include/topology/edgelist.h b/flex/engines/graph_db/grin/include/include/topology/edgelist.h deleted file mode 100644 index 221693c8b73b..000000000000 --- a/flex/engines/graph_db/grin/include/include/topology/edgelist.h +++ /dev/null @@ -1,54 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_ -#define GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_ - - -#if defined(GRIN_ENABLE_EDGE_LIST) && !defined(GRIN_WITH_EDGE_PROPERTY) -GRIN_EDGE_LIST grin_get_edge_list(GRIN_GRAPH); -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST -void grin_destroy_edge_list(GRIN_GRAPH, GRIN_EDGE_LIST); -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST_ARRAY -size_t grin_get_edge_list_size(GRIN_GRAPH, GRIN_EDGE_LIST); - -GRIN_EDGE grin_get_edge_from_list(GRIN_GRAPH, GRIN_EDGE_LIST, size_t); -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR -GRIN_EDGE_LIST_ITERATOR grin_get_edge_list_begin(GRIN_GRAPH, GRIN_EDGE_LIST); - -void grin_destroy_edge_list_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); - -void grin_get_next_edge_list_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); - -bool grin_is_edge_list_end(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); - -GRIN_EDGE grin_get_edge_from_iter(GRIN_GRAPH, GRIN_EDGE_LIST_ITERATOR); -#endif - -#endif // GRIN_INCLUDE_TOPOLOGY_EDGELIST_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/topology/structure.h b/flex/engines/graph_db/grin/include/include/topology/structure.h deleted file mode 100644 index 0604b3628f6c..000000000000 --- a/flex/engines/graph_db/grin/include/include/topology/structure.h +++ /dev/null @@ -1,121 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_ -#define GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_ - -/** - * @brief Get a (non-partitioned) graph from storage - * @param uri The URI of the graph. - * Current URI for supported storage includes: - * 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version} - * 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy} - * 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional. - * @return A graph handle. -*/ -GRIN_GRAPH grin_get_graph_from_storage(const char*); - -void grin_destroy_graph(GRIN_GRAPH); - -// Graph -#if defined(GRIN_ASSUME_HAS_DIRECTED_GRAPH) && defined(GRIN_ASSUME_HAS_UNDIRECTED_GRAPH) -/** - * @brief Check if the graph is directed. - * This API is only available when the storage supports both directed and - * undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH`` - * and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined. - * @param GRIN_GRAPH The graph. - * @return True if the graph is directed, otherwise false. -*/ -bool grin_is_directed(GRIN_GRAPH); -#endif - -#ifdef GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -/** - * @brief Check if the graph is a multigraph. - * This API is only available when the storage supports multigraph. - * @param GRIN_GRAPH The graph. - * @return True if the graph is a multigraph, otherwise false. -*/ -bool grin_is_multigraph(GRIN_GRAPH); -#endif - -#ifndef GRIN_WITH_VERTEX_PROPERTY -/** - * @brief Get the number of vertices in the graph. - * This API is only available for simple graph. - * @param GRIN_GRAPH The graph. - * @return The number of vertices in the graph. -*/ -size_t grin_get_vertex_num(GRIN_GRAPH); -#endif - -#ifndef GRIN_WITH_EDGE_PROPERTY -/** - * @brief Get the number of edges in the graph. - * This API is only available for simple graph. - * @param GRIN_GRAPH The graph. - * @return The number of edges in the graph. -*/ -size_t grin_get_edge_num(GRIN_GRAPH); -#endif - - -// Vertex -void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX); - -bool grin_equal_vertex(GRIN_GRAPH, GRIN_VERTEX, GRIN_VERTEX); - -// Data -#ifdef GRIN_WITH_VERTEX_DATA -GRIN_DATATYPE grin_get_vertex_data_datatype(GRIN_GRAPH, GRIN_VERTEX); - -const void* grin_get_vertex_data_value(GRIN_GRAPH, GRIN_VERTEX); -#endif - -// Edge -void grin_destroy_edge(GRIN_GRAPH, GRIN_EDGE); - -/** - * @brief Get the source vertex of an edge. - * @param GRIN_GRAPH The graph. - * @param GRIN_EDGE The edge. - * @return The source vertex of the edge. -*/ -GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE); - -/** - * @brief Get the destination vertex of an edge. - * @param GRIN_GRAPH The graph. - * @param GRIN_EDGE The edge. - * @return The destination vertex of the edge. -*/ -GRIN_VERTEX grin_get_dst_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE); - -#ifdef GRIN_WITH_EDGE_DATA -GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE); - -const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE); -#endif - -#endif // GRIN_INCLUDE_TOPOLOGY_STRUCTURE_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/include/topology/vertexlist.h b/flex/engines/graph_db/grin/include/include/topology/vertexlist.h deleted file mode 100644 index 42922bae1374..000000000000 --- a/flex/engines/graph_db/grin/include/include/topology/vertexlist.h +++ /dev/null @@ -1,94 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_ -#define GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_ - - -#if defined(GRIN_ENABLE_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) -/** - * @brief Get the vertex list of the graph - * This API is only available for simple graph. - * In property graph, use ``grin_get_vertex_list_by_type`` instead. - * @param GRIN_GRAPH The graph. - * @return The vertex list. -*/ -GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH); -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST -void grin_destroy_vertex_list(GRIN_GRAPH, GRIN_VERTEX_LIST); -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY -size_t grin_get_vertex_list_size(GRIN_GRAPH, GRIN_VERTEX_LIST); - -/** - * @brief Get the vertex from the vertex list. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_LIST The vertex list. - * @param index The index of the vertex in the vertex list. - * @return The vertex. -*/ -GRIN_VERTEX grin_get_vertex_from_list(GRIN_GRAPH, GRIN_VERTEX_LIST, size_t index); -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -/** - * @brief Get the begin iterator of the vertex list. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_LIST The vertex list. - * @return The begin iterator. -*/ -GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH, GRIN_VERTEX_LIST); - -void grin_destroy_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); - -/** - * @brief Update the iterator to the next of the vertex list. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_LIST_ITERATOR The iterator to be updated. -*/ -void grin_get_next_vertex_list_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); - -/** - * @brief Check whether the iterator reaches the end of the vertex list. - * Note that we may get an end iterator when calling ``grin_get_vertex_list_begin`` - * if the vertex list is empty. - * Users should check if the iterator is at the end before using it. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_LIST_ITERATOR The iterator. - * @return True if the iterator reaches the end of the vertex list. -*/ -bool grin_is_vertex_list_end(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); - -/** - * @brief Get the vertex from the iterator. - * @param GRIN_GRAPH The graph. - * @param GRIN_VERTEX_LIST_ITERATOR The iterator. - * @return The vertex. -*/ -GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH, GRIN_VERTEX_LIST_ITERATOR); -#endif - -#endif // GRIN_INCLUDE_TOPOLOGY_VERTEXLIST_H_ - -#ifdef __cplusplus -} -#endif diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto deleted file mode 100644 index f96b9f0afb77..000000000000 --- a/flex/engines/graph_db/grin/include/proto/gie_data_model/data_type.proto +++ /dev/null @@ -1,127 +0,0 @@ -syntax = "proto3"; - -package gie; -option java_package = "com.alibaba.graphscope.proto.schema"; - -enum PrimitiveType { - DT_ANY = 0; - DT_SIGNED_INT32 = 1; - DT_UNSIGNED_INT32 = 2; - DT_SIGNED_INT64 = 3; - DT_UNSIGNED_INT64 = 4; - DT_BOOL = 5; - DT_FLOAT = 6; - DT_DOUBLE = 7; - DT_STRING = 8; // string with unlimited length -} - -message Numeric { // precision=4 scale=2 : 23.12 - uint32 precision = 1; - uint32 scale = 2; -} - -message Char { - uint32 fixed_length = 1; -} - -message VarChar { - uint32 max_length = 1; -} - -// temporal types - -enum DateFormat { - DF_YYYY_MM_DD = 0; // ISO fomat: 2019-01-01 -} - -enum TimeFormat { - TF_HH_MM_SS_SSS = 0; // ISO format: 00:00:00.000 -} - -enum DateTimeFormat { - DTF_YYYY_MM_DD_HH_MM_SS_SSS = 0; // ISO format: 2019-01-01 00:00:00.000 -} - -enum TimeZoneFormat { - TZF_UTC = 0; // Z - TZF_OFFSET = 1; // +08:00 or -08:00 -} - -message Date { - DateFormat date_format = 1; -} - -message Time { - TimeFormat time_format = 1; - TimeZoneFormat time_zone_format = 2; -} - -message DateTime { - DateTimeFormat date_time_format = 1; - TimeZoneFormat time_zone_format = 2; -} - -// element type nested in array or multiset or map -message ComponentType { - oneof item { - PrimitiveType primitive_type = 1; - Numeric numeric = 2; - Char char = 3; - VarChar var_char = 4; - Date date = 5; - Time time = 6; - DateTime date_time = 7; - } -} - -message Array { - ComponentType component_type = 1; - uint32 max_length = 2; -} - -message MultiSet { - ComponentType component_type = 1; -} - -message Map { - // type can be hashing - message KeyType { - enum PrimitiveKeyType { - DT_SIGNED_INT32 = 0; - DT_UNSIGNED_INT32 = 1; - DT_SIGNED_INT64 = 2; - DT_UNSIGNED_INT64 = 3; - DT_BOOL = 4; - DT_STRING = 5; - } - - oneof item { - PrimitiveKeyType primitive_key_type = 1; - Char char = 2; - VarChar var_char = 3; - Date date = 4; - Time time = 5; - DateTime date_time = 6; - } - } - - KeyType key_type = 1; - ComponentType value_type = 2; -} - -message StorageDataType { - oneof item { - PrimitiveType primitive_type = 1; - Numeric numeric = 2; - Char char = 3; - VarChar var_char = 4; - Date date = 5; - Time time = 6; - DateTime date_time = 7; - Array array = 8; - MultiSet multi_set = 9; - Map map = 10; - } - - bool nullable = 11; -} diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto deleted file mode 100644 index e5d323464d4e..000000000000 --- a/flex/engines/graph_db/grin/include/proto/gie_data_model/graph.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package gie; -option java_package = "com.alibaba.graphscope.proto.schema"; - -import "schema.proto"; -import "partition.proto"; - -message Graph { - string snapshot_id = 1; - Schema schema = 2; - GraphPartitionStrategy partition_strategy = 3; -} \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto deleted file mode 100644 index bfc7c571add8..000000000000 --- a/flex/engines/graph_db/grin/include/proto/gie_data_model/partition.proto +++ /dev/null @@ -1,123 +0,0 @@ -syntax = "proto3"; - -package gie; -option java_package = "com.alibaba.graphscope.proto.schema"; - -import "schema.proto"; - -message GraphTopologyPartitionStrategy { - enum VertexPartitionStrategy { - VPS_ALL = 0; // a vertex is replicated in all partitions - VPS_ONE = 1; // Edge-Cut, a vertex is distributed to one partition - 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 - } - - enum EdgePartitionStrategy { - EPS_ALL = 0; // an edge is replicated in all partitions - EPS_ONE = 1; // Vertex-Cut, an edge is distributed to one partition - EPS_FOLLOW_SRC = 2; // Edge-Cut, an edge is distributed to the partition where its source vertex resides - EPS_FOLLOW_DST = 3; // Edge-Cut, an edge is distributed to the partition where its dst vertex resides - EPS_FOLLOW_BOTH = 4; // Edge-Cut, an edge is distributed to the partitions where its src or dst vertices reside - } - - // Index Strategy to lookup edges by vertex - enum VertexToEdgeIndexStrategy { - VTE_NONE = 0; // no indexing, i.e. Vertex-Cut - VTE_INDEX_SRC = 1; // indexing based on the source vertex - VTE_INDEX_DST = 2; // indexing based on the dst vertex - VTE_INDEX_BOTH = 3; // indexing based on both the src and dst vertices - } - - message AllReplicate { - // VertexPartitionStrategy = ALL - // EdgePartitionStrategy = ALL - VertexToEdgeIndexStrategy index_strategy = 1; - } - - message VertexCut { - // partition edges first, then place vertices automatically - } - - message EdgeCut { - // partition vertices first using MAP_TO_ONE strategy, - // then place edges with certain placement strategy - - // VertexPartitionStrategy = ONE - EdgePartitionStrategy edge_partition_strategy = 1; - VertexToEdgeIndexStrategy edge_index_strategy = 2; - } - - message AdvancedEdgeCut { - message VertexTypePairEdgePartitionStrategy { - uint32 src_type = 1; - uint32 dst_type = 2; - EdgePartitionStrategy edge_partition_strategy = 3; - } - - message VertexTypePairEdgeIndexStrategy { - uint32 src_type = 1; - uint32 dst_type = 2; - VertexToEdgeIndexStrategy edge_index_strategy = 3; - } - - message VertexTypePairEdgePartitionStrategyArray { - repeated VertexTypePairEdgePartitionStrategy vertex_type_pair_edge_partition_strategy = 1; - } - - message VertexTypePairEdgeIndexStrategyArray { - repeated VertexTypePairEdgeIndexStrategy vertex_type_pair_edge_index_strategy = 1; - } - - map vertex_type_to_partition_strategy = 1; - map edge_type_to_partition_strategy = 2; - map edge_type_to_index_strategy = 3; - } - - oneof item { - AllReplicate replicate = 1; - EdgeCut edge_cut = 2; - VertexCut vertex_cut = 3; - AdvancedEdgeCut advanced_edge_cut = 4; - } -} - -message GraphPropertyPlacementStrategy { - // This strategy assumes that properties are always distributed along with the topology of the vertices/edges. - // Other strategies, i.e., properties are not distributed along with the topology, are not currently being considered. - enum PropertyPlacementStrategy { - PPS_UNDEFINED = 0; - // Properties exist only in one of partitions (i.e., the master node in GRIN) where the vertex/edge topology resides. - // 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'. - PPS_ON_MASTER = 1; - // Properties exist in each partition where the vertex/edge topology resides. - // 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'. - PPS_ON_MASTER_N_MIRROR = 2; - } - - message AllReplicatePropertyPlacement { - PropertyPlacementStrategy all_replicate_vertex_property_placement_strategy = 1; - PropertyPlacementStrategy all_replicate_edge_property_placement_strategy = 2; - } - - // Combine the EdgeCut and AdvancedEdgeCut partition strategies. - message EdgeCutPropertyPlacement { - PropertyPlacementStrategy all_replicate_vertex_property_placement_strategy = 1; - PropertyPlacementStrategy edge_cut_vertex_property_placement_strategy = 2; - PropertyPlacementStrategy edge_cut_edge_property_placement_strategy = 3; - } - - message VertexCutPropertyPlacement { - // property placement in VertexCut is not considered currently. - } - - oneof item { - AllReplicatePropertyPlacement all_replicate_property_placement = 1; - EdgeCutPropertyPlacement edge_cut_property_placement = 2; - VertexCutPropertyPlacement vertex_cut_property_placement = 3; - } -} - -message GraphPartitionStrategy { - GraphTopologyPartitionStrategy topology_partition = 1; - GraphPropertyPlacementStrategy property_placement = 2; -} diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto deleted file mode 100644 index 8a5f28f76851..000000000000 --- a/flex/engines/graph_db/grin/include/proto/gie_data_model/schema.proto +++ /dev/null @@ -1,46 +0,0 @@ -syntax = "proto3"; - -package gie; -option java_package = "com.alibaba.graphscope.proto.schema"; - -import "data_type.proto"; - -message Property { - uint32 property_id = 1; - string property_name = 2; - StorageDataType property_type = 3; - string comment = 4; // description of the property -} - -message VertexType { - uint32 type_id = 1; - string type_name = 2; - repeated Property properties = 3; - repeated uint32 primary_key_ids = 4; - string comment = 5; // description of the vertex type -} - -message EdgeType { - enum Relation { - MANY_TO_MANY = 0; - MANY_TO_ONE = 1; - ONE_TO_MANY = 2; - ONE_TO_ONE = 3; - } - message VertexTypePairRelation { - uint32 src_type_id = 1; - uint32 dst_type_id = 2; - Relation relation = 3; - } - uint32 type_id = 1; - string type_name = 2; - repeated Property properties = 3; - repeated uint32 primary_key_ids = 4; - repeated VertexTypePairRelation vertex_type_pair_relations = 5; - string comment = 6; // description of the edge type -} - -message Schema { - repeated VertexType vertex_types = 1; - repeated EdgeType edge_types = 2; -} diff --git a/flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto b/flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto deleted file mode 100644 index bc4e5554940a..000000000000 --- a/flex/engines/graph_db/grin/include/proto/gie_data_model/statistics.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; - -package gie; -option java_package = "com.alibaba.graphscope.proto.schema"; - -message VertexTypeStatistics { - uint32 vertex_type_id = 1; - uint64 num_vertices = 2; -} - -message EdgeTypeStatistics { - message EntityPairStatistics { - uint32 src_type_id = 1; - uint32 dst_type_id = 2; - uint64 num_edges = 3; - } - uint32 edge_type_id = 1; - repeated EntityPairStatistics entity_pair_statistics = 2; -} - -message Statistics { - string snapshot_id = 1; - - uint32 num_partitions = 2; - uint64 num_vertices = 3; - uint64 num_edges = 4; - - repeated VertexTypeStatistics vertex_type_statistics = 5; - repeated EdgeTypeStatistics edge_type_statistics = 6; -} diff --git a/flex/engines/graph_db/grin/include/proto/graph.proto b/flex/engines/graph_db/grin/include/proto/graph.proto deleted file mode 100644 index 36473f516892..000000000000 --- a/flex/engines/graph_db/grin/include/proto/graph.proto +++ /dev/null @@ -1,141 +0,0 @@ -syntax = "proto3"; - -package grin; - -enum ListRetrieval { - LR_NA = 0; - LR_ARRAY_LIKE = 1; - LR_ITERATOR = 2; -} - -message TopologyFeature { - bool grin_assume_has_directed_graph = 1; - bool grin_assume_has_undirected_graph = 2; - bool grin_assume_has_multi_edge_graph = 3; - bool grin_with_vertex_data = 4; - bool grin_with_edge_data = 5; - repeated ListRetrieval vertex_list_retrievals = 6; - repeated ListRetrieval edge_list_retrievals = 7; - repeated ListRetrieval adjacent_list_retrievals = 8; -} - -enum GraphPartitionStrategy { - GPS_NA = 0; - GPS_ALL_REPLICATE = 1; - GPS_EDGE_CUT = 2; - GPS_VERTEX_CUT = 3; - GPS_HYBRID_CUT = 4; -} - -enum PropertyDataPartitionStrategy { - PDPS_NA = 0; - PDPS_MASTER_ONLY = 1; - PDPS_REPLICATE_MASTER_MIRROR = 2; - PDPS_SPLIT_MASTER_MIRROR = 3; -} - -message MirrorPartitionListFeature { - bool grin_trait_master_vertex_mirror_partition_list = 1; - bool grin_trait_mirror_vertex_mirror_partition_list = 2; - bool grin_trait_master_edge_mirror_partition_list = 3; - bool grin_trait_mirror_edge_mirror_partition_list = 4; -} - - -message PartitionFeature { - GraphPartitionStrategy graph_partition_strategy = 1; - - bool grin_trait_natural_id_for_partition = 2; - bool grin_enable_vertex_ref = 3; - bool grin_enable_edge_ref = 4; - - PropertyDataPartitionStrategy vertex_data = 5; - PropertyDataPartitionStrategy edge_data = 6; - - MirrorPartitionListFeature mirror_partition_list_feature = 7; - - bool grin_trait_select_master_for_vertex_list = 8; - bool grin_trait_select_partition_for_vertex_list = 9; - bool grin_trait_select_master_for_edge_list = 10; - bool grin_trait_select_partition_for_edge_list = 11; - bool grin_trait_select_master_neighbor_for_adjacent_list = 12; - bool grin_trait_select_neighbor_partition_for_adjacent_list = 13; - - bool grin_trait_fast_vertex_ref = 14; -} - -message VertexPropertyFeature { - bool grin_with_vertex_property = 1; - bool grin_with_vertex_property_name = 2; - bool grin_with_vertex_type_name = 3; - - bool grin_enable_vertex_primary_keys = 4; - - bool grin_trait_natural_id_for_vertex_type = 5; - bool grin_trait_natural_id_for_vertex_property = 6; -} - -message EdgePropertyFeature { - bool grin_with_edge_property = 1; - bool grin_with_edge_property_name = 2; - bool grin_with_edge_type_name = 3; - - bool grin_enable_edge_primary_keys = 4; - - bool grin_trait_natural_id_for_edge_type = 5; - bool grin_trait_natural_id_for_edge_property = 6; -} - -message PropertyFeature { - bool grin_enable_row = 1; - VertexPropertyFeature vertex_property_feature = 2; - EdgePropertyFeature edge_property_feature = 3; - - PropertyDataPartitionStrategy vertex_property = 4; - PropertyDataPartitionStrategy edge_property = 5; - - bool grin_trait_specific_vev_relation = 6; - - bool grin_trait_const_value_ptr = 7; -} - -message IndexFeature { - bool grin_with_vertex_label = 1; - bool grin_with_edge_label = 2; - - bool grin_assume_all_vertex_list_sorted = 3; - - bool grin_enable_vertex_internal_id_index = 4; - - bool grin_enable_vertex_pk_index = 5; - bool grin_enable_edge_pk_index = 6; -} - -message PredicateFeature { - -} - -message StorageFeature { - oneof specific_feature { - TopologyFeature topology_feature = 1; - PartitionFeature partition_feature = 2; - PropertyFeature property_feature = 3; - IndexFeature index_feature = 4; - PredicateFeature predicate_feature = 5; - } -} - -message Statistics { - int32 vertex_count = 1; - int32 edge_count = 2; - int32 partition_count = 3; - int32 vertex_type_count = 4; - int32 edge_type_count = 5; -} - -message Graph { - string uri = 1; - string grin_version = 2; - repeated StorageFeature features = 3; - Statistics statistics = 4; -} diff --git a/flex/engines/graph_db/grin/include/rust/Cargo.toml b/flex/engines/graph_db/grin/include/rust/Cargo.toml deleted file mode 100644 index 75783a76f55c..000000000000 --- a/flex/engines/graph_db/grin/include/rust/Cargo.toml +++ /dev/null @@ -1,75 +0,0 @@ -[package] -name = "grin" -version = "0.1.1" -authors = ["dijie"] - -[dependencies] -cfg-if = "0.1" - -[features] -grin_assume_has_directed_graph = [] -grin_assume_has_undirected_graph = [] -grin_assume_has_multi_edge_graph = [] -grin_with_vertex_data = [] -grin_with_edge_data = [] -grin_enable_vertex_list = [] -grin_enable_vertex_list_array = [] -grin_enable_vertex_list_iterator = [] -grin_enable_edge_list = [] -grin_enable_edge_list_array = [] -grin_enable_edge_list_iterator = [] -grin_enable_adjacent_list = [] -grin_enable_adjacent_list_array = [] -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_enable_edge_ref = [] -grin_assume_all_replicate_partition = [] -grin_assume_edge_cut_partition = [] -grin_assume_edge_cut_follow_src_partition = [] -grin_assume_edge_cut_follow_dst_partition = [] -grin_assume_vertex_cut_partition = [] -grin_assume_master_only_partition_for_vertex_data = [] -grin_assume_replicate_master_mirror_partition_for_vertex_data = [] -grin_assume_master_only_partition_for_edge_data = [] -grin_assume_replicate_master_mirror_partition_for_edge_data = [] -grin_trait_master_vertex_mirror_partition_list = [] -grin_trait_mirror_vertex_mirror_partition_list = [] -grin_trait_master_edge_mirror_partition_list = [] -grin_trait_mirror_edge_mirror_partition_list = [] -grin_trait_select_master_for_vertex_list = [] -grin_trait_select_partition_for_vertex_list = [] -grin_trait_select_master_for_edge_list = [] -grin_trait_select_partition_for_edge_list = [] -grin_trait_select_master_neighbor_for_adjacent_list = [] -grin_trait_select_neighbor_partition_for_adjacent_list = [] -grin_enable_row = [] -grin_trait_const_value_ptr = [] -grin_with_vertex_property = [] -grin_with_vertex_property_name = [] -grin_with_vertex_type_name = [] -grin_trait_natural_id_for_vertex_type = [] -grin_enable_vertex_primary_keys = [] -grin_trait_natural_id_for_vertex_property = [] -grin_with_edge_property = [] -grin_with_edge_property_name = [] -grin_with_edge_type_name = [] -grin_trait_natural_id_for_edge_type = [] -grin_enable_edge_primary_keys = [] -grin_trait_natural_id_for_edge_property = [] -grin_trait_specific_vev_relation = [] -grin_assume_master_only_partition_for_vertex_property = [] -grin_assume_replicate_master_mirror_partition_for_vertex_property = [] -grin_assume_split_master_mirror_partition_for_vertex_property = [] -grin_assume_master_only_partition_for_edge_property = [] -grin_assume_replicate_master_mirror_partition_for_edge_property = [] -grin_assume_split_master_mirror_partition_for_edge_property = [] -grin_with_vertex_label = [] -grin_with_edge_label = [] -grin_assume_all_vertex_list_sorted = [] -grin_enable_vertex_internal_id_index = [] -grin_enable_vertex_pk_index = [] -grin_enable_edge_pk_index = [] -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_trait_natural_id_for_partition', 'grin_enable_vertex_ref', 'grin_trait_fast_vertex_ref', 'grin_assume_edge_cut_partition', 'grin_trait_select_master_for_vertex_list', 'grin_enable_row', 'grin_with_vertex_property', 'grin_with_vertex_property_name', 'grin_with_vertex_type_name', 'grin_trait_natural_id_for_vertex_type', 'grin_trait_natural_id_for_vertex_property', 'grin_with_edge_property', 'grin_with_edge_property_name', 'grin_with_edge_type_name', 'grin_trait_natural_id_for_edge_type', 'grin_trait_natural_id_for_edge_property', 'grin_enable_vertex_primary_keys', 'grin_enable_vertex_internal_id_index', 'grin_enable_vertex_pk_index'] diff --git a/flex/engines/graph_db/grin/include/rust/grin.rs b/flex/engines/graph_db/grin/include/rust/grin.rs deleted file mode 100644 index 2b51035f88a6..000000000000 --- a/flex/engines/graph_db/grin/include/rust/grin.rs +++ /dev/null @@ -1,1693 +0,0 @@ -#[doc = "< incoming"] -pub const GRIN_DIRECTION_IN: GrinDirection = 0; -#[doc = "< outgoing"] -pub const GRIN_DIRECTION_OUT: GrinDirection = 1; -#[doc = "< incoming & outgoing"] -pub const GRIN_DIRECTION_BOTH: GrinDirection = 2; -#[doc = " Enumerates the directions of edges with respect to a certain vertex"] -pub type GrinDirection = u32; -#[doc = "< other unknown types"] -pub const GRIN_DATATYPE_UNDEFINED: GrinDatatype = 0; -#[doc = "< int"] -pub const GRIN_DATATYPE_INT32: GrinDatatype = 1; -#[doc = "< unsigned int"] -pub const GRIN_DATATYPE_UINT32: GrinDatatype = 2; -#[doc = "< long int"] -pub const GRIN_DATATYPE_INT64: GrinDatatype = 3; -#[doc = "< unsigned long int"] -pub const GRIN_DATATYPE_UINT64: GrinDatatype = 4; -#[doc = "< float"] -pub const GRIN_DATATYPE_FLOAT: GrinDatatype = 5; -#[doc = "< double"] -pub const GRIN_DATATYPE_DOUBLE: GrinDatatype = 6; -#[doc = "< string"] -pub const GRIN_DATATYPE_STRING: GrinDatatype = 7; -#[doc = "< date"] -pub const GRIN_DATATYPE_DATE32: GrinDatatype = 8; -#[doc = "< Time32"] -pub const GRIN_DATATYPE_TIME32: GrinDatatype = 9; -#[doc = "< Timestamp"] -pub const GRIN_DATATYPE_TIMESTAMP64: GrinDatatype = 10; -#[doc = " Enumerates the datatype supported in the storage"] -pub type GrinDatatype = u32; -#[doc = "< success"] -pub const GRIN_ERROR_CODE_NO_ERROR: GrinErrorCode = 0; -#[doc = "< unknown error"] -pub const GRIN_ERROR_CODE_UNKNOWN_ERROR: GrinErrorCode = 1; -#[doc = "< invalid value"] -pub const GRIN_ERROR_CODE_INVALID_VALUE: GrinErrorCode = 2; -#[doc = "< unknown datatype"] -pub const GRIN_ERROR_CODE_UNKNOWN_DATATYPE: GrinErrorCode = 3; -#[doc = " Enumerates the error codes of grin"] -pub type GrinErrorCode = u32; -cfg_if::cfg_if! { - if #[cfg(feature = "grin_features_enable_v6d")]{ - pub type GrinGraph = *mut ::std::os::raw::c_void; - pub type GrinVertex = u64; - #[repr(C)] - #[derive(Debug, Copy, Clone, PartialEq)] - pub struct GrinEdge { - pub src: GrinVertex, - pub dst: GrinVertex, - pub dir: GrinDirection, - pub etype: u32, - pub eid: u64, - } - pub type GrinVertexList = *mut ::std::os::raw::c_void; - pub type GrinVertexListIterator = *mut ::std::os::raw::c_void; - #[repr(C)] - #[derive(Debug, Copy, Clone, PartialEq)] - pub struct GrinAdjacentList { - pub begin: *const ::std::os::raw::c_void, - pub end: *const ::std::os::raw::c_void, - pub vid: GrinVertex, - pub dir: GrinDirection, - pub etype: u32, - } - pub type GrinAdjacentListIterator = *mut ::std::os::raw::c_void; - pub type GrinPartitionedGraph = *mut ::std::os::raw::c_void; - pub type GrinPartition = u32; - pub type GrinPartitionList = *mut ::std::os::raw::c_void; - pub type GrinPartitionId = u32; - pub type GrinVertexRef = i64; - pub type GrinVertexType = u32; - pub type GrinVertexTypeList = *mut ::std::os::raw::c_void; - pub type GrinVertexProperty = u64; - pub type GrinVertexPropertyList = *mut ::std::os::raw::c_void; - pub type GrinVertexTypeId = u32; - pub type GrinVertexPropertyId = u32; - pub type GrinEdgeType = u32; - pub type GrinEdgeTypeList = *mut ::std::os::raw::c_void; - pub type GrinVevType = *mut ::std::os::raw::c_void; - pub type GrinVevTypeList = *mut ::std::os::raw::c_void; - pub type GrinEdgeProperty = u64; - pub type GrinEdgePropertyList = *mut ::std::os::raw::c_void; - pub type GrinEdgeTypeId = u32; - pub type GrinEdgePropertyId = u32; - pub type GrinRow = *mut ::std::os::raw::c_void; - pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; - pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX; - pub const GRIN_NULL_EDGE: GrinEdge = GrinEdge{src: u64::MAX, dst: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX, eid: u64::MAX}; - pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); - pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = GrinAdjacentList{begin: std::ptr::null(), end: std::ptr::null(), vid: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX}; - pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX; - pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; - pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1; - pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX; - pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX; - pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; - pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; - pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX; - pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); - pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); - pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX; - pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; - pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; - pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); - pub const GRIN_NULL_SIZE: u32 = u32::MAX; - } else { - pub type GrinGraph = *mut ::std::os::raw::c_void; - pub type GrinVertex = *mut ::std::os::raw::c_void; - pub type GrinEdge = *mut ::std::os::raw::c_void; - pub type GrinVertexData = *mut ::std::os::raw::c_void; - pub type GrinVertexList = *mut ::std::os::raw::c_void; - pub type GrinVertexListIterator = *mut ::std::os::raw::c_void; - pub type GrinAdjacentList = *mut ::std::os::raw::c_void; - pub type GrinAdjacentListIterator = *mut ::std::os::raw::c_void; - pub type GrinEdgeData = *mut ::std::os::raw::c_void; - pub type GrinEdgeList = *mut ::std::os::raw::c_void; - pub type GrinEdgeListIterator = *mut ::std::os::raw::c_void; - pub type GrinPartitionedGraph = *mut ::std::os::raw::c_void; - pub type GrinPartition = *mut ::std::os::raw::c_void; - pub type GrinPartitionList = *mut ::std::os::raw::c_void; - pub type GrinPartitionId = u32; - pub type GrinVertexRef = *mut ::std::os::raw::c_void; - pub type GrinEdgeRef = *mut ::std::os::raw::c_void; - pub type GrinVertexType = *mut ::std::os::raw::c_void; - pub type GrinVertexTypeList = *mut ::std::os::raw::c_void; - pub type GrinVertexProperty = *mut ::std::os::raw::c_void; - pub type GrinVertexPropertyList = *mut ::std::os::raw::c_void; - pub type GrinVertexTypeId = u32; - pub type GrinVertexPropertyId = u32; - pub type GrinEdgeType = *mut ::std::os::raw::c_void; - pub type GrinEdgeTypeList = *mut ::std::os::raw::c_void; - pub type GrinVevType = *mut ::std::os::raw::c_void; - pub type GrinVevTypeList = *mut ::std::os::raw::c_void; - pub type GrinEdgeProperty = *mut ::std::os::raw::c_void; - pub type GrinEdgePropertyList = *mut ::std::os::raw::c_void; - pub type GrinEdgeTypeId = u32; - pub type GrinEdgePropertyId = u32; - pub type GrinRow = *mut ::std::os::raw::c_void; - pub type GrinLabel = *mut ::std::os::raw::c_void; - pub type GrinLabelList = *mut ::std::os::raw::c_void; - pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; - pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_DATA: GrinVertexData = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); - pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut(); - pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_DATA: GrinEdgeData = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITION: GrinPartition = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); - pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; - pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); - pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; - pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; - pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); - pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); - pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); - pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; - pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; - pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); - pub const GRIN_NULL_LABEL: GrinLabel = std::ptr::null_mut(); - pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut(); - pub const GRIN_NULL_SIZE: u32 = u32::MAX; - } -} -extern "C" { - #[cfg(feature = "grin_enable_adjacent_list")] - #[allow(unused)] - pub fn grin_destroy_adjacent_list(arg1: GrinGraph, arg2: GrinAdjacentList); - - #[cfg(feature = "grin_enable_adjacent_list_array")] - #[allow(unused)] - pub fn grin_get_adjacent_list_size(arg1: GrinGraph, arg2: GrinAdjacentList) -> usize; - - #[doc = " @brief Get the neighbor vertex from the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentList The adjacent list.\n @param index The index of the edge to/from the neighbor in the adjacent list.\n @return The neighbor vertex."] - #[cfg(feature = "grin_enable_adjacent_list_array")] - #[allow(unused)] - pub fn grin_get_neighbor_from_adjacent_list( - arg1: GrinGraph, - arg2: GrinAdjacentList, - index: usize, - ) -> GrinVertex; - - #[doc = " @brief Get the edge from the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentList The adjacent list.\n @param index The index of the edge in the adjacent list.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] - #[cfg(feature = "grin_enable_adjacent_list_array")] - #[allow(unused)] - pub fn grin_get_edge_from_adjacent_list( - arg1: GrinGraph, - arg2: GrinAdjacentList, - arg3: usize, - ) -> GrinEdge; - - #[doc = " @brief Get the begin iterator of the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentList The adjacent list.\n @return The begin iterator of the adjacent list."] - #[cfg(feature = "grin_enable_adjacent_list_iterator")] - #[allow(unused)] - pub fn grin_get_adjacent_list_begin( - arg1: GrinGraph, - arg2: GrinAdjacentList, - ) -> GrinAdjacentListIterator; - - #[cfg(feature = "grin_enable_adjacent_list_iterator")] - #[allow(unused)] - pub fn grin_destroy_adjacent_list_iter(arg1: GrinGraph, arg2: GrinAdjacentListIterator); - - #[doc = " @brief Update the iterator to the next of the adjacent list.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator to be updated."] - #[cfg(feature = "grin_enable_adjacent_list_iterator")] - #[allow(unused)] - pub fn grin_get_next_adjacent_list_iter(arg1: GrinGraph, arg2: GrinAdjacentListIterator); - - #[doc = " @brief Check if the adjacent list iterator is at the end.\n Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin``\n if the adjacent list is empty.\n Users should check if the iterator is at the end before using it.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator.\n @return True if the iterator is at the end, otherwise false."] - #[cfg(feature = "grin_enable_adjacent_list_iterator")] - #[allow(unused)] - pub fn grin_is_adjacent_list_end(arg1: GrinGraph, arg2: GrinAdjacentListIterator) -> bool; - - #[doc = " @brief Get the neighbor vertex from the adjacent list iterator.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator.\n @return The neighbor vertex."] - #[cfg(feature = "grin_enable_adjacent_list_iterator")] - #[allow(unused)] - pub fn grin_get_neighbor_from_adjacent_list_iter( - arg1: GrinGraph, - arg2: GrinAdjacentListIterator, - ) -> GrinVertex; - - #[doc = " @brief Get the edge from the adjacent list iterator.\n @param GrinGraph The graph.\n @param GrinAdjacentListIterator The adjacent list iterator.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] - #[cfg(feature = "grin_enable_adjacent_list_iterator")] - #[allow(unused)] - pub fn grin_get_edge_from_adjacent_list_iter( - arg1: GrinGraph, - arg2: GrinAdjacentListIterator, - ) -> GrinEdge; - - #[cfg(feature = "grin_enable_edge_list")] - #[allow(unused)] - pub fn grin_destroy_edge_list(arg1: GrinGraph, arg2: GrinEdgeList); - - #[cfg(feature = "grin_enable_edge_list_array")] - #[allow(unused)] - pub fn grin_get_edge_list_size(arg1: GrinGraph, arg2: GrinEdgeList) -> usize; - - #[cfg(feature = "grin_enable_edge_list_array")] - #[allow(unused)] - pub fn grin_get_edge_from_list( - arg1: GrinGraph, - arg2: GrinEdgeList, - arg3: usize, - ) -> GrinEdge; - - #[cfg(feature = "grin_enable_edge_list_iterator")] - #[allow(unused)] - pub fn grin_get_edge_list_begin( - arg1: GrinGraph, - arg2: GrinEdgeList, - ) -> GrinEdgeListIterator; - - #[cfg(feature = "grin_enable_edge_list_iterator")] - #[allow(unused)] - pub fn grin_destroy_edge_list_iter(arg1: GrinGraph, arg2: GrinEdgeListIterator); - - #[cfg(feature = "grin_enable_edge_list_iterator")] - #[allow(unused)] - pub fn grin_get_next_edge_list_iter(arg1: GrinGraph, arg2: GrinEdgeListIterator); - - #[cfg(feature = "grin_enable_edge_list_iterator")] - #[allow(unused)] - pub fn grin_is_edge_list_end(arg1: GrinGraph, arg2: GrinEdgeListIterator) -> bool; - - #[cfg(feature = "grin_enable_edge_list_iterator")] - #[allow(unused)] - pub fn grin_get_edge_from_iter(arg1: GrinGraph, arg2: GrinEdgeListIterator) -> GrinEdge; - - #[doc = " @brief Get a (non-partitioned) graph from storage\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A graph handle."] - #[allow(unused)] - pub fn grin_get_graph_from_storage(arg1: *const ::std::os::raw::c_char) -> GrinGraph; - - #[allow(unused)] - pub fn grin_destroy_graph(arg1: GrinGraph); - - #[doc = " @brief Check if the graph is directed.\n This API is only available when the storage supports both directed and\n undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH``\n and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined.\n @param GrinGraph The graph.\n @return True if the graph is directed, otherwise false."] - #[cfg(all(feature = "grin_assume_has_directed_graph", feature = "grin_assume_has_undirected_graph"))] - #[allow(unused)] - pub fn grin_is_directed(arg1: GrinGraph) -> bool; - - #[doc = " @brief Check if the graph is a multigraph.\n This API is only available when the storage supports multigraph.\n @param GrinGraph The graph.\n @return True if the graph is a multigraph, otherwise false."] - #[cfg(feature = "grin_assume_has_multi_edge_graph")] - #[allow(unused)] - pub fn grin_is_multigraph(arg1: GrinGraph) -> bool; - - #[allow(unused)] - pub fn grin_destroy_vertex(arg1: GrinGraph, arg2: GrinVertex); - - #[allow(unused)] - pub fn grin_equal_vertex(arg1: GrinGraph, arg2: GrinVertex, arg3: GrinVertex) -> bool; - - #[cfg(feature = "grin_with_vertex_data")] - #[allow(unused)] - pub fn grin_get_vertex_data_datatype(arg1: GrinGraph, arg2: GrinVertex) -> GrinDatatype; - - #[cfg(feature = "grin_with_vertex_data")] - #[allow(unused)] - pub fn grin_get_vertex_data_value( - arg1: GrinGraph, - arg2: GrinVertex, - ) -> *const ::std::os::raw::c_void; - - #[allow(unused)] - pub fn grin_destroy_edge(arg1: GrinGraph, arg2: GrinEdge); - - #[doc = " @brief Get the source vertex of an edge.\n @param GrinGraph The graph.\n @param GrinEdge The edge.\n @return The source vertex of the edge."] - #[allow(unused)] - pub fn grin_get_src_vertex_from_edge(arg1: GrinGraph, arg2: GrinEdge) -> GrinVertex; - - #[doc = " @brief Get the destination vertex of an edge.\n @param GrinGraph The graph.\n @param GrinEdge The edge.\n @return The destination vertex of the edge."] - #[allow(unused)] - pub fn grin_get_dst_vertex_from_edge(arg1: GrinGraph, arg2: GrinEdge) -> GrinVertex; - - #[cfg(feature = "grin_with_edge_data")] - #[allow(unused)] - pub fn grin_get_edge_data_datatype(arg1: GrinGraph, arg2: GrinEdge) -> GrinDatatype; - - #[cfg(feature = "grin_with_edge_data")] - #[allow(unused)] - pub fn grin_get_edge_data_value( - arg1: GrinGraph, - arg2: GrinEdge, - ) -> *const ::std::os::raw::c_void; - - #[cfg(feature = "grin_enable_vertex_list")] - #[allow(unused)] - pub fn grin_destroy_vertex_list(arg1: GrinGraph, arg2: GrinVertexList); - - #[cfg(feature = "grin_enable_vertex_list_array")] - #[allow(unused)] - pub fn grin_get_vertex_list_size(arg1: GrinGraph, arg2: GrinVertexList) -> usize; - - #[doc = " @brief Get the vertex from the vertex list.\n @param GrinGraph The graph.\n @param GrinVertexList The vertex list.\n @param index The index of the vertex in the vertex list.\n @return The vertex."] - #[cfg(feature = "grin_enable_vertex_list_array")] - #[allow(unused)] - pub fn grin_get_vertex_from_list( - arg1: GrinGraph, - arg2: GrinVertexList, - index: usize, - ) -> GrinVertex; - - #[doc = " @brief Get the begin iterator of the vertex list.\n @param GrinGraph The graph.\n @param GrinVertexList The vertex list.\n @return The begin iterator."] - #[cfg(feature = "grin_enable_vertex_list_iterator")] - #[allow(unused)] - pub fn grin_get_vertex_list_begin( - arg1: GrinGraph, - arg2: GrinVertexList, - ) -> GrinVertexListIterator; - - #[cfg(feature = "grin_enable_vertex_list_iterator")] - #[allow(unused)] - pub fn grin_destroy_vertex_list_iter(arg1: GrinGraph, arg2: GrinVertexListIterator); - - #[doc = " @brief Update the iterator to the next of the vertex list.\n @param GrinGraph The graph.\n @param GrinVertexListIterator The iterator to be updated."] - #[cfg(feature = "grin_enable_vertex_list_iterator")] - #[allow(unused)] - pub fn grin_get_next_vertex_list_iter(arg1: GrinGraph, arg2: GrinVertexListIterator); - - #[doc = " @brief Check whether the iterator reaches the end of the vertex list.\n Note that we may get an end iterator when calling ``grin_get_vertex_list_begin``\n if the vertex list is empty.\n Users should check if the iterator is at the end before using it.\n @param GrinGraph The graph.\n @param GrinVertexListIterator The iterator.\n @return True if the iterator reaches the end of the vertex list."] - #[cfg(feature = "grin_enable_vertex_list_iterator")] - #[allow(unused)] - pub fn grin_is_vertex_list_end(arg1: GrinGraph, arg2: GrinVertexListIterator) -> bool; - - #[doc = " @brief Get the vertex from the iterator.\n @param GrinGraph The graph.\n @param GrinVertexListIterator The iterator.\n @return The vertex."] - #[cfg(feature = "grin_enable_vertex_list_iterator")] - #[allow(unused)] - pub fn grin_get_vertex_from_iter( - arg1: GrinGraph, - arg2: GrinVertexListIterator, - ) -> GrinVertex; - - #[doc = " @brief Get a partitioned graph from a storage.\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A partitioned graph handle."] - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_partitioned_graph_from_storage( - uri: *const ::std::os::raw::c_char, - ) -> GrinPartitionedGraph; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_destroy_partitioned_graph(arg1: GrinPartitionedGraph); - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_total_partitions_number(arg1: GrinPartitionedGraph) -> usize; - - #[doc = " @brief Get the local partition list of the partitioned graph.\n For example, a graph may be partitioned into 6 partitions and located in\n 2 machines, then each machine may contain a local partition list of size 3.\n @param GrinPartitionedGraph The partitioned graph.\n @return A partition list of local partitions."] - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_local_partition_list(arg1: GrinPartitionedGraph) -> GrinPartitionList; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_destroy_partition_list(arg1: GrinPartitionedGraph, arg2: GrinPartitionList); - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_create_partition_list(arg1: GrinPartitionedGraph) -> GrinPartitionList; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_insert_partition_to_list( - arg1: GrinPartitionedGraph, - arg2: GrinPartitionList, - arg3: GrinPartition, - ) -> bool; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_partition_list_size( - arg1: GrinPartitionedGraph, - arg2: GrinPartitionList, - ) -> usize; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_partition_from_list( - arg1: GrinPartitionedGraph, - arg2: GrinPartitionList, - arg3: usize, - ) -> GrinPartition; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_equal_partition( - arg1: GrinPartitionedGraph, - arg2: GrinPartition, - arg3: GrinPartition, - ) -> bool; - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_destroy_partition(arg1: GrinPartitionedGraph, arg2: GrinPartition); - - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_partition_info( - arg1: GrinPartitionedGraph, - arg2: GrinPartition, - ) -> *const ::std::os::raw::c_void; - - #[doc = " @brief Get a local graph of the partitioned graph.\n @param GrinPartitionedGraph The partitioned graph.\n @param GrinPartition The partition of the graph.\n @return A local graph."] - #[cfg(feature = "grin_enable_graph_partition")] - #[allow(unused)] - pub fn grin_get_local_graph_by_partition( - arg1: GrinPartitionedGraph, - arg2: GrinPartition, - ) -> GrinGraph; - - #[cfg(feature = "grin_trait_natural_id_for_partition")] - #[allow(unused)] - pub fn grin_get_partition_by_id( - arg1: GrinPartitionedGraph, - arg2: GrinPartitionId, - ) -> GrinPartition; - - #[cfg(feature = "grin_trait_natural_id_for_partition")] - #[allow(unused)] - pub fn grin_get_partition_id( - arg1: GrinPartitionedGraph, - arg2: GrinPartition, - ) -> GrinPartitionId; - - #[doc = " @brief Get the vertex ref of a vertex.\n A vertex ref is a reference for a \"local\" vertex, and the reference can\n be recognized by other partitions.\n To transfer the vertex ref handle between partitions, users should\n first call serialization methods to serialize the vertex ref handle\n into string or int64 based on the storage's features;\n then send the messages to remote partitions and deserialize the string or\n int64 remotely to get the vertex ref handle on the remote partition;\n finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle\n on the remote partition.\n These two vertices should represent the same vertex in the partitioned graph.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @return The vertex ref"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_get_vertex_ref_by_vertex(arg1: GrinGraph, arg2: GrinVertex) -> GrinVertexRef; - - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_destroy_vertex_ref(arg1: GrinGraph, arg2: GrinVertexRef); - - #[doc = " @brief get the local vertex handle from the vertex ref handle\n if the vertex ref handle is not recognized, a null vertex is returned\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref\n @return The vertex handle"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_get_vertex_from_vertex_ref(arg1: GrinGraph, arg2: GrinVertexRef) -> GrinVertex; - - #[doc = " @brief get the master partition of a vertex ref.\n Some storage can still provide the master partition of the vertex ref,\n even if the vertex ref can NOT be recognized locally.\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_get_master_partition_from_vertex_ref( - arg1: GrinGraph, - arg2: GrinVertexRef, - ) -> GrinPartition; - - #[doc = " @brief serialize the vertex ref handle to string\n The returned string should be freed by ``grin_destroy_serialized_vertex_ref``\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_serialize_vertex_ref( - arg1: GrinGraph, - arg2: GrinVertexRef, - ) -> *const ::std::os::raw::c_char; - - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_destroy_serialized_vertex_ref( - arg1: GrinGraph, - arg2: *const ::std::os::raw::c_char, - ); - - #[doc = " @brief deserialize the string to vertex ref handle\n If the string is invalid, a null vertex ref is returned\n @param GrinGraph The graph\n @param msg The string message to be deserialized"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_deserialize_to_vertex_ref( - arg1: GrinGraph, - msg: *const ::std::os::raw::c_char, - ) -> GrinVertexRef; - - #[doc = " @brief check if the vertex is a master vertex\n @param GrinGraph The graph\n @param GrinVertex The vertex"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_is_master_vertex(arg1: GrinGraph, arg2: GrinVertex) -> bool; - - #[doc = " @brief check if the vertex is a mirror vertex\n @param GrinGraph The graph\n @param GrinVertex The vertex"] - #[cfg(feature = "grin_enable_vertex_ref")] - #[allow(unused)] - pub fn grin_is_mirror_vertex(arg1: GrinGraph, arg2: GrinVertex) -> bool; - - #[doc = " @brief serialize the vertex ref handle to int64\n This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref\n can be serialized into int64 instead of string.\n Obviously transferring and serializing int64 is faster than string.\n @param GrinGraph The graph\n @param GrinVertexRef The vertex ref"] - #[cfg(feature = "grin_trait_fast_vertex_ref")] - #[allow(unused)] - pub fn grin_serialize_vertex_ref_as_int64( - arg1: GrinGraph, - arg2: GrinVertexRef, - ) -> i64; - - #[doc = " @brief deserialize the int64 to vertex ref handle\n @param GrinGraph The graph\n @param msg The int64 message to be deserialized"] - #[cfg(feature = "grin_trait_fast_vertex_ref")] - #[allow(unused)] - pub fn grin_deserialize_int64_to_vertex_ref( - arg1: GrinGraph, - msg: i64, - ) -> GrinVertexRef; - - #[cfg(feature = "grin_trait_master_vertex_mirror_partition_list")] - #[allow(unused)] - pub fn grin_get_master_vertex_mirror_partition_list( - arg1: GrinGraph, - arg2: GrinVertex, - ) -> GrinPartitionList; - - #[cfg(feature = "grin_trait_mirror_vertex_mirror_partition_list")] - #[allow(unused)] - pub fn grin_get_mirror_vertex_mirror_partition_list( - arg1: GrinGraph, - arg2: GrinVertex, - ) -> GrinPartitionList; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_get_edge_ref_by_edge(arg1: GrinGraph, arg2: GrinEdge) -> GrinEdgeRef; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_destroy_edge_ref(arg1: GrinGraph, arg2: GrinEdgeRef); - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_get_edge_from_edge_ref(arg1: GrinGraph, arg2: GrinEdgeRef) -> GrinEdge; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_get_master_partition_from_edge_ref( - arg1: GrinGraph, - arg2: GrinEdgeRef, - ) -> GrinPartition; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_serialize_edge_ref( - arg1: GrinGraph, - arg2: GrinEdgeRef, - ) -> *const ::std::os::raw::c_char; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_destroy_serialized_edge_ref(arg1: GrinGraph, arg2: *const ::std::os::raw::c_char); - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_deserialize_to_edge_ref( - arg1: GrinGraph, - arg2: *const ::std::os::raw::c_char, - ) -> GrinEdgeRef; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_is_master_edge(arg1: GrinGraph, arg2: GrinEdge) -> bool; - - #[cfg(feature = "grin_enable_edge_ref")] - #[allow(unused)] - pub fn grin_is_mirror_edge(arg1: GrinGraph, arg2: GrinEdge) -> bool; - - #[cfg(feature = "grin_trait_master_edge_mirror_partition_list")] - #[allow(unused)] - pub fn grin_get_master_edge_mirror_partition_list( - arg1: GrinGraph, - arg2: GrinEdge, - ) -> GrinPartitionList; - - #[cfg(feature = "grin_trait_mirror_edge_mirror_partition_list")] - #[allow(unused)] - pub fn grin_get_mirror_edge_mirror_partition_list( - arg1: GrinGraph, - arg2: GrinEdge, - ) -> GrinPartitionList; - - #[doc = " @brief Get the vertex list of a given type with master vertices only.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex list of master vertices only."] - #[cfg(all(feature = "grin_trait_select_master_for_vertex_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_list_by_type_select_master( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> GrinVertexList; - - #[doc = " @brief Get the vertex list of a given type with mirror vertices only.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex list of mirror vertices only."] - #[cfg(all(feature = "grin_trait_select_master_for_vertex_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_list_by_type_select_mirror( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> GrinVertexList; - - #[cfg(all(feature = "grin_trait_select_partition_for_vertex_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_list_by_type_select_partition( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinPartition, - ) -> GrinVertexList; - - #[cfg(all(feature = "grin_trait_select_master_for_edge_list", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_edge_list_by_type_select_master( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> GrinEdgeList; - - #[cfg(all(feature = "grin_trait_select_master_for_edge_list", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_edge_list_by_type_select_mirror( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> GrinEdgeList; - - #[cfg(all(feature = "grin_trait_select_partition_for_edge_list", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_edge_list_by_type_select_partition( - arg1: GrinGraph, - arg2: GrinEdgeType, - arg3: GrinPartition, - ) -> GrinEdgeList; - - #[cfg(all(feature = "grin_trait_select_master_neighbor_for_adjacent_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_adjacent_list_by_edge_type_select_master_neighbor( - arg1: GrinGraph, - arg2: GrinDirection, - arg3: GrinVertex, - arg4: GrinEdgeType, - ) -> GrinAdjacentList; - - #[cfg(all(feature = "grin_trait_select_master_neighbor_for_adjacent_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_adjacent_list_by_edge_type_select_mirror_neighbor( - arg1: GrinGraph, - arg2: GrinDirection, - arg3: GrinVertex, - arg4: GrinEdgeType, - ) -> GrinAdjacentList; - - #[cfg(all(feature = "grin_trait_select_neighbor_partition_for_adjacent_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_adjacent_list_by_edge_type_select_partition_neighbor( - arg1: GrinGraph, - arg2: GrinDirection, - arg3: GrinVertex, - arg4: GrinEdgeType, - arg5: GrinPartition, - ) -> GrinAdjacentList; - - #[cfg(feature = "grin_trait_specific_vev_relation")] - #[allow(unused)] - pub fn grin_get_one_to_one_vev_types(arg1: GrinGraph) -> GrinVevTypeList; - - #[cfg(feature = "grin_trait_specific_vev_relation")] - #[allow(unused)] - pub fn grin_get_one_to_many_vev_types(arg1: GrinGraph) -> GrinVevTypeList; - - #[cfg(feature = "grin_trait_specific_vev_relation")] - #[allow(unused)] - pub fn grin_get_many_to_one_vev_types(arg1: GrinGraph) -> GrinVevTypeList; - - #[cfg(feature = "grin_trait_specific_vev_relation")] - #[allow(unused)] - pub fn grin_get_many_to_many_vev_types(arg1: GrinGraph) -> GrinVevTypeList; - - #[doc = " @brief Get the vertex types that have primary keys\n In some graph, not every vertex type has primary keys.\n @param GrinGraph The graph\n @return The vertex type list of types that have primary keys"] - #[cfg(feature = "grin_enable_vertex_primary_keys")] - #[allow(unused)] - pub fn grin_get_vertex_types_with_primary_keys(arg1: GrinGraph) -> GrinVertexTypeList; - - #[doc = " @brief Get the primary keys properties of a vertex type\n The primary keys properties are the properties that can be used to identify a vertex.\n They are a subset of the properties of a vertex type.\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @return The primary keys properties list"] - #[cfg(feature = "grin_enable_vertex_primary_keys")] - #[allow(unused)] - pub fn grin_get_primary_keys_by_vertex_type( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> GrinVertexPropertyList; - - #[doc = " @brief Get the primary keys values row of a vertex\n The values in the row are in the same order as the primary keys properties.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @return The primary keys values row"] - #[cfg(feature = "grin_enable_vertex_primary_keys")] - #[allow(unused)] - pub fn grin_get_vertex_primary_keys_row(arg1: GrinGraph, arg2: GrinVertex) -> GrinRow; - - #[cfg(feature = "grin_enable_edge_primary_keys")] - #[allow(unused)] - pub fn grin_get_edge_types_with_primary_keys(arg1: GrinGraph) -> GrinEdgeTypeList; - - #[cfg(feature = "grin_enable_edge_primary_keys")] - #[allow(unused)] - pub fn grin_get_primary_keys_by_edge_type( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> GrinEdgePropertyList; - - #[cfg(feature = "grin_enable_edge_primary_keys")] - #[allow(unused)] - pub fn grin_get_edge_primary_keys_row(arg1: GrinGraph, arg2: GrinEdge) -> GrinRow; - - #[allow(unused)] - pub fn grin_destroy_string_value(arg1: GrinGraph, arg2: *const ::std::os::raw::c_char); - - #[doc = " @brief Get the vertex property name\n @param GrinGraph The graph\n @param GrinVertexType The vertex type that the property belongs to\n @param GrinVertexProperty The vertex property\n @return The property's name as string"] - #[cfg(feature = "grin_with_vertex_property_name")] - #[allow(unused)] - pub fn grin_get_vertex_property_name( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinVertexProperty, - ) -> *const ::std::os::raw::c_char; - - #[doc = " @brief Get the vertex property with a given name under a specific vertex type\n @param GrinGraph The graph\n @param GrinVertexType The specific vertex type\n @param name The name\n @return The vertex property"] - #[cfg(feature = "grin_with_vertex_property_name")] - #[allow(unused)] - pub fn grin_get_vertex_property_by_name( - arg1: GrinGraph, - arg2: GrinVertexType, - name: *const ::std::os::raw::c_char, - ) -> GrinVertexProperty; - - #[doc = " @brief Get properties under all types with a given name.\n For example, vertex type \"person\" and \"company\" both have a property\n called \"name\". When this API is called given \"name\", it will return a list\n of \"name\" properties under both types.\n @param GrinGraph The graph\n @param name The name\n @return The vertex property list of properties with the given name"] - #[cfg(feature = "grin_with_vertex_property_name")] - #[allow(unused)] - pub fn grin_get_vertex_properties_by_name( - arg1: GrinGraph, - name: *const ::std::os::raw::c_char, - ) -> GrinVertexPropertyList; - - #[cfg(feature = "grin_with_edge_property_name")] - #[allow(unused)] - pub fn grin_get_edge_property_name( - arg1: GrinGraph, - arg2: GrinEdgeType, - arg3: GrinEdgeProperty, - ) -> *const ::std::os::raw::c_char; - - #[cfg(feature = "grin_with_edge_property_name")] - #[allow(unused)] - pub fn grin_get_edge_property_by_name( - arg1: GrinGraph, - arg2: GrinEdgeType, - name: *const ::std::os::raw::c_char, - ) -> GrinEdgeProperty; - - #[cfg(feature = "grin_with_edge_property_name")] - #[allow(unused)] - pub fn grin_get_edge_properties_by_name( - arg1: GrinGraph, - name: *const ::std::os::raw::c_char, - ) -> GrinEdgePropertyList; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_equal_vertex_property( - arg1: GrinGraph, - arg2: GrinVertexProperty, - arg3: GrinVertexProperty, - ) -> bool; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_destroy_vertex_property(arg1: GrinGraph, arg2: GrinVertexProperty); - - #[doc = " @brief Get the datatype of the vertex property\n @param GrinGraph The graph\n @param GrinVertexProperty The vertex property\n @return The datatype of the vertex property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_datatype( - arg1: GrinGraph, - arg2: GrinVertexProperty, - ) -> GrinDatatype; - - #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_int32( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> i32; - - #[doc = " @brief Get the value of uint32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_uint32( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> u32; - - #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_int64( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> i64; - - #[doc = " @brief Get the value of uint64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_uint64( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> u64; - - #[doc = " @brief Get the value of float, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype float.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_float( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> f32; - - #[doc = " @brief Get the value of double, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype double.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_double( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> f64; - - #[doc = " @brief Get the value of string, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype string.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_string( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> *const ::std::os::raw::c_char; - - #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype date32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_date32( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> i32; - - #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype time32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_time32( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> i32; - - #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype timestamp64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @param GrinVertexProperty The vertex property\n @return The value of the property"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_value_of_timestamp64( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> i64; - - #[doc = " @brief Get the vertex type that a given vertex property belongs to.\n @param GrinGraph The graph\n @param GrinVertexProperty The vertex property\n @return The vertex type"] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_type_from_property( - arg1: GrinGraph, - arg2: GrinVertexProperty, - ) -> GrinVertexType; - - #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_trait_const_value_ptr"))] - #[allow(unused)] - pub fn grin_get_vertex_property_value( - arg1: GrinGraph, - arg2: GrinVertex, - arg3: GrinVertexProperty, - ) -> *const ::std::os::raw::c_void; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_equal_edge_property( - arg1: GrinGraph, - arg2: GrinEdgeProperty, - arg3: GrinEdgeProperty, - ) -> bool; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_destroy_edge_property(arg1: GrinGraph, arg2: GrinEdgeProperty); - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_datatype( - arg1: GrinGraph, - arg2: GrinEdgeProperty, - ) -> GrinDatatype; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_int32( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> i32; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_uint32( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> u32; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_int64( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> i64; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_uint64( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> u64; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_float( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> f32; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_double( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> f64; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_string( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> *const ::std::os::raw::c_char; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_date32( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> i32; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_time32( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> i32; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_value_of_timestamp64( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> i64; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_type_from_property( - arg1: GrinGraph, - arg2: GrinEdgeProperty, - ) -> GrinEdgeType; - - #[cfg(all(feature = "grin_with_edge_property", feature = "grin_trait_const_value_ptr"))] - #[allow(unused)] - pub fn grin_get_edge_property_value( - arg1: GrinGraph, - arg2: GrinEdge, - arg3: GrinEdgeProperty, - ) -> *const ::std::os::raw::c_void; - - #[doc = " @brief Get the vertex property list of the graph.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @return The vertex property list."] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_list_by_type( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> GrinVertexPropertyList; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_list_size( - arg1: GrinGraph, - arg2: GrinVertexPropertyList, - ) -> usize; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_from_list( - arg1: GrinGraph, - arg2: GrinVertexPropertyList, - arg3: usize, - ) -> GrinVertexProperty; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_create_vertex_property_list(arg1: GrinGraph) -> GrinVertexPropertyList; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_destroy_vertex_property_list(arg1: GrinGraph, arg2: GrinVertexPropertyList); - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_insert_vertex_property_to_list( - arg1: GrinGraph, - arg2: GrinVertexPropertyList, - arg3: GrinVertexProperty, - ) -> bool; - - #[doc = " @brief Get the vertex property handle by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @param GrinVertexPropertyId The vertex property id.\n @return The vertex property handle."] - #[cfg(feature = "grin_trait_natural_id_for_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_by_id( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinVertexPropertyId, - ) -> GrinVertexProperty; - - #[doc = " @brief Get the vertex property's natural id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @param GrinVertexProperty The vertex property handle.\n @return The vertex property id."] - #[cfg(feature = "grin_trait_natural_id_for_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_property_id( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinVertexProperty, - ) -> GrinVertexPropertyId; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_list_by_type( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> GrinEdgePropertyList; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_list_size( - arg1: GrinGraph, - arg2: GrinEdgePropertyList, - ) -> usize; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_from_list( - arg1: GrinGraph, - arg2: GrinEdgePropertyList, - arg3: usize, - ) -> GrinEdgeProperty; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_create_edge_property_list(arg1: GrinGraph) -> GrinEdgePropertyList; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_destroy_edge_property_list(arg1: GrinGraph, arg2: GrinEdgePropertyList); - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_insert_edge_property_to_list( - arg1: GrinGraph, - arg2: GrinEdgePropertyList, - arg3: GrinEdgeProperty, - ) -> bool; - - #[cfg(feature = "grin_trait_natural_id_for_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_by_id( - arg1: GrinGraph, - arg2: GrinEdgeType, - arg3: GrinEdgePropertyId, - ) -> GrinEdgeProperty; - - #[doc = " We must specify the edge type here, because the edge property id is unique only under a specific edge type"] - #[cfg(feature = "grin_trait_natural_id_for_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_property_id( - arg1: GrinGraph, - arg2: GrinEdgeType, - arg3: GrinEdgeProperty, - ) -> GrinEdgePropertyId; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_destroy_row(arg1: GrinGraph, arg2: GrinRow); - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_int32_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> i32; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_uint32_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> u32; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_int64_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> i64; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_uint64_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> u64; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_float_from_row(arg1: GrinGraph, arg2: GrinRow, arg3: usize) -> f32; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_double_from_row(arg1: GrinGraph, arg2: GrinRow, arg3: usize) -> f64; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_string_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> *const ::std::os::raw::c_char; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_date32_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> i32; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_time32_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> i32; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_get_timestamp64_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: usize, - ) -> i64; - - #[doc = " @brief Create a row.\n Row works as carrier of property values in GRIN.\n It is a pure value array, and users can only get the value by the array index.\n That means users should understand the property that each value is\n representing when using the row.\n Currently rows are used in two scenarios:\n 1. Users can create a row of values for primary keys properties,\n and then query the vertex/edge using the row if pk indexing is enabled.\n 2. Users can get the row of values for the entire property list of\n a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``.\n However this API is not recommended if the user only wants to get the\n properties values, in which case, the user can get property values\n one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``."] - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_create_row(arg1: GrinGraph) -> GrinRow; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_int32_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: i32, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_uint32_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: u32, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_int64_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: i64, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_uint64_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: u64, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_float_to_row(arg1: GrinGraph, arg2: GrinRow, arg3: f32) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_double_to_row(arg1: GrinGraph, arg2: GrinRow, arg3: f64) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_string_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: *const ::std::os::raw::c_char, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_date32_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: i32, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_time32_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: i32, - ) -> bool; - - #[cfg(feature = "grin_enable_row")] - #[allow(unused)] - pub fn grin_insert_timestamp64_to_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: i64, - ) -> bool; - - #[cfg(all(feature = "grin_enable_row", feature = "grin_trait_const_value_ptr"))] - #[allow(unused)] - pub fn grin_get_value_from_row( - arg1: GrinGraph, - arg2: GrinRow, - arg3: GrinDatatype, - arg4: usize, - ) -> *const ::std::os::raw::c_void; - - #[doc = " @brief Get row of values for the entire property list of a vertex.\n Later users can get property values from the row using APIs like\n ``grin_get_int32_from_row``.\n However this two-step value getting is not recommended if the user\n only wants to get the value of one property, in which case, the user\n should use APIs like ``grin_get_vertex_property_value_of_int32``.\n @param GrinGraph The graph\n @param GrinVertex The vertex"] - #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_enable_row"))] - #[allow(unused)] - pub fn grin_get_vertex_row(arg1: GrinGraph, arg2: GrinVertex) -> GrinRow; - - #[cfg(all(feature = "grin_with_edge_property", feature = "grin_enable_row"))] - #[allow(unused)] - pub fn grin_get_edge_row(arg1: GrinGraph, arg2: GrinEdge) -> GrinRow; - - #[doc = " @brief Get the vertex number of a given type in the graph.\n This API is only available for property graph.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex number."] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_num_by_type(arg1: GrinGraph, arg2: GrinVertexType) -> usize; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_num_by_type(arg1: GrinGraph, arg2: GrinEdgeType) -> usize; - - #[doc = " @brief Get the vertex list of a given type.\n This API is only available for property graph.\n To get a vertex list chain of all types, using APIs in GRIN extension.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex list of the given type."] - #[cfg(all(feature = "grin_enable_vertex_list", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_list_by_type( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> GrinVertexList; - - #[cfg(all(feature = "grin_enable_edge_list", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_edge_list_by_type(arg1: GrinGraph, arg2: GrinEdgeType) -> GrinEdgeList; - - #[doc = " @brief Get the adjacent list of given direction, vertex and edge type.\n This API is only available for property graph.\n To get a adjacent list chain of all types, using APIs in GRIN extension.\n @param GrinGraph The graph.\n @param GrinDirection The direction of the adjacent list.\n @param GrinVertex The vertex.\n @return The adjacent list."] - #[cfg(all(feature = "grin_enable_adjacent_list", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_adjacent_list_by_edge_type( - arg1: GrinGraph, - arg2: GrinDirection, - arg3: GrinVertex, - arg4: GrinEdgeType, - ) -> GrinAdjacentList; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_equal_vertex_type( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinVertexType, - ) -> bool; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_type(arg1: GrinGraph, arg2: GrinVertex) -> GrinVertexType; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_destroy_vertex_type(arg1: GrinGraph, arg2: GrinVertexType); - - #[doc = " @brief Get the vertex type list of the graph\n This API is only available for property graph.\n It lists all the vertex types in the graph.\n @param GrinGraph The graph.\n @return The vertex type list."] - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_type_list(arg1: GrinGraph) -> GrinVertexTypeList; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_destroy_vertex_type_list(arg1: GrinGraph, arg2: GrinVertexTypeList); - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_create_vertex_type_list(arg1: GrinGraph) -> GrinVertexTypeList; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_insert_vertex_type_to_list( - arg1: GrinGraph, - arg2: GrinVertexTypeList, - arg3: GrinVertexType, - ) -> bool; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_type_list_size(arg1: GrinGraph, arg2: GrinVertexTypeList) -> usize; - - #[cfg(feature = "grin_with_vertex_property")] - #[allow(unused)] - pub fn grin_get_vertex_type_from_list( - arg1: GrinGraph, - arg2: GrinVertexTypeList, - arg3: usize, - ) -> GrinVertexType; - - #[doc = " @brief Get the vertex type name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex type name of string."] - #[cfg(feature = "grin_with_vertex_type_name")] - #[allow(unused)] - pub fn grin_get_vertex_type_name( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> *const ::std::os::raw::c_char; - - #[doc = " @brief Get the vertex type by name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GrinGraph The graph.\n @param name The vertex type name.\n @return The vertex type."] - #[cfg(feature = "grin_with_vertex_type_name")] - #[allow(unused)] - pub fn grin_get_vertex_type_by_name( - arg1: GrinGraph, - name: *const ::std::os::raw::c_char, - ) -> GrinVertexType; - - #[doc = " @brief Get the vertex type id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @return The vertex type id."] - #[cfg(feature = "grin_trait_natural_id_for_vertex_type")] - #[allow(unused)] - pub fn grin_get_vertex_type_id(arg1: GrinGraph, arg2: GrinVertexType) - -> GrinVertexTypeId; - - #[doc = " @brief Get the vertex type by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GrinGraph The graph.\n @param GrinVertexTypeId The vertex type id.\n @return The vertex type."] - #[cfg(feature = "grin_trait_natural_id_for_vertex_type")] - #[allow(unused)] - pub fn grin_get_vertex_type_by_id( - arg1: GrinGraph, - arg2: GrinVertexTypeId, - ) -> GrinVertexType; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_equal_edge_type( - arg1: GrinGraph, - arg2: GrinEdgeType, - arg3: GrinEdgeType, - ) -> bool; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_type(arg1: GrinGraph, arg2: GrinEdge) -> GrinEdgeType; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_destroy_edge_type(arg1: GrinGraph, arg2: GrinEdgeType); - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_type_list(arg1: GrinGraph) -> GrinEdgeTypeList; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_destroy_edge_type_list(arg1: GrinGraph, arg2: GrinEdgeTypeList); - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_create_edge_type_list(arg1: GrinGraph) -> GrinEdgeTypeList; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_insert_edge_type_to_list( - arg1: GrinGraph, - arg2: GrinEdgeTypeList, - arg3: GrinEdgeType, - ) -> bool; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_type_list_size(arg1: GrinGraph, arg2: GrinEdgeTypeList) -> usize; - - #[cfg(feature = "grin_with_edge_property")] - #[allow(unused)] - pub fn grin_get_edge_type_from_list( - arg1: GrinGraph, - arg2: GrinEdgeTypeList, - arg3: usize, - ) -> GrinEdgeType; - - #[cfg(feature = "grin_with_edge_type_name")] - #[allow(unused)] - pub fn grin_get_edge_type_name( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> *const ::std::os::raw::c_char; - - #[cfg(feature = "grin_with_edge_type_name")] - #[allow(unused)] - pub fn grin_get_edge_type_by_name( - arg1: GrinGraph, - arg2: *const ::std::os::raw::c_char, - ) -> GrinEdgeType; - - #[cfg(feature = "grin_trait_natural_id_for_edge_type")] - #[allow(unused)] - pub fn grin_get_edge_type_id(arg1: GrinGraph, arg2: GrinEdgeType) -> GrinEdgeTypeId; - - #[cfg(feature = "grin_trait_natural_id_for_edge_type")] - #[allow(unused)] - pub fn grin_get_edge_type_by_id(arg1: GrinGraph, arg2: GrinEdgeTypeId) -> GrinEdgeType; - - #[doc = " @brief Get source vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GrinGraph The graph.\n @param GrinEdgeType The edge type.\n @return The vertex type list of source."] - #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_src_types_by_edge_type( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> GrinVertexTypeList; - - #[doc = " @brief Get destination vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GrinGraph The graph.\n @param GrinEdgeType The edge type.\n @return The vertex type list of destination."] - #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_dst_types_by_edge_type( - arg1: GrinGraph, - arg2: GrinEdgeType, - ) -> GrinVertexTypeList; - - #[doc = " @brief Get edge types related to a pair of vertex types.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n @param GrinGraph The graph.\n @param GrinVertexType The source vertex type.\n @param GrinVertexType The destination vertex type.\n @return The related edge type list."] - #[cfg(all(feature = "grin_with_vertex_property", feature = "grin_with_edge_property"))] - #[allow(unused)] - pub fn grin_get_edge_types_by_vertex_type_pair( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinVertexType, - ) -> GrinEdgeTypeList; - - #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] - #[allow(unused)] - pub fn grin_get_label_by_name( - arg1: GrinGraph, - arg2: *const ::std::os::raw::c_char, - ) -> GrinLabel; - - #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] - #[allow(unused)] - pub fn grin_destroy_label(arg1: GrinGraph, arg2: GrinLabel); - - #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] - #[allow(unused)] - pub fn grin_get_label_name(arg1: GrinGraph, arg2: GrinLabel) - -> *const ::std::os::raw::c_char; - - #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] - #[allow(unused)] - pub fn grin_destroy_label_list(arg1: GrinGraph, arg2: GrinLabelList); - - #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] - #[allow(unused)] - pub fn grin_get_label_list_size(arg1: GrinGraph, arg2: GrinLabelList) -> usize; - - #[cfg(any(feature = "grin_with_vertex_label", feature = "grin_with_edge_label"))] - #[allow(unused)] - pub fn grin_get_label_from_list( - arg1: GrinGraph, - arg2: GrinLabelList, - arg3: usize, - ) -> GrinLabel; - - #[doc = " @brief assign a label to a vertex\n @param GrinGraph the graph\n @param GrinLabel the label\n @param GrinVertex the vertex\n @return whether succeed"] - #[cfg(feature = "grin_with_vertex_label")] - #[allow(unused)] - pub fn grin_assign_label_to_vertex( - arg1: GrinGraph, - arg2: GrinLabel, - arg3: GrinVertex, - ) -> bool; - - #[doc = " @brief get the label list of a vertex\n @param GrinGraph the graph\n @param GrinVertex the vertex"] - #[cfg(feature = "grin_with_vertex_label")] - #[allow(unused)] - pub fn grin_get_vertex_label_list(arg1: GrinGraph, arg2: GrinVertex) -> GrinLabelList; - - #[doc = " @brief get the vertex list by label\n @param GrinGraph the graph\n @param GrinLabel the label"] - #[cfg(feature = "grin_with_vertex_label")] - #[allow(unused)] - pub fn grin_get_vertex_list_by_label(arg1: GrinGraph, arg2: GrinLabel) -> GrinVertexList; - - #[doc = " @brief filtering an existing vertex list by label\n @param GrinVertexList the existing vertex list\n @param GrinLabel the label"] - #[cfg(feature = "grin_with_vertex_label")] - #[allow(unused)] - pub fn grin_select_label_for_vertex_list( - arg1: GrinGraph, - arg2: GrinLabel, - arg3: GrinVertexList, - ) -> GrinVertexList; - - #[doc = " @brief assign a label to a edge\n @param GrinGraph the graph\n @param GrinLabel the label\n @param GrinEdge the edge\n @return whether succeed"] - #[cfg(feature = "grin_with_edge_label")] - #[allow(unused)] - pub fn grin_assign_label_to_edge(arg1: GrinGraph, arg2: GrinLabel, arg3: GrinEdge) -> bool; - - #[doc = " @brief get the label list of a edge\n @param GrinGraph the graph\n @param GrinEdge the edge"] - #[cfg(feature = "grin_with_edge_label")] - #[allow(unused)] - pub fn grin_get_edge_label_list(arg1: GrinGraph, arg2: GrinEdge) -> GrinLabelList; - - #[doc = " @brief get the edge list by label\n @param GrinGraph the graph\n @param GrinLabel the label"] - #[cfg(feature = "grin_with_edge_label")] - #[allow(unused)] - pub fn grin_get_edge_list_by_label(arg1: GrinGraph, arg2: GrinLabel) -> GrinEdgeList; - - #[doc = " @brief filtering an existing edge list by label\n @param GrinEdgeList the existing edge list\n @param GrinLabel the label"] - #[cfg(feature = "grin_with_edge_label")] - #[allow(unused)] - pub fn grin_select_label_for_edge_list( - arg1: GrinGraph, - arg2: GrinLabel, - arg3: GrinEdgeList, - ) -> GrinEdgeList; - - #[cfg(feature = "grin_assume_all_vertex_list_sorted")] - #[allow(unused)] - pub fn grin_smaller_vertex(arg1: GrinGraph, arg2: GrinVertex, arg3: GrinVertex) -> bool; - - #[doc = " @brief Get the position of a vertex in a sorted list\n caller must guarantee the input vertex list is sorted to get the correct result\n @param GrinGraph The graph\n @param GrinVertexList The sorted vertex list\n @param GrinVertex The vertex to find\n @return The position of the vertex"] - #[cfg(all(feature = "grin_assume_all_vertex_list_sorted", feature = "grin_enable_vertex_list_array"))] - #[allow(unused)] - pub fn grin_get_position_of_vertex_from_sorted_list( - arg1: GrinGraph, - arg2: GrinVertexList, - arg3: GrinVertex, - ) -> usize; - - #[doc = " @brief Get the int64 internal id of a vertex\n @param GrinGraph The graph\n @param GrinVertex The vertex\n @return The int64 internal id of the vertex"] - #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_internal_id_by_type( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinVertex, - ) -> i64; - - #[doc = " @brief Get the vertex by internal id under type\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @param id The internal id of the vertex under type\n @return The vertex"] - #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_by_internal_id_by_type( - arg1: GrinGraph, - arg2: GrinVertexType, - id: i64, - ) -> GrinVertex; - - #[doc = " @brief Get the upper bound of internal id under type.\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @return The upper bound of internal id under type"] - #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_internal_id_upper_bound_by_type( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> i64; - - #[doc = " @brief Get the lower bound internal id under type.\n @param GrinGraph The graph\n @param GrinVertexType The vertex type\n @return The lower bound internal id under type"] - #[cfg(all(feature = "grin_enable_vertex_internal_id_index", feature = "grin_with_vertex_property"))] - #[allow(unused)] - pub fn grin_get_vertex_internal_id_lower_bound_by_type( - arg1: GrinGraph, - arg2: GrinVertexType, - ) -> i64; - - #[doc = " @brief Get the vertex by primary keys row.\n The values in the row must be in the same order as the primary keys\n properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``.\n @param GrinGraph The graph.\n @param GrinVertexType The vertex type.\n @param GrinRow The values row of primary keys properties.\n @return The vertex."] - #[cfg(all(feature = "grin_enable_vertex_pk_index", feature = "grin_enable_vertex_primary_keys"))] - #[allow(unused)] - pub fn grin_get_vertex_by_primary_keys_row( - arg1: GrinGraph, - arg2: GrinVertexType, - arg3: GrinRow, - ) -> GrinVertex; - - #[cfg(all(feature = "grin_enable_edge_pk_index", feature = "grin_enable_edge_primary_keys"))] - #[allow(unused)] - pub fn grin_get_edge_by_primary_keys_row( - arg1: GrinGraph, - arg2: GrinEdgeType, - arg3: GrinRow, - ) -> GrinEdge; - - pub static mut grin_error_code: GrinErrorCode; - - #[doc = " @brief Get the last error code.\n The error code is thread local.\n Currently users only need to check the error code when using\n getting-value APIs whose return has no predefined invalid value."] - #[allow(unused)] - pub fn grin_get_last_error_code() -> GrinErrorCode; - - #[doc = " @brief Get the static feature prototype message of the storage.\n This proto describes the features of the storage, such as whether\n it supports property graph or partitioned graph.\n @return The serialized proto message."] - #[allow(unused)] - pub fn grin_get_static_storage_feature_msg() -> *const ::std::os::raw::c_char; -} diff --git a/flex/engines/graph_db/grin/include/rust/grin_all.h b/flex/engines/graph_db/grin/include/rust/grin_all.h deleted file mode 100644 index 234b2eb7c7f1..000000000000 --- a/flex/engines/graph_db/grin/include/rust/grin_all.h +++ /dev/null @@ -1,83 +0,0 @@ -#define GRIN_FEATURES_ENABLE_ALL -#define GRIN_RUST_CODEGEN - -#include "template/predefine.h" -#include "topology/adjacentlist.h" -#include "topology/edgelist.h" -#include "topology/structure.h" -#include "topology/vertexlist.h" -#include "partition/partition.h" -#include "partition/reference.h" -#include "partition/topology.h" -#include "property/partition.h" -#include "property/primarykey.h" -#include "property/property.h" -#include "property/propertylist.h" -#include "property/row.h" -#include "property/topology.h" -#include "property/type.h" -#include "index/label.h" -#include "index/order.h" -#include "index/internal_id.h" -#include "index/pk.h" -#include "common/error.h" -#include "common/message.h" - -#ifdef GRIN_RUST_CODEGEN -/// GRIN_FEATURES_ENABLE_ALL -/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; -/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_DATA: GrinVertexData = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_DATA: GrinEdgeData = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_LIST: GrinEdgeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_LIST_ITERATOR: GrinEdgeListIterator = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_LABEL: GrinLabel = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX; -int __rust_keep_grin_null; -#endif - -/// GRIN_V6D -/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; -/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE: GrinEdge = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_LIST: *mut ::std::os::raw::c_void = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_LIST_ITERATOR: *mut ::std::os::raw::c_void = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX; -/// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_NATURAL_ID: u32 = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX; -///int __rust_keep_grin_null_v6d; \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/rust/grin_all.rs b/flex/engines/graph_db/grin/include/rust/grin_all.rs deleted file mode 100644 index 0b06ea2694c3..000000000000 --- a/flex/engines/graph_db/grin/include/rust/grin_all.rs +++ /dev/null @@ -1,1368 +0,0 @@ -/* automatically generated by rust-bindgen 0.64.0 */ - -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const __bool_true_false_are_defined: u32 = 1; -pub type wchar_t = ::std::os::raw::c_int; -pub type max_align_t = u128; -#[doc = "< incoming"] -pub const GRIN_DIRECTION_IN: GRIN_DIRECTION = 0; -#[doc = "< outgoing"] -pub const GRIN_DIRECTION_OUT: GRIN_DIRECTION = 1; -#[doc = "< incoming & outgoing"] -pub const GRIN_DIRECTION_BOTH: GRIN_DIRECTION = 2; -#[doc = " Enumerates the directions of edges with respect to a certain vertex"] -pub type GRIN_DIRECTION = ::std::os::raw::c_uint; -#[doc = "< other unknown types"] -pub const GRIN_DATATYPE_Undefined: GRIN_DATATYPE = 0; -#[doc = "< int"] -pub const GRIN_DATATYPE_Int32: GRIN_DATATYPE = 1; -#[doc = "< unsigned int"] -pub const GRIN_DATATYPE_UInt32: GRIN_DATATYPE = 2; -#[doc = "< long int"] -pub const GRIN_DATATYPE_Int64: GRIN_DATATYPE = 3; -#[doc = "< unsigned long int"] -pub const GRIN_DATATYPE_UInt64: GRIN_DATATYPE = 4; -#[doc = "< float"] -pub const GRIN_DATATYPE_Float: GRIN_DATATYPE = 5; -#[doc = "< double"] -pub const GRIN_DATATYPE_Double: GRIN_DATATYPE = 6; -#[doc = "< string"] -pub const GRIN_DATATYPE_String: GRIN_DATATYPE = 7; -#[doc = "< date"] -pub const GRIN_DATATYPE_Date32: GRIN_DATATYPE = 8; -#[doc = "< Time32"] -pub const GRIN_DATATYPE_Time32: GRIN_DATATYPE = 9; -#[doc = "< Timestamp"] -pub const GRIN_DATATYPE_Timestamp64: GRIN_DATATYPE = 10; -#[doc = " Enumerates the datatype supported in the storage"] -pub type GRIN_DATATYPE = ::std::os::raw::c_uint; -#[doc = "< success"] -pub const GRIN_ERROR_CODE_NO_ERROR: GRIN_ERROR_CODE = 0; -#[doc = "< unknown error"] -pub const GRIN_ERROR_CODE_UNKNOWN_ERROR: GRIN_ERROR_CODE = 1; -#[doc = "< invalid value"] -pub const GRIN_ERROR_CODE_INVALID_VALUE: GRIN_ERROR_CODE = 2; -#[doc = "< unknown datatype"] -pub const GRIN_ERROR_CODE_UNKNOWN_DATATYPE: GRIN_ERROR_CODE = 3; -#[doc = " Enumerates the error codes of grin"] -pub type GRIN_ERROR_CODE = ::std::os::raw::c_uint; -pub type GRIN_GRAPH = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_DATA = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void; -pub type GRIN_ADJACENT_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_DATA = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_LIST_ITERATOR = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITION = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint; -pub type GRIN_VERTEX_REF = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_REF = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_TYPE = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_PROPERTY = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint; -pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint; -pub type GRIN_EDGE_TYPE = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VEV_TYPE = *mut ::std::os::raw::c_void; -pub type GRIN_VEV_TYPE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_PROPERTY = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint; -pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint; -pub type GRIN_ROW = *mut ::std::os::raw::c_void; -pub type GRIN_LABEL = *mut ::std::os::raw::c_void; -pub type GRIN_LABEL_LIST = *mut ::std::os::raw::c_void; -extern "C" { - pub fn grin_destroy_adjacent_list(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST); -} -extern "C" { - pub fn grin_get_adjacent_list_size(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST) -> usize; -} -extern "C" { - #[doc = " @brief Get the neighbor vertex from the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST The adjacent list.\n @param index The index of the edge to/from the neighbor in the adjacent list.\n @return The neighbor vertex."] - pub fn grin_get_neighbor_from_adjacent_list( - arg1: GRIN_GRAPH, - arg2: GRIN_ADJACENT_LIST, - index: usize, - ) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief Get the edge from the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST The adjacent list.\n @param index The index of the edge in the adjacent list.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] - pub fn grin_get_edge_from_adjacent_list( - arg1: GRIN_GRAPH, - arg2: GRIN_ADJACENT_LIST, - arg3: usize, - ) -> GRIN_EDGE; -} -extern "C" { - #[doc = " @brief Get the begin iterator of the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST The adjacent list.\n @return The begin iterator of the adjacent list."] - pub fn grin_get_adjacent_list_begin( - arg1: GRIN_GRAPH, - arg2: GRIN_ADJACENT_LIST, - ) -> GRIN_ADJACENT_LIST_ITERATOR; -} -extern "C" { - pub fn grin_destroy_adjacent_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST_ITERATOR); -} -extern "C" { - #[doc = " @brief Update the iterator to the next of the adjacent list.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator to be updated."] - pub fn grin_get_next_adjacent_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST_ITERATOR); -} -extern "C" { - #[doc = " @brief Check if the adjacent list iterator is at the end.\n Note that we may get an end iterator when calling ``grin_get_adjacent_list_begin``\n if the adjacent list is empty.\n Users should check if the iterator is at the end before using it.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.\n @return True if the iterator is at the end, otherwise false."] - pub fn grin_is_adjacent_list_end(arg1: GRIN_GRAPH, arg2: GRIN_ADJACENT_LIST_ITERATOR) -> bool; -} -extern "C" { - #[doc = " @brief Get the neighbor vertex from the adjacent list iterator.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.\n @return The neighbor vertex."] - pub fn grin_get_neighbor_from_adjacent_list_iter( - arg1: GRIN_GRAPH, - arg2: GRIN_ADJACENT_LIST_ITERATOR, - ) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief Get the edge from the adjacent list iterator.\n @param GRIN_GRAPH The graph.\n @param GRIN_ADJACENT_LIST_ITERATOR The adjacent list iterator.\n @return The edge. Note that when the direction is OUT, the destination vertex\n of the edge is the neighbor vertex. While the direction is IN, the source\n vertex of the edge is the neighbor vertex."] - pub fn grin_get_edge_from_adjacent_list_iter( - arg1: GRIN_GRAPH, - arg2: GRIN_ADJACENT_LIST_ITERATOR, - ) -> GRIN_EDGE; -} -extern "C" { - pub fn grin_destroy_edge_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST); -} -extern "C" { - pub fn grin_get_edge_list_size(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST) -> usize; -} -extern "C" { - pub fn grin_get_edge_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_LIST, - arg3: usize, - ) -> GRIN_EDGE; -} -extern "C" { - pub fn grin_get_edge_list_begin( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_LIST, - ) -> GRIN_EDGE_LIST_ITERATOR; -} -extern "C" { - pub fn grin_destroy_edge_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR); -} -extern "C" { - pub fn grin_get_next_edge_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR); -} -extern "C" { - pub fn grin_is_edge_list_end(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR) -> bool; -} -extern "C" { - pub fn grin_get_edge_from_iter(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_LIST_ITERATOR) -> GRIN_EDGE; -} -extern "C" { - #[doc = " @brief Get a (non-partitioned) graph from storage\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A graph handle."] - pub fn grin_get_graph_from_storage(arg1: *const ::std::os::raw::c_char) -> GRIN_GRAPH; -} -extern "C" { - pub fn grin_destroy_graph(arg1: GRIN_GRAPH); -} -extern "C" { - #[doc = " @brief Check if the graph is directed.\n This API is only available when the storage supports both directed and\n undirected graph. Otherwise, check which of ``GRIN_ASSUME_HAS_DIRECTED_GRAPH``\n and ``GRIN_ASSUME_HAS_UNDIRECTED_GRAPH`` is defined.\n @param GRIN_GRAPH The graph.\n @return True if the graph is directed, otherwise false."] - pub fn grin_is_directed(arg1: GRIN_GRAPH) -> bool; -} -extern "C" { - #[doc = " @brief Check if the graph is a multigraph.\n This API is only available when the storage supports multigraph.\n @param GRIN_GRAPH The graph.\n @return True if the graph is a multigraph, otherwise false."] - pub fn grin_is_multigraph(arg1: GRIN_GRAPH) -> bool; -} -extern "C" { - pub fn grin_destroy_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX); -} -extern "C" { - pub fn grin_equal_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX, arg3: GRIN_VERTEX) -> bool; -} -extern "C" { - pub fn grin_get_vertex_data_datatype(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_DATATYPE; -} -extern "C" { - pub fn grin_get_vertex_data_value( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - ) -> *const ::std::os::raw::c_void; -} -extern "C" { - pub fn grin_destroy_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE); -} -extern "C" { - #[doc = " @brief Get the source vertex of an edge.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE The edge.\n @return The source vertex of the edge."] - pub fn grin_get_src_vertex_from_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief Get the destination vertex of an edge.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE The edge.\n @return The destination vertex of the edge."] - pub fn grin_get_dst_vertex_from_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_VERTEX; -} -extern "C" { - pub fn grin_get_edge_data_datatype(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_DATATYPE; -} -extern "C" { - pub fn grin_get_edge_data_value( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - ) -> *const ::std::os::raw::c_void; -} -extern "C" { - pub fn grin_destroy_vertex_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST); -} -extern "C" { - pub fn grin_get_vertex_list_size(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST) -> usize; -} -extern "C" { - #[doc = " @brief Get the vertex from the vertex list.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST The vertex list.\n @param index The index of the vertex in the vertex list.\n @return The vertex."] - pub fn grin_get_vertex_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_LIST, - index: usize, - ) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief Get the begin iterator of the vertex list.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST The vertex list.\n @return The begin iterator."] - pub fn grin_get_vertex_list_begin( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_LIST, - ) -> GRIN_VERTEX_LIST_ITERATOR; -} -extern "C" { - pub fn grin_destroy_vertex_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST_ITERATOR); -} -extern "C" { - #[doc = " @brief Update the iterator to the next of the vertex list.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST_ITERATOR The iterator to be updated."] - pub fn grin_get_next_vertex_list_iter(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST_ITERATOR); -} -extern "C" { - #[doc = " @brief Check whether the iterator reaches the end of the vertex list.\n Note that we may get an end iterator when calling ``grin_get_vertex_list_begin``\n if the vertex list is empty.\n Users should check if the iterator is at the end before using it.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST_ITERATOR The iterator.\n @return True if the iterator reaches the end of the vertex list."] - pub fn grin_is_vertex_list_end(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_LIST_ITERATOR) -> bool; -} -extern "C" { - #[doc = " @brief Get the vertex from the iterator.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_LIST_ITERATOR The iterator.\n @return The vertex."] - pub fn grin_get_vertex_from_iter( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_LIST_ITERATOR, - ) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief Get a partitioned graph from a storage.\n @param uri The URI of the graph.\n Current URI for supported storage includes:\n 1. gart://{etcd_endpoint}?prefix={etcd_prefix}&version={version}\n 2. graphar://{yaml_path}?partition_num={partition_num}&strategy={strategy}\n 3. v6d://{object_id}?ipc_socket={ipc_socket} where ipc_socket is optional.\n @return A partitioned graph handle."] - pub fn grin_get_partitioned_graph_from_storage( - uri: *const ::std::os::raw::c_char, - ) -> GRIN_PARTITIONED_GRAPH; -} -extern "C" { - pub fn grin_destroy_partitioned_graph(arg1: GRIN_PARTITIONED_GRAPH); -} -extern "C" { - pub fn grin_get_total_partitions_number(arg1: GRIN_PARTITIONED_GRAPH) -> usize; -} -extern "C" { - #[doc = " @brief Get the local partition list of the partitioned graph.\n For example, a graph may be partitioned into 6 partitions and located in\n 2 machines, then each machine may contain a local partition list of size 3.\n @param GRIN_PARTITIONED_GRAPH The partitioned graph.\n @return A partition list of local partitions."] - pub fn grin_get_local_partition_list(arg1: GRIN_PARTITIONED_GRAPH) -> GRIN_PARTITION_LIST; -} -extern "C" { - pub fn grin_destroy_partition_list(arg1: GRIN_PARTITIONED_GRAPH, arg2: GRIN_PARTITION_LIST); -} -extern "C" { - pub fn grin_create_partition_list(arg1: GRIN_PARTITIONED_GRAPH) -> GRIN_PARTITION_LIST; -} -extern "C" { - pub fn grin_insert_partition_to_list( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION_LIST, - arg3: GRIN_PARTITION, - ) -> bool; -} -extern "C" { - pub fn grin_get_partition_list_size( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION_LIST, - ) -> usize; -} -extern "C" { - pub fn grin_get_partition_from_list( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION_LIST, - arg3: usize, - ) -> GRIN_PARTITION; -} -extern "C" { - pub fn grin_equal_partition( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION, - arg3: GRIN_PARTITION, - ) -> bool; -} -extern "C" { - pub fn grin_destroy_partition(arg1: GRIN_PARTITIONED_GRAPH, arg2: GRIN_PARTITION); -} -extern "C" { - pub fn grin_get_partition_info( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION, - ) -> *const ::std::os::raw::c_void; -} -extern "C" { - #[doc = " @brief Get a local graph of the partitioned graph.\n @param GRIN_PARTITIONED_GRAPH The partitioned graph.\n @param GRIN_PARTITION The partition of the graph.\n @return A local graph."] - pub fn grin_get_local_graph_by_partition( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION, - ) -> GRIN_GRAPH; -} -extern "C" { - pub fn grin_get_partition_by_id( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION_ID, - ) -> GRIN_PARTITION; -} -extern "C" { - pub fn grin_get_partition_id( - arg1: GRIN_PARTITIONED_GRAPH, - arg2: GRIN_PARTITION, - ) -> GRIN_PARTITION_ID; -} -extern "C" { - #[doc = " @brief Get the vertex ref of a vertex.\n A vertex ref is a reference for a \"local\" vertex, and the reference can\n be recognized by other partitions.\n To transfer the vertex ref handle between partitions, users should\n first call serialization methods to serialize the vertex ref handle\n into string or int64 based on the storage's features;\n then send the messages to remote partitions and deserialize the string or\n int64 remotely to get the vertex ref handle on the remote partition;\n finally use ``grin_get_vertex_by_vertex_ref`` to get the vertex handle\n on the remote partition.\n These two vertices should represent the same vertex in the partitioned graph.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @return The vertex ref"] - pub fn grin_get_vertex_ref_by_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_VERTEX_REF; -} -extern "C" { - pub fn grin_destroy_vertex_ref(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_REF); -} -extern "C" { - #[doc = " @brief get the local vertex handle from the vertex ref handle\n if the vertex ref handle is not recognized, a null vertex is returned\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref\n @return The vertex handle"] - pub fn grin_get_vertex_from_vertex_ref(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_REF) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief get the master partition of a vertex ref.\n Some storage can still provide the master partition of the vertex ref,\n even if the vertex ref can NOT be recognized locally.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref"] - pub fn grin_get_master_partition_from_vertex_ref( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_REF, - ) -> GRIN_PARTITION; -} -extern "C" { - #[doc = " @brief serialize the vertex ref handle to string\n The returned string should be freed by ``grin_destroy_serialized_vertex_ref``\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref"] - pub fn grin_serialize_vertex_ref( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_REF, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_destroy_serialized_vertex_ref( - arg1: GRIN_GRAPH, - arg2: *const ::std::os::raw::c_char, - ); -} -extern "C" { - #[doc = " @brief deserialize the string to vertex ref handle\n If the string is invalid, a null vertex ref is returned\n @param GRIN_GRAPH The graph\n @param msg The string message to be deserialized"] - pub fn grin_deserialize_to_vertex_ref( - arg1: GRIN_GRAPH, - msg: *const ::std::os::raw::c_char, - ) -> GRIN_VERTEX_REF; -} -extern "C" { - #[doc = " @brief check if the vertex is a master vertex\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex"] - pub fn grin_is_master_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> bool; -} -extern "C" { - #[doc = " @brief check if the vertex is a mirror vertex\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex"] - pub fn grin_is_mirror_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> bool; -} -extern "C" { - #[doc = " @brief serialize the vertex ref handle to int64\n This API is enabled by ``GRIN_TRAIT_FAST_VERTEX_REF``, meaning the vertex ref\n can be serialized into int64 instead of string.\n Obviously transferring and serializing int64 is faster than string.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_REF The vertex ref"] - pub fn grin_serialize_vertex_ref_as_int64( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_REF, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief deserialize the int64 to vertex ref handle\n @param GRIN_GRAPH The graph\n @param msg The int64 message to be deserialized"] - pub fn grin_deserialize_int64_to_vertex_ref( - arg1: GRIN_GRAPH, - msg: ::std::os::raw::c_longlong, - ) -> GRIN_VERTEX_REF; -} -extern "C" { - pub fn grin_get_master_vertex_mirror_partition_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - ) -> GRIN_PARTITION_LIST; -} -extern "C" { - pub fn grin_get_mirror_vertex_mirror_partition_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - ) -> GRIN_PARTITION_LIST; -} -extern "C" { - pub fn grin_get_edge_ref_by_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_EDGE_REF; -} -extern "C" { - pub fn grin_destroy_edge_ref(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_REF); -} -extern "C" { - pub fn grin_get_edge_from_edge_ref(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_REF) -> GRIN_EDGE; -} -extern "C" { - pub fn grin_get_master_partition_from_edge_ref( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_REF, - ) -> GRIN_PARTITION; -} -extern "C" { - pub fn grin_serialize_edge_ref( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_REF, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_destroy_serialized_edge_ref(arg1: GRIN_GRAPH, arg2: *const ::std::os::raw::c_char); -} -extern "C" { - pub fn grin_deserialize_to_edge_ref( - arg1: GRIN_GRAPH, - arg2: *const ::std::os::raw::c_char, - ) -> GRIN_EDGE_REF; -} -extern "C" { - pub fn grin_is_master_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> bool; -} -extern "C" { - pub fn grin_is_mirror_edge(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> bool; -} -extern "C" { - pub fn grin_get_master_edge_mirror_partition_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - ) -> GRIN_PARTITION_LIST; -} -extern "C" { - pub fn grin_get_mirror_edge_mirror_partition_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - ) -> GRIN_PARTITION_LIST; -} -extern "C" { - #[doc = " @brief Get the vertex list of a given type with master vertices only.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex list of master vertices only."] - pub fn grin_get_vertex_list_by_type_select_master( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> GRIN_VERTEX_LIST; -} -extern "C" { - #[doc = " @brief Get the vertex list of a given type with mirror vertices only.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex list of mirror vertices only."] - pub fn grin_get_vertex_list_by_type_select_mirror( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> GRIN_VERTEX_LIST; -} -extern "C" { - pub fn grin_get_vertex_list_by_type_select_partition( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_PARTITION, - ) -> GRIN_VERTEX_LIST; -} -extern "C" { - pub fn grin_get_edge_list_by_type_select_master( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> GRIN_EDGE_LIST; -} -extern "C" { - pub fn grin_get_edge_list_by_type_select_mirror( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> GRIN_EDGE_LIST; -} -extern "C" { - pub fn grin_get_edge_list_by_type_select_partition( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - arg3: GRIN_PARTITION, - ) -> GRIN_EDGE_LIST; -} -extern "C" { - pub fn grin_get_adjacent_list_by_edge_type_select_master_neighbor( - arg1: GRIN_GRAPH, - arg2: GRIN_DIRECTION, - arg3: GRIN_VERTEX, - arg4: GRIN_EDGE_TYPE, - ) -> GRIN_ADJACENT_LIST; -} -extern "C" { - pub fn grin_get_adjacent_list_by_edge_type_select_mirror_neighbor( - arg1: GRIN_GRAPH, - arg2: GRIN_DIRECTION, - arg3: GRIN_VERTEX, - arg4: GRIN_EDGE_TYPE, - ) -> GRIN_ADJACENT_LIST; -} -extern "C" { - pub fn grin_get_adjacent_list_by_edge_type_select_partition_neighbor( - arg1: GRIN_GRAPH, - arg2: GRIN_DIRECTION, - arg3: GRIN_VERTEX, - arg4: GRIN_EDGE_TYPE, - arg5: GRIN_PARTITION, - ) -> GRIN_ADJACENT_LIST; -} -extern "C" { - pub fn grin_get_one_to_one_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; -} -extern "C" { - pub fn grin_get_one_to_many_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; -} -extern "C" { - pub fn grin_get_many_to_one_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; -} -extern "C" { - pub fn grin_get_many_to_many_vev_types(arg1: GRIN_GRAPH) -> GRIN_VEV_TYPE_LIST; -} -extern "C" { - #[doc = " @brief Get the vertex types that have primary keys\n In some graph, not every vertex type has primary keys.\n @param GRIN_GRAPH The graph\n @return The vertex type list of types that have primary keys"] - pub fn grin_get_vertex_types_with_primary_keys(arg1: GRIN_GRAPH) -> GRIN_VERTEX_TYPE_LIST; -} -extern "C" { - #[doc = " @brief Get the primary keys properties of a vertex type\n The primary keys properties are the properties that can be used to identify a vertex.\n They are a subset of the properties of a vertex type.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @return The primary keys properties list"] - pub fn grin_get_primary_keys_by_vertex_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> GRIN_VERTEX_PROPERTY_LIST; -} -extern "C" { - #[doc = " @brief Get the primary keys values row of a vertex\n The values in the row are in the same order as the primary keys properties.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @return The primary keys values row"] - pub fn grin_get_vertex_primary_keys_row(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_ROW; -} -extern "C" { - pub fn grin_get_edge_types_with_primary_keys(arg1: GRIN_GRAPH) -> GRIN_EDGE_TYPE_LIST; -} -extern "C" { - pub fn grin_get_primary_keys_by_edge_type( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> GRIN_EDGE_PROPERTY_LIST; -} -extern "C" { - pub fn grin_get_edge_primary_keys_row(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_ROW; -} -extern "C" { - pub fn grin_destroy_string_value(arg1: GRIN_GRAPH, arg2: *const ::std::os::raw::c_char); -} -extern "C" { - #[doc = " @brief Get the vertex property name\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type that the property belongs to\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The property's name as string"] - pub fn grin_get_vertex_property_name( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_VERTEX_PROPERTY, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - #[doc = " @brief Get the vertex property with a given name under a specific vertex type\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The specific vertex type\n @param name The name\n @return The vertex property"] - pub fn grin_get_vertex_property_by_name( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - name: *const ::std::os::raw::c_char, - ) -> GRIN_VERTEX_PROPERTY; -} -extern "C" { - #[doc = " @brief Get properties under all types with a given name.\n For example, vertex type \"person\" and \"company\" both have a property\n called \"name\". When this API is called given \"name\", it will return a list\n of \"name\" properties under both types.\n @param GRIN_GRAPH The graph\n @param name The name\n @return The vertex property list of properties with the given name"] - pub fn grin_get_vertex_properties_by_name( - arg1: GRIN_GRAPH, - name: *const ::std::os::raw::c_char, - ) -> GRIN_VERTEX_PROPERTY_LIST; -} -extern "C" { - pub fn grin_get_edge_property_name( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - arg3: GRIN_EDGE_PROPERTY, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_get_edge_property_by_name( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - name: *const ::std::os::raw::c_char, - ) -> GRIN_EDGE_PROPERTY; -} -extern "C" { - pub fn grin_get_edge_properties_by_name( - arg1: GRIN_GRAPH, - name: *const ::std::os::raw::c_char, - ) -> GRIN_EDGE_PROPERTY_LIST; -} -extern "C" { - pub fn grin_equal_vertex_property( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_PROPERTY, - arg3: GRIN_VERTEX_PROPERTY, - ) -> bool; -} -extern "C" { - pub fn grin_destroy_vertex_property(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_PROPERTY); -} -extern "C" { - #[doc = " @brief Get the datatype of the vertex property\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The datatype of the vertex property"] - pub fn grin_get_vertex_property_datatype( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_PROPERTY, - ) -> GRIN_DATATYPE; -} -extern "C" { - #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_int32( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " @brief Get the value of uint32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_uint32( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_uint; -} -extern "C" { - #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype int64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_int64( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief Get the value of uint64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype uint64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_uint64( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_ulonglong; -} -extern "C" { - #[doc = " @brief Get the value of float, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype float.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_float( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> f32; -} -extern "C" { - #[doc = " @brief Get the value of double, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype double.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_double( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> f64; -} -extern "C" { - #[doc = " @brief Get the value of string, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype string.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_string( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype date32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_date32( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " @brief Get the value of int32, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype time32.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_time32( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " @brief Get the value of int64, given a vertex and a vertex property.\n The user should make sure the vertex property is of datatype timestamp64.\n The return int has no predefined invalid value.\n User should use ``grin_get_last_error_code()`` to check if the API call\n is successful.\n Note that the returned string should be explicitly freed by the user,\n by calling API ``grin_destroy_string_value``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The value of the property"] - pub fn grin_get_vertex_property_value_of_timestamp64( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief Get the vertex type that a given vertex property belongs to.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_PROPERTY The vertex property\n @return The vertex type"] - pub fn grin_get_vertex_type_from_property( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_PROPERTY, - ) -> GRIN_VERTEX_TYPE; -} -extern "C" { - pub fn grin_get_vertex_property_value( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX, - arg3: GRIN_VERTEX_PROPERTY, - ) -> *const ::std::os::raw::c_void; -} -extern "C" { - pub fn grin_equal_edge_property( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_PROPERTY, - arg3: GRIN_EDGE_PROPERTY, - ) -> bool; -} -extern "C" { - pub fn grin_destroy_edge_property(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_PROPERTY); -} -extern "C" { - pub fn grin_get_edge_property_datatype( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_PROPERTY, - ) -> GRIN_DATATYPE; -} -extern "C" { - pub fn grin_get_edge_property_value_of_int32( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn grin_get_edge_property_value_of_uint32( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_uint; -} -extern "C" { - pub fn grin_get_edge_property_value_of_int64( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - pub fn grin_get_edge_property_value_of_uint64( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_ulonglong; -} -extern "C" { - pub fn grin_get_edge_property_value_of_float( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> f32; -} -extern "C" { - pub fn grin_get_edge_property_value_of_double( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> f64; -} -extern "C" { - pub fn grin_get_edge_property_value_of_string( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_get_edge_property_value_of_date32( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn grin_get_edge_property_value_of_time32( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn grin_get_edge_property_value_of_timestamp64( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - pub fn grin_get_edge_type_from_property( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_PROPERTY, - ) -> GRIN_EDGE_TYPE; -} -extern "C" { - pub fn grin_get_edge_property_value( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE, - arg3: GRIN_EDGE_PROPERTY, - ) -> *const ::std::os::raw::c_void; -} -extern "C" { - #[doc = " @brief Get the vertex property list of the graph.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @return The vertex property list."] - pub fn grin_get_vertex_property_list_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> GRIN_VERTEX_PROPERTY_LIST; -} -extern "C" { - pub fn grin_get_vertex_property_list_size( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_PROPERTY_LIST, - ) -> usize; -} -extern "C" { - pub fn grin_get_vertex_property_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_PROPERTY_LIST, - arg3: usize, - ) -> GRIN_VERTEX_PROPERTY; -} -extern "C" { - pub fn grin_create_vertex_property_list(arg1: GRIN_GRAPH) -> GRIN_VERTEX_PROPERTY_LIST; -} -extern "C" { - pub fn grin_destroy_vertex_property_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_PROPERTY_LIST); -} -extern "C" { - pub fn grin_insert_vertex_property_to_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_PROPERTY_LIST, - arg3: GRIN_VERTEX_PROPERTY, - ) -> bool; -} -extern "C" { - #[doc = " @brief Get the vertex property handle by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @param GRIN_VERTEX_PROPERTY_ID The vertex property id.\n @return The vertex property handle."] - pub fn grin_get_vertex_property_by_id( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_VERTEX_PROPERTY_ID, - ) -> GRIN_VERTEX_PROPERTY; -} -extern "C" { - #[doc = " @brief Get the vertex property's natural id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY``,\n meaning that the storage has naturally increasing ids for vertex properties\n under a certain vertex type.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @param GRIN_VERTEX_PROPERTY The vertex property handle.\n @return The vertex property id."] - pub fn grin_get_vertex_property_id( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_VERTEX_PROPERTY, - ) -> GRIN_VERTEX_PROPERTY_ID; -} -extern "C" { - pub fn grin_get_edge_property_list_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> GRIN_EDGE_PROPERTY_LIST; -} -extern "C" { - pub fn grin_get_edge_property_list_size( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_PROPERTY_LIST, - ) -> usize; -} -extern "C" { - pub fn grin_get_edge_property_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_PROPERTY_LIST, - arg3: usize, - ) -> GRIN_EDGE_PROPERTY; -} -extern "C" { - pub fn grin_create_edge_property_list(arg1: GRIN_GRAPH) -> GRIN_EDGE_PROPERTY_LIST; -} -extern "C" { - pub fn grin_destroy_edge_property_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_PROPERTY_LIST); -} -extern "C" { - pub fn grin_insert_edge_property_to_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_PROPERTY_LIST, - arg3: GRIN_EDGE_PROPERTY, - ) -> bool; -} -extern "C" { - pub fn grin_get_edge_property_by_id( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - arg3: GRIN_EDGE_PROPERTY_ID, - ) -> GRIN_EDGE_PROPERTY; -} -extern "C" { - #[doc = " We must specify the edge type here, because the edge property id is unique only under a specific edge type"] - pub fn grin_get_edge_property_id( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - arg3: GRIN_EDGE_PROPERTY, - ) -> GRIN_EDGE_PROPERTY_ID; -} -extern "C" { - pub fn grin_destroy_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW); -} -extern "C" { - pub fn grin_get_int32_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn grin_get_uint32_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_uint; -} -extern "C" { - pub fn grin_get_int64_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - pub fn grin_get_uint64_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_ulonglong; -} -extern "C" { - pub fn grin_get_float_from_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: usize) -> f32; -} -extern "C" { - pub fn grin_get_double_from_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: usize) -> f64; -} -extern "C" { - pub fn grin_get_string_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_get_date32_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn grin_get_time32_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn grin_get_timestamp64_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: usize, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief Create a row.\n Row works as carrier of property values in GRIN.\n It is a pure value array, and users can only get the value by the array index.\n That means users should understand the property that each value is\n representing when using the row.\n Currently rows are used in two scenarios:\n 1. Users can create a row of values for primary keys properties,\n and then query the vertex/edge using the row if pk indexing is enabled.\n 2. Users can get the row of values for the entire property list of\n a vertex/edge in one API ``grin_get_vertex_row`` or ``grin_get_edge_row``.\n However this API is not recommended if the user only wants to get the\n properties values, in which case, the user can get property values\n one-by-one using the APIs like ``grin_get_vertex_property_value_of_int32``."] - pub fn grin_create_row(arg1: GRIN_GRAPH) -> GRIN_ROW; -} -extern "C" { - pub fn grin_insert_int32_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_int, - ) -> bool; -} -extern "C" { - pub fn grin_insert_uint32_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_uint, - ) -> bool; -} -extern "C" { - pub fn grin_insert_int64_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_longlong, - ) -> bool; -} -extern "C" { - pub fn grin_insert_uint64_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_ulonglong, - ) -> bool; -} -extern "C" { - pub fn grin_insert_float_to_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: f32) -> bool; -} -extern "C" { - pub fn grin_insert_double_to_row(arg1: GRIN_GRAPH, arg2: GRIN_ROW, arg3: f64) -> bool; -} -extern "C" { - pub fn grin_insert_string_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: *const ::std::os::raw::c_char, - ) -> bool; -} -extern "C" { - pub fn grin_insert_date32_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_int, - ) -> bool; -} -extern "C" { - pub fn grin_insert_time32_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_int, - ) -> bool; -} -extern "C" { - pub fn grin_insert_timestamp64_to_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: ::std::os::raw::c_longlong, - ) -> bool; -} -extern "C" { - pub fn grin_get_value_from_row( - arg1: GRIN_GRAPH, - arg2: GRIN_ROW, - arg3: GRIN_DATATYPE, - arg4: usize, - ) -> *const ::std::os::raw::c_void; -} -extern "C" { - #[doc = " @brief Get row of values for the entire property list of a vertex.\n Later users can get property values from the row using APIs like\n ``grin_get_int32_from_row``.\n However this two-step value getting is not recommended if the user\n only wants to get the value of one property, in which case, the user\n should use APIs like ``grin_get_vertex_property_value_of_int32``.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex"] - pub fn grin_get_vertex_row(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_ROW; -} -extern "C" { - pub fn grin_get_edge_row(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_ROW; -} -extern "C" { - #[doc = " @brief Get the vertex number of a given type in the graph.\n This API is only available for property graph.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex number."] - pub fn grin_get_vertex_num_by_type(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE) -> usize; -} -extern "C" { - pub fn grin_get_edge_num_by_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE) -> usize; -} -extern "C" { - #[doc = " @brief Get the vertex list of a given type.\n This API is only available for property graph.\n To get a vertex list chain of all types, using APIs in GRIN extension.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex list of the given type."] - pub fn grin_get_vertex_list_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> GRIN_VERTEX_LIST; -} -extern "C" { - pub fn grin_get_edge_list_by_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE) -> GRIN_EDGE_LIST; -} -extern "C" { - #[doc = " @brief Get the adjacent list of given direction, vertex and edge type.\n This API is only available for property graph.\n To get a adjacent list chain of all types, using APIs in GRIN extension.\n @param GRIN_GRAPH The graph.\n @param GRIN_DIRECTION The direction of the adjacent list.\n @param GRIN_VERTEX The vertex.\n @return The adjacent list."] - pub fn grin_get_adjacent_list_by_edge_type( - arg1: GRIN_GRAPH, - arg2: GRIN_DIRECTION, - arg3: GRIN_VERTEX, - arg4: GRIN_EDGE_TYPE, - ) -> GRIN_ADJACENT_LIST; -} -extern "C" { - pub fn grin_equal_vertex_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_VERTEX_TYPE, - ) -> bool; -} -extern "C" { - pub fn grin_get_vertex_type(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_VERTEX_TYPE; -} -extern "C" { - pub fn grin_destroy_vertex_type(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE); -} -extern "C" { - #[doc = " @brief Get the vertex type list of the graph\n This API is only available for property graph.\n It lists all the vertex types in the graph.\n @param GRIN_GRAPH The graph.\n @return The vertex type list."] - pub fn grin_get_vertex_type_list(arg1: GRIN_GRAPH) -> GRIN_VERTEX_TYPE_LIST; -} -extern "C" { - pub fn grin_destroy_vertex_type_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE_LIST); -} -extern "C" { - pub fn grin_create_vertex_type_list(arg1: GRIN_GRAPH) -> GRIN_VERTEX_TYPE_LIST; -} -extern "C" { - pub fn grin_insert_vertex_type_to_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE_LIST, - arg3: GRIN_VERTEX_TYPE, - ) -> bool; -} -extern "C" { - pub fn grin_get_vertex_type_list_size(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE_LIST) -> usize; -} -extern "C" { - pub fn grin_get_vertex_type_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE_LIST, - arg3: usize, - ) -> GRIN_VERTEX_TYPE; -} -extern "C" { - #[doc = " @brief Get the vertex type name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex type name of string."] - pub fn grin_get_vertex_type_name( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - #[doc = " @brief Get the vertex type by name.\n This API is enabled by ``GRIN_WITH_VERTEX_TYPE_NAME``,\n meaning that the graph has a unique name for each vertex type.\n @param GRIN_GRAPH The graph.\n @param name The vertex type name.\n @return The vertex type."] - pub fn grin_get_vertex_type_by_name( - arg1: GRIN_GRAPH, - name: *const ::std::os::raw::c_char, - ) -> GRIN_VERTEX_TYPE; -} -extern "C" { - #[doc = " @brief Get the vertex type id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @return The vertex type id."] - pub fn grin_get_vertex_type_id(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX_TYPE) - -> GRIN_VERTEX_TYPE_ID; -} -extern "C" { - #[doc = " @brief Get the vertex type by id.\n This API is enabled by ``GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE``,\n meaning that the graph has naturally increasing ids for vertex types.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE_ID The vertex type id.\n @return The vertex type."] - pub fn grin_get_vertex_type_by_id( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE_ID, - ) -> GRIN_VERTEX_TYPE; -} -extern "C" { - pub fn grin_equal_edge_type( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - arg3: GRIN_EDGE_TYPE, - ) -> bool; -} -extern "C" { - pub fn grin_get_edge_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_EDGE_TYPE; -} -extern "C" { - pub fn grin_destroy_edge_type(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE); -} -extern "C" { - pub fn grin_get_edge_type_list(arg1: GRIN_GRAPH) -> GRIN_EDGE_TYPE_LIST; -} -extern "C" { - pub fn grin_destroy_edge_type_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE_LIST); -} -extern "C" { - pub fn grin_create_edge_type_list(arg1: GRIN_GRAPH) -> GRIN_EDGE_TYPE_LIST; -} -extern "C" { - pub fn grin_insert_edge_type_to_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE_LIST, - arg3: GRIN_EDGE_TYPE, - ) -> bool; -} -extern "C" { - pub fn grin_get_edge_type_list_size(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE_LIST) -> usize; -} -extern "C" { - pub fn grin_get_edge_type_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE_LIST, - arg3: usize, - ) -> GRIN_EDGE_TYPE; -} -extern "C" { - pub fn grin_get_edge_type_name( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_get_edge_type_by_name( - arg1: GRIN_GRAPH, - arg2: *const ::std::os::raw::c_char, - ) -> GRIN_EDGE_TYPE; -} -extern "C" { - pub fn grin_get_edge_type_id(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE) -> GRIN_EDGE_TYPE_ID; -} -extern "C" { - pub fn grin_get_edge_type_by_id(arg1: GRIN_GRAPH, arg2: GRIN_EDGE_TYPE_ID) -> GRIN_EDGE_TYPE; -} -extern "C" { - #[doc = " @brief Get source vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE_TYPE The edge type.\n @return The vertex type list of source."] - pub fn grin_get_src_types_by_edge_type( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> GRIN_VERTEX_TYPE_LIST; -} -extern "C" { - #[doc = " @brief Get destination vertex types related to an edge type.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n To return the related pairs of vertex types, GRIN provides two APIs to get\n the src and dst vertex types respectively.\n The returned vertex type lists are of the same size,\n and the src/dst vertex types are aligned with their positions in the lists.\n @param GRIN_GRAPH The graph.\n @param GRIN_EDGE_TYPE The edge type.\n @return The vertex type list of destination."] - pub fn grin_get_dst_types_by_edge_type( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - ) -> GRIN_VERTEX_TYPE_LIST; -} -extern "C" { - #[doc = " @brief Get edge types related to a pair of vertex types.\n GRIN assumes the relation between edge type and pairs of vertex types is\n many-to-many.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The source vertex type.\n @param GRIN_VERTEX_TYPE The destination vertex type.\n @return The related edge type list."] - pub fn grin_get_edge_types_by_vertex_type_pair( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_VERTEX_TYPE, - ) -> GRIN_EDGE_TYPE_LIST; -} -extern "C" { - pub fn grin_get_label_by_name( - arg1: GRIN_GRAPH, - arg2: *const ::std::os::raw::c_char, - ) -> GRIN_LABEL; -} -extern "C" { - pub fn grin_destroy_label(arg1: GRIN_GRAPH, arg2: GRIN_LABEL); -} -extern "C" { - pub fn grin_get_label_name(arg1: GRIN_GRAPH, arg2: GRIN_LABEL) - -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn grin_destroy_label_list(arg1: GRIN_GRAPH, arg2: GRIN_LABEL_LIST); -} -extern "C" { - pub fn grin_get_label_list_size(arg1: GRIN_GRAPH, arg2: GRIN_LABEL_LIST) -> usize; -} -extern "C" { - pub fn grin_get_label_from_list( - arg1: GRIN_GRAPH, - arg2: GRIN_LABEL_LIST, - arg3: usize, - ) -> GRIN_LABEL; -} -extern "C" { - #[doc = " @brief assign a label to a vertex\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label\n @param GRIN_VERTEX the vertex\n @return whether succeed"] - pub fn grin_assign_label_to_vertex( - arg1: GRIN_GRAPH, - arg2: GRIN_LABEL, - arg3: GRIN_VERTEX, - ) -> bool; -} -extern "C" { - #[doc = " @brief get the label list of a vertex\n @param GRIN_GRAPH the graph\n @param GRIN_VERTEX the vertex"] - pub fn grin_get_vertex_label_list(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX) -> GRIN_LABEL_LIST; -} -extern "C" { - #[doc = " @brief get the vertex list by label\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label"] - pub fn grin_get_vertex_list_by_label(arg1: GRIN_GRAPH, arg2: GRIN_LABEL) -> GRIN_VERTEX_LIST; -} -extern "C" { - #[doc = " @brief filtering an existing vertex list by label\n @param GRIN_VERTEX_LIST the existing vertex list\n @param GRIN_LABEL the label"] - pub fn grin_select_label_for_vertex_list( - arg1: GRIN_GRAPH, - arg2: GRIN_LABEL, - arg3: GRIN_VERTEX_LIST, - ) -> GRIN_VERTEX_LIST; -} -extern "C" { - #[doc = " @brief assign a label to a edge\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label\n @param GRIN_EDGE the edge\n @return whether succeed"] - pub fn grin_assign_label_to_edge(arg1: GRIN_GRAPH, arg2: GRIN_LABEL, arg3: GRIN_EDGE) -> bool; -} -extern "C" { - #[doc = " @brief get the label list of a edge\n @param GRIN_GRAPH the graph\n @param GRIN_EDGE the edge"] - pub fn grin_get_edge_label_list(arg1: GRIN_GRAPH, arg2: GRIN_EDGE) -> GRIN_LABEL_LIST; -} -extern "C" { - #[doc = " @brief get the edge list by label\n @param GRIN_GRAPH the graph\n @param GRIN_LABEL the label"] - pub fn grin_get_edge_list_by_label(arg1: GRIN_GRAPH, arg2: GRIN_LABEL) -> GRIN_EDGE_LIST; -} -extern "C" { - #[doc = " @brief filtering an existing edge list by label\n @param GRIN_EDGE_LIST the existing edge list\n @param GRIN_LABEL the label"] - pub fn grin_select_label_for_edge_list( - arg1: GRIN_GRAPH, - arg2: GRIN_LABEL, - arg3: GRIN_EDGE_LIST, - ) -> GRIN_EDGE_LIST; -} -extern "C" { - pub fn grin_smaller_vertex(arg1: GRIN_GRAPH, arg2: GRIN_VERTEX, arg3: GRIN_VERTEX) -> bool; -} -extern "C" { - #[doc = " @brief Get the position of a vertex in a sorted list\n caller must guarantee the input vertex list is sorted to get the correct result\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_LIST The sorted vertex list\n @param GRIN_VERTEX The vertex to find\n @return The position of the vertex"] - pub fn grin_get_position_of_vertex_from_sorted_list( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_LIST, - arg3: GRIN_VERTEX, - ) -> usize; -} -extern "C" { - #[doc = " @brief Get the int64 internal id of a vertex\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX The vertex\n @return The int64 internal id of the vertex"] - pub fn grin_get_vertex_internal_id_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_VERTEX, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief Get the vertex by internal id under type\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @param id The internal id of the vertex under type\n @return The vertex"] - pub fn grin_get_vertex_by_internal_id_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - id: ::std::os::raw::c_longlong, - ) -> GRIN_VERTEX; -} -extern "C" { - #[doc = " @brief Get the upper bound of internal id under type.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @return The upper bound of internal id under type"] - pub fn grin_get_vertex_internal_id_upper_bound_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief Get the lower bound internal id under type.\n @param GRIN_GRAPH The graph\n @param GRIN_VERTEX_TYPE The vertex type\n @return The lower bound internal id under type"] - pub fn grin_get_vertex_internal_id_lower_bound_by_type( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - ) -> ::std::os::raw::c_longlong; -} -extern "C" { - #[doc = " @brief Get the vertex by primary keys row.\n The values in the row must be in the same order as the primary keys\n properties, which can be obtained by ``grin_get_primary_keys_by_vertex_type``.\n @param GRIN_GRAPH The graph.\n @param GRIN_VERTEX_TYPE The vertex type.\n @param GRIN_ROW The values row of primary keys properties.\n @return The vertex."] - pub fn grin_get_vertex_by_primary_keys_row( - arg1: GRIN_GRAPH, - arg2: GRIN_VERTEX_TYPE, - arg3: GRIN_ROW, - ) -> GRIN_VERTEX; -} -extern "C" { - pub fn grin_get_edge_by_primary_keys_row( - arg1: GRIN_GRAPH, - arg2: GRIN_EDGE_TYPE, - arg3: GRIN_ROW, - ) -> GRIN_EDGE; -} -extern "C" { - pub static mut grin_error_code: GRIN_ERROR_CODE; -} -extern "C" { - #[doc = " @brief Get the last error code.\n The error code is thread local.\n Currently users only need to check the error code when using\n getting-value APIs whose return has no predefined invalid value."] - pub fn grin_get_last_error_code() -> GRIN_ERROR_CODE; -} -extern "C" { - #[doc = " @brief Get the static feature prototype message of the storage.\n This proto describes the features of the storage, such as whether\n it supports property graph or partitioned graph.\n @return The serialized proto message."] - pub fn grin_get_static_storage_feature_msg() -> *const ::std::os::raw::c_char; -} -extern "C" { - #[doc = " GRIN_FEATURES_ENABLE_ALL\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_DATA: GrinVertexData = 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_DATA: GrinEdgeData = 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 = std::ptr::null_mut();\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 = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_REF: GrinEdgeRef = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = std::ptr::null_mut();\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 = std::ptr::null_mut();\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 = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = std::ptr::null_mut();\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_LABEL: GrinLabel = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_LABEL_LIST: GrinLabelList = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX;"] - pub static mut __rust_keep_grin_null: ::std::os::raw::c_int; -} diff --git a/flex/engines/graph_db/grin/include/rust/grin_v6d.h b/flex/engines/graph_db/grin/include/rust/grin_v6d.h deleted file mode 100644 index 820ff02ab7b6..000000000000 --- a/flex/engines/graph_db/grin/include/rust/grin_v6d.h +++ /dev/null @@ -1,38 +0,0 @@ -#define GRIN_FEATURES_ENABLE_V6D -#define GRIN_RUST_CODEGEN - -#include "storage/v6d/predefine.h" - -#ifdef GRIN_RUST_CODEGEN -/// GRIN_FEATURES_ENABLE_V6D -/// RUST_KEEP pub const GRIN_NULL_DATATYPE: GrinDatatype = GRIN_DATATYPE_UNDEFINED; -/// RUST_KEEP pub const GRIN_NULL_GRAPH: GrinGraph = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX: GrinVertex = u64::MAX; -/// 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}; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST: GrinVertexList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_LIST_ITERATOR: GrinVertexListIterator = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST: GrinAdjacentList = GrinAdjacentList{begin: std::ptr::null(), end: std::ptr::null(), vid: u64::MAX, dir: GRIN_DIRECTION_BOTH, etype: u32::MAX}; -/// RUST_KEEP pub const GRIN_NULL_ADJACENT_LIST_ITERATOR: GrinAdjacentListIterator = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITIONED_GRAPH: GrinPartitionedGraph = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITION: GrinPartition = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_PARTITION_LIST: GrinPartitionList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_PARTITION_ID: GrinPartitionId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_REF: GrinVertexRef = -1; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE: GrinVertexType = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_LIST: GrinVertexTypeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY: GrinVertexProperty = u64::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_LIST: GrinVertexPropertyList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VERTEX_TYPE_ID: GrinVertexTypeId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_VERTEX_PROPERTY_ID: GrinVertexPropertyId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE: GrinEdgeType = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_LIST: GrinEdgeTypeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE: GrinVevType = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY: GrinEdgeProperty = u64::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_LIST: GrinEdgePropertyList = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_EDGE_TYPE_ID: GrinEdgeTypeId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_EDGE_PROPERTY_ID: GrinEdgePropertyId = u32::MAX; -/// RUST_KEEP pub const GRIN_NULL_ROW: GrinRow = std::ptr::null_mut(); -/// RUST_KEEP pub const GRIN_NULL_SIZE: u32 = u32::MAX; -int __rust_keep_grin_null; -#endif diff --git a/flex/engines/graph_db/grin/include/rust/grin_v6d.rs b/flex/engines/graph_db/grin/include/rust/grin_v6d.rs deleted file mode 100644 index 2b6b26011a31..000000000000 --- a/flex/engines/graph_db/grin/include/rust/grin_v6d.rs +++ /dev/null @@ -1,97 +0,0 @@ -/* automatically generated by rust-bindgen 0.64.0 */ - -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const __bool_true_false_are_defined: u32 = 1; -pub const GRIN_NULL_VERTEX_REF: i32 = -1; -pub type wchar_t = ::std::os::raw::c_int; -pub type max_align_t = u128; -#[doc = "< incoming"] -pub const GRIN_DIRECTION_IN: GRIN_DIRECTION = 0; -#[doc = "< outgoing"] -pub const GRIN_DIRECTION_OUT: GRIN_DIRECTION = 1; -#[doc = "< incoming & outgoing"] -pub const GRIN_DIRECTION_BOTH: GRIN_DIRECTION = 2; -#[doc = " Enumerates the directions of edges with respect to a certain vertex"] -pub type GRIN_DIRECTION = ::std::os::raw::c_uint; -#[doc = "< other unknown types"] -pub const GRIN_DATATYPE_Undefined: GRIN_DATATYPE = 0; -#[doc = "< int"] -pub const GRIN_DATATYPE_Int32: GRIN_DATATYPE = 1; -#[doc = "< unsigned int"] -pub const GRIN_DATATYPE_UInt32: GRIN_DATATYPE = 2; -#[doc = "< long int"] -pub const GRIN_DATATYPE_Int64: GRIN_DATATYPE = 3; -#[doc = "< unsigned long int"] -pub const GRIN_DATATYPE_UInt64: GRIN_DATATYPE = 4; -#[doc = "< float"] -pub const GRIN_DATATYPE_Float: GRIN_DATATYPE = 5; -#[doc = "< double"] -pub const GRIN_DATATYPE_Double: GRIN_DATATYPE = 6; -#[doc = "< string"] -pub const GRIN_DATATYPE_String: GRIN_DATATYPE = 7; -#[doc = "< date"] -pub const GRIN_DATATYPE_Date32: GRIN_DATATYPE = 8; -#[doc = "< Time32"] -pub const GRIN_DATATYPE_Time32: GRIN_DATATYPE = 9; -#[doc = "< Timestamp"] -pub const GRIN_DATATYPE_Timestamp64: GRIN_DATATYPE = 10; -#[doc = " Enumerates the datatype supported in the storage"] -pub type GRIN_DATATYPE = ::std::os::raw::c_uint; -#[doc = "< success"] -pub const GRIN_ERROR_CODE_NO_ERROR: GRIN_ERROR_CODE = 0; -#[doc = "< unknown error"] -pub const GRIN_ERROR_CODE_UNKNOWN_ERROR: GRIN_ERROR_CODE = 1; -#[doc = "< invalid value"] -pub const GRIN_ERROR_CODE_INVALID_VALUE: GRIN_ERROR_CODE = 2; -#[doc = "< unknown datatype"] -pub const GRIN_ERROR_CODE_UNKNOWN_DATATYPE: GRIN_ERROR_CODE = 3; -#[doc = " Enumerates the error codes of grin"] -pub type GRIN_ERROR_CODE = ::std::os::raw::c_uint; -pub type GRIN_GRAPH = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX = ::std::os::raw::c_ulonglong; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct GRIN_EDGE { - pub src: GRIN_VERTEX, - pub dst: GRIN_VERTEX, - pub dir: GRIN_DIRECTION, - pub etype: ::std::os::raw::c_uint, - pub eid: ::std::os::raw::c_ulonglong, -} -pub type GRIN_VERTEX_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_LIST_ITERATOR = *mut ::std::os::raw::c_void; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct GRIN_ADJACENT_LIST { - pub begin: *const ::std::os::raw::c_void, - pub end: *const ::std::os::raw::c_void, - pub vid: GRIN_VERTEX, - pub dir: GRIN_DIRECTION, - pub etype: ::std::os::raw::c_uint, -} -pub type GRIN_ADJACENT_LIST_ITERATOR = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITIONED_GRAPH = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITION = ::std::os::raw::c_uint; -pub type GRIN_PARTITION_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_PARTITION_ID = ::std::os::raw::c_uint; -pub type GRIN_VERTEX_REF = ::std::os::raw::c_longlong; -pub type GRIN_VERTEX_TYPE = ::std::os::raw::c_uint; -pub type GRIN_VERTEX_TYPE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_PROPERTY = ::std::os::raw::c_ulonglong; -pub type GRIN_VERTEX_PROPERTY_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VERTEX_TYPE_ID = ::std::os::raw::c_uint; -pub type GRIN_VERTEX_PROPERTY_ID = ::std::os::raw::c_uint; -pub type GRIN_EDGE_TYPE = ::std::os::raw::c_uint; -pub type GRIN_EDGE_TYPE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_VEV_TYPE = *mut ::std::os::raw::c_void; -pub type GRIN_VEV_TYPE_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_PROPERTY = ::std::os::raw::c_ulonglong; -pub type GRIN_EDGE_PROPERTY_LIST = *mut ::std::os::raw::c_void; -pub type GRIN_EDGE_TYPE_ID = ::std::os::raw::c_uint; -pub type GRIN_EDGE_PROPERTY_ID = ::std::os::raw::c_uint; -pub type GRIN_ROW = *mut ::std::os::raw::c_void; -extern "C" { - #[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 = GrinAdjacentList{begin: std::ptr::null(), end: std::ptr::null(), vid: 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_VEV_TYPE: GrinVevType = std::ptr::null_mut();\n RUST_KEEP pub const GRIN_NULL_VEV_TYPE_LIST: GrinVevTypeList = 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;"] - pub static mut __rust_keep_grin_null: ::std::os::raw::c_int; -} diff --git a/flex/engines/graph_db/grin/include/rust/parse.py b/flex/engines/graph_db/grin/include/rust/parse.py deleted file mode 100644 index 93c07cb95ce7..000000000000 --- a/flex/engines/graph_db/grin/include/rust/parse.py +++ /dev/null @@ -1,257 +0,0 @@ -import os -from pathlib import Path - -def get_func_name(line): - return line.split('(')[0].strip().split(' ')[-1].strip() - -def get_macro_name(line): - return ('one', [('yes', line.split(' ')[1].strip())]) - -def parse_expr(line): - line = line.strip() - assert(line.startswith('#if ')) - line = line[4:] - defs = line.split() - res = [] - rel = '' - for d in defs: - if d.startswith('!'): - res.append(('not', d[1+8: -1])) - elif d.startswith('defined'): - res.append(('yes', d[8: -1])) - elif d == '&&': - assert(rel == '' or rel == 'and') - rel = 'and' - elif d == '||': - assert(rel == '' or rel == 'or') - rel = 'or' - else: - assert False, f'unknown: {d}' - assert(rel != '') - return (rel, res) - -def parse(path): - res = {} - macros = [] - prefix = '' - with open(path) as f: - for _line in f: - if _line.strip().endswith('\\'): - prefix += _line.strip()[:-1] - continue - line = prefix + _line - prefix = '' - if line.startswith(('GRIN_', 'void', 'bool', 'size_t', 'const', 'int', 'long long int', - 'unsigned int', 'unsigned long long int', - 'float', 'double', 'const char*', 'struct')): - func_name = get_func_name(line) - res[func_name] = macros.copy() - elif line.startswith('#ifdef'): - assert(len(macros) == 0) - macro_name = get_macro_name(line) - macros.append(macro_name) - elif line.startswith('#endif'): - assert(len(macros) <= 1) - if len(macros) == 1: - macros = macros[:-1] - elif line.startswith('#if '): - assert(len(macros) == 0) - macro_name = parse_expr(line) - macros.append(macro_name) - return res - -def to_rust(deps): - if len(deps) == 0: - return '' - assert(len(deps) == 1) - one_foramt = '#[cfg(feature = \"{}\")]' - yes_format = 'feature = \"{}\"' - not_format = 'not(feature = \"{}\")' - all_format = '#[cfg(all({}))]' - any_format = '#[cfg(any({}))]' - - deps = deps[0] - if deps[0] == 'one': - assert(len(deps[1]) == 1) - assert(deps[1][0][0] == 'yes') - return one_foramt.format(deps[1][0][1].lower()) - elif deps[0] == 'and': - conds = [not_format.format(d[1].lower()) if d[0] == 'not' else yes_format.format(d[1].lower()) for d in deps[1]] - return all_format.format(", ".join(conds)) - elif deps[0] == 'or': - conds = [not_format.format(d[1].lower()) if d[0] == 'not' else yes_format.format(d[1].lower()) for d in deps[1]] - return any_format.format(", ".join(conds)) - else: - assert False, f'unknown: {deps}' - -def snake_to_camel(s): - if s.startswith(('GRIN_DATATYPE_', 'GRIN_DIRECTION_', 'GRIN_ERROR_CODE_', 'GRIN_FEATURES_ENABLE')): - return s.upper() - return ''.join([w.capitalize() for w in s.split('_')]) - -def snake_to_camel_line(line): - segs = line.split(' ') - return ' '.join([snake_to_camel(s) if s.startswith('GRIN_') and s.find('NULL') == -1 else s for s in segs]) - -def static_replace(line): - replaces = { - '::std::os::raw::c_uint': 'u32', - '::std::os::raw::c_int': 'i32', - '::std::os::raw::c_ulonglong': 'u64', - '::std::os::raw::c_longlong': 'i64', - 'Copy, Clone': 'Copy, Clone, PartialEq', - } - for k in replaces: - line = line.replace(k, replaces[k]) - return line - - -def rewrite(file, r, strip=7): - with open(file) as f: - lines = f.readlines() - externc_flag = True - need_ending_line = True - parts = [[], [], [], []] - p = 0 - for i, line in enumerate(lines): - if i < strip: - continue - line = snake_to_camel_line(line) - line = static_replace(line) - if line.startswith('extern '): - if externc_flag: - p += 1 - parts[p].append('extern "C" {') - externc_flag = False - continue - if line.startswith('}'): - if i < len(lines) - 1: - if externc_flag: - parts[p].append('}') - else: - parts[p].append('') - else: - need_ending_line = False - parts[p].append('}') - continue - if line.find('pub fn') != -1: - func_name = line - func_name = func_name[func_name.find('pub fn')+7:] - func_name = func_name.split('(')[0] - if func_name in r and r[func_name]: - parts[p].append(f' {r[func_name]}') - parts[p].append(' #[allow(unused)]') - if line.find('pub type') != -1: - func_name = line - func_name = func_name[func_name.find('pub type')+9:] - func_name = func_name.split(' ')[0] - if func_name in r and r[func_name]: - parts[p].append(f'{r[func_name]}') - parts[p].append('#[allow(unused)]') - if line.find('RUST_KEEP') != -1: - macro_name = line[line.find('GRIN'):line.find('RUST_KEEP')-3].lower() - if need_ending_line: - parts[p][-1] = '}' - p += 1 - segs = line.split('RUST_KEEP') - for s in segs[1:]: - parts[p].append(s[1:s.find(';')+1]) - break - if line.find('pub type GrinGraph') != -1: - p += 1 - parts[p].append(line[:-1]) - return parts - - -def parse_to_rs(path, dst, predefine, strip=7): - r = {} - r |= parse(path / predefine) - for f in path.glob('include/**/*.h'): - r |= parse(f) - for k in r: - r[k] = to_rust(r[k]) - return rewrite(f'{dst}.rs', r, strip=strip) - -def get_features(path, storage): - macros = [] - with open(path / f'storage/{storage}/predefine.h') as f: - lines = f.readlines() - for line in lines: - if line.startswith('#define') and line.find('GRIN_NULL') == -1: - macros.append(line[8:].strip().lower()) - return macros - -def parse_to_toml(path, storages): - features = {} - for s in storages: - features[f'grin_features_enable_{s}'] = get_features(path, s) - with open(path / 'template/predefine.h') as f: - lines = f.readlines() - macros = [] - for line in lines: - if line.startswith('#define') and line.find('GRIN_NULL') == -1: - macros.append(line[8:].strip().lower()) - with open('Cargo.toml', 'w') as f: - f.write('[package]\n') - f.write(f'name = \"grin\"\n') - f.write('version = \"0.1.1\"\n') - f.write('authors = [\"dijie\"]\n') - f.write('\n') - f.write('[dependencies]\n') - f.write('cfg-if = \"0.1\"\n\n') - f.write('[features]\n') - for k in macros: - f.write(f'{k} = []\n') - for feat in features: - f.write(f'{feat} = {features[feat]}\n') - -def bindgen(src, dst): - os.system(f'bindgen {src} -o {dst}.rs --no-layout-tests -- -I"../include" -I".."') - -def all(path): - src = 'grin_all.h' - dst = 'grin_all' - predefine = 'template/predefine.h' - bindgen(src, dst) - return parse_to_rs(path, dst, predefine) - -def v6d(path): - src = 'grin_v6d.h' - dst = 'grin_v6d' - predefine = 'storage/v6d/predefine.h' - bindgen(src, dst) - return parse_to_rs(path, dst, predefine, strip=50) - -def merge(partss): - with open('grin.rs', 'w') as outfile: - # write allparts 0 - outfile.write('\n'.join(partss['all'][0])) - outfile.write('\n') - # write every parts 1 & 3 - outfile.write('cfg_if::cfg_if! {\n') - first = True - for k in partss: - if k != 'all': - if first: - first = False - outfile.write(' if') - else: - outfile.write(' elif') - outfile.write(f' #[cfg(feature = \"grin_features_enable_{k}\")]') - else: - outfile.write(' else ') - outfile.write('{\n') - outfile.write('\n'.join([f' {x}' for x in partss[k][1] + partss[k][3]])) - outfile.write('\n }') - outfile.write('\n}\n') - # write allparts 2 - outfile.write('\n'.join(partss['all'][2])) - outfile.write('\n') - - -if __name__ == '__main__': - path = Path('..') - allparts = all(path) - v6dparts = v6d(path) - merge({'v6d': v6dparts, 'all': allparts}) - parse_to_toml(path, ['v6d']) \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/storage/GART/predefine.h b/flex/engines/graph_db/grin/include/storage/GART/predefine.h deleted file mode 100644 index 8009c9efca2b..000000000000 --- a/flex/engines/graph_db/grin/include/storage/GART/predefine.h +++ /dev/null @@ -1,237 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @file predefine.h - * @brief This template file consists of four parts: - * 1. The predefined enumerate types of GRIN, which should NOT be modified. - * 2. The supported macros which should be specified by storage implementors - * based on storage features. - * 3. The typedefs of the enabled handles. This should be specified by storage. - * 4. The corresponding null values of the enabled handles. This should be - * specified by storage. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* 1. Predefined enumerate types of GRIN */ -/// Enumerates the directions of edges with respect to a certain vertex -typedef enum { - IN = 0, ///< incoming - OUT = 1, ///< outgoing - BOTH = 2, ///< incoming & outgoing -} GRIN_DIRECTION; - -/// Enumerates the datatype supported in the storage -typedef enum { - Undefined = 0, ///< other unknown types - Int32 = 1, ///< int - UInt32 = 2, ///< unsigned int - Int64 = 3, ///< long int - UInt64 = 4, ///< unsigned long int - Float = 5, ///< float - Double = 6, ///< double - String = 7, ///< string - Date32 = 8, ///< date - Time32 = 9, ///< Time32 - Timestamp64 = 10, ///< Timestamp -} GRIN_DATATYPE; - -/// Enumerates the error codes of grin -typedef enum { - NO_ERROR = 0, ///< success - UNKNOWN_ERROR = 1, ///< unknown error - INVALID_VALUE = 2, ///< invalid value - UNKNOWN_DATATYPE = 3, ///< unknown datatype -} GRIN_ERROR_CODE; - -/* Define supported macros based on storage features */ -// Topology -#define GRIN_ASSUME_HAS_DIRECTED_GRAPH -#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH -#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -#define GRIN_ENABLE_VERTEX_LIST -#define GRIN_ENABLE_VERTEX_LIST_ITERATOR -#define GRIN_ENABLE_ADJACENT_LIST -#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR -// Partition -#define GRIN_ENABLE_GRAPH_PARTITION -#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -#define GRIN_ENABLE_VERTEX_REF -#define GRIN_TRAIT_FAST_VERTEX_REF -#define GRIN_ASSUME_EDGE_CUT_PARTITION -#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST -// Property -#define GRIN_ENABLE_ROW -#define GRIN_WITH_VERTEX_PROPERTY -#define GRIN_WITH_VERTEX_PROPERTY_NAME -#define GRIN_WITH_VERTEX_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY_NAME -#define GRIN_WITH_EDGE_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -// Index -#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - -/* Define the handles using typedef */ -typedef void* GRIN_GRAPH; -typedef unsigned long long int GRIN_VERTEX; - -#ifdef GRIN_WITH_VERTEX_DATA -typedef void* GRIN_VERTEX_DATA; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST -typedef void* GRIN_VERTEX_LIST; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef void* GRIN_VERTEX_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -typedef void* GRIN_ADJACENT_LIST_ITERATOR; -#endif - -#ifdef GRIN_WITH_EDGE_DATA -typedef void* GRIN_EDGE_DATA; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST -typedef void* GRIN_EDGE_LIST; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR -typedef void* GRIN_EDGE_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -typedef void* GRIN_PARTITIONED_GRAPH; -typedef unsigned GRIN_PARTITION; -typedef void* GRIN_PARTITION_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -typedef unsigned GRIN_PARTITION_ID; -#endif - -#ifdef GRIN_ENABLE_VERTEX_REF -typedef long long int GRIN_VERTEX_REF; -#endif - -#ifdef GRIN_ENABLE_EDGE_REF -typedef void* GRIN_EDGE_REF; -#endif - -#ifdef GRIN_WITH_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_TYPE; -typedef void* GRIN_VERTEX_TYPE_LIST; -typedef unsigned long long int GRIN_VERTEX_PROPERTY; -typedef void* GRIN_VERTEX_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -typedef unsigned GRIN_VERTEX_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_PROPERTY_ID; -#endif - -#ifdef GRIN_WITH_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_TYPE; -typedef void* GRIN_EDGE_TYPE_LIST; -typedef void* GRIN_VEV_TYPE; -typedef void* GRIN_VEV_TYPE_LIST; -typedef unsigned long long int GRIN_EDGE_PROPERTY; -typedef void* GRIN_EDGE_PROPERTY_LIST; -#endif - -typedef struct GRIN_EDGE { - GRIN_VERTEX src; - GRIN_VERTEX dst; - GRIN_DIRECTION dir; - GRIN_EDGE_TYPE etype; - char* edata; -} GRIN_EDGE; - -#ifdef GRIN_ENABLE_ADJACENT_LIST -typedef struct GRIN_ADJACENT_LIST { - GRIN_VERTEX v; - GRIN_DIRECTION dir; - GRIN_EDGE_TYPE etype; -} GRIN_ADJACENT_LIST; -#endif - - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -typedef unsigned GRIN_EDGE_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_PROPERTY_ID; -#endif - -#ifdef GRIN_ENABLE_ROW -typedef void* GRIN_ROW; -#endif - -#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) -typedef void* GRIN_LABEL; -typedef void* GRIN_LABEL_LIST; -#endif - -/* Define invalid values for returns of handles */ -#define GRIN_NULL_GRAPH NULL -#define GRIN_NULL_VERTEX (unsigned long long int)~0 -#define GRIN_NULL_VERTEX_LIST NULL -#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL -#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL -#define GRIN_NULL_PARTITIONED_GRAPH NULL -#define GRIN_NULL_PARTITION (unsigned)~0 -#define GRIN_NULL_PARTITION_LIST NULL -#define GRIN_NULL_PARTITION_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_REF -1 -#define GRIN_NULL_VERTEX_TYPE (unsigned)~0 -#define GRIN_NULL_VERTEX_TYPE_LIST NULL -#define GRIN_NULL_VERTEX_PROPERTY (unsigned long long int)~0 -#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL -#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_EDGE_TYPE (unsigned)~0 -#define GRIN_NULL_EDGE_TYPE_LIST NULL -#define GRIN_NULL_VEV_TYPE NULL -#define GRIN_NULL_VEV_TYPE_LIST NULL -#define GRIN_NULL_EDGE_PROPERTY (unsigned long long int)~0 -#define GRIN_NULL_EDGE_PROPERTY_LIST NULL -#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 -#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_ROW NULL -#define GRIN_NULL_SIZE (unsigned)~0 -#define GRIN_NULL_NAME NULL -#define GRIN_NULL_EDGE GRIN_EDGE{GRIN_NULL_VERTEX, GRIN_NULL_VERTEX, BOTH, GRIN_NULL_EDGE_TYPE_ID, NULL} -#define GRIN_NULL_ADJACENT_LIST GRIN_ADJACENT_LIST{GRIN_NULL_VERTEX, BOTH, GRIN_NULL_EDGE_TYPE_ID} - -#ifdef __cplusplus -} -#endif diff --git a/flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h b/flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h deleted file mode 100644 index b675ee947b6a..000000000000 --- a/flex/engines/graph_db/grin/include/storage/GraphAr/predefine.h +++ /dev/null @@ -1,243 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @file predefine.h - * @brief This template file consists of four parts: - * 1. The predefined enumerate types of GRIN, which should NOT be modified. - * 2. The supported macros which should be specified by storage implementors - * based on storage features. - * 3. The typedefs of the enabled handles. This should be specified by storage. - * 4. The corresponding null values of the enabled handles. This should be - * specified by storage. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* 1. Predefined enumerate types of GRIN */ -/// Enumerates the directions of edges with respect to a certain vertex -typedef enum { - IN = 0, ///< incoming - OUT = 1, ///< outgoing - BOTH = 2, ///< incoming & outgoing -} GRIN_DIRECTION; - -/// Enumerates the datatype supported in the storage -typedef enum { - Undefined = 0, ///< other unknown types - Int32 = 1, ///< int - UInt32 = 2, ///< unsigned int - Int64 = 3, ///< long int - UInt64 = 4, ///< unsigned long int - Float = 5, ///< float - Double = 6, ///< double - String = 7, ///< string - Date32 = 8, ///< date - Time32 = 9, ///< Time32 - Timestamp64 = 10, ///< Timestamp -} GRIN_DATATYPE; - -/// Enumerates the error codes of grin -typedef enum { - NO_ERROR = 0, ///< success - UNKNOWN_ERROR = 1, ///< unknown error - INVALID_VALUE = 2, ///< invalid value - UNKNOWN_DATATYPE = 3, ///< unknown datatype -} GRIN_ERROR_CODE; - -/* 2. Define supported macros based on storage features */ -// Topology -#define GRIN_ASSUME_HAS_DIRECTED_GRAPH -#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -#define GRIN_ENABLE_VERTEX_LIST -#define GRIN_ENABLE_VERTEX_LIST_ARRAY -#define GRIN_ENABLE_VERTEX_LIST_ITERATOR -#define GRIN_ENABLE_EDGE_LIST -#define GRIN_ENABLE_EDGE_LIST_ITERATOR -#define GRIN_ENABLE_ADJACENT_LIST -#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR -// Partition -#define GRIN_ENABLE_GRAPH_PARTITION -#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -#define GRIN_ENABLE_VERTEX_REF -#define GRIN_TRAIT_FAST_VERTEX_REF -#define GRIN_ASSUME_ALL_REPLICATE_PARTITION -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA -#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST -#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST -#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST -#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST -// Property -#define GRIN_ENABLE_ROW -#define GRIN_WITH_VERTEX_PROPERTY -#define GRIN_WITH_VERTEX_PROPERTY_NAME -#define GRIN_WITH_VERTEX_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY_NAME -#define GRIN_WITH_EDGE_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY -// Index -#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED -#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - -/* 3. Define the handles using typedef */ -typedef void* GRIN_GRAPH; -typedef void* GRIN_VERTEX; -typedef void* GRIN_EDGE; - -#ifdef GRIN_WITH_VERTEX_DATA -typedef void* GRIN_VERTEX_DATA; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST -typedef void* GRIN_VERTEX_LIST; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef void* GRIN_VERTEX_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST -typedef void* GRIN_ADJACENT_LIST; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -typedef void* GRIN_ADJACENT_LIST_ITERATOR; -#endif - -#ifdef GRIN_WITH_EDGE_DATA -typedef void* GRIN_EDGE_DATA; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST -typedef void* GRIN_EDGE_LIST; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR -typedef void* GRIN_EDGE_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -typedef void* GRIN_PARTITIONED_GRAPH; -typedef unsigned GRIN_PARTITION; -typedef void* GRIN_PARTITION_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -typedef unsigned GRIN_PARTITION_ID; -#endif - -#ifdef GRIN_ENABLE_VERTEX_REF -typedef long long int GRIN_VERTEX_REF; -#endif - -#ifdef GRIN_ENABLE_EDGE_REF -typedef void* GRIN_EDGE_REF; -#endif - -#ifdef GRIN_WITH_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_TYPE; -typedef void* GRIN_VERTEX_TYPE_LIST; -typedef unsigned GRIN_VERTEX_PROPERTY; -typedef void* GRIN_VERTEX_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -typedef unsigned GRIN_VERTEX_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_PROPERTY_ID; -#endif - -#ifdef GRIN_WITH_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_TYPE; -typedef void* GRIN_EDGE_TYPE_LIST; -typedef void* GRIN_VEV_TYPE; -typedef void* GRIN_VEV_TYPE_LIST; -typedef unsigned GRIN_EDGE_PROPERTY; -typedef void* GRIN_EDGE_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -typedef unsigned GRIN_EDGE_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_PROPERTY_ID; -#endif - -#ifdef GRIN_ENABLE_ROW -typedef void* GRIN_ROW; -#endif - -#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) -typedef void* GRIN_LABEL; -typedef void* GRIN_LABEL_LIST; -#endif - -/* 4. Define invalid values for returns of handles */ -#define GRIN_NULL_GRAPH NULL -#define GRIN_NULL_VERTEX NULL -#define GRIN_NULL_EDGE NULL -#define GRIN_NULL_VERTEX_DATA NULL -#define GRIN_NULL_VERTEX_LIST NULL -#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL -#define GRIN_NULL_ADJACENT_LIST NULL -#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL -#define GRIN_NULL_EDGE_DATA NULL -#define GRIN_NULL_EDGE_LIST NULL -#define GRIN_NULL_EDGE_LIST_ITERATOR NULL -#define GRIN_NULL_PARTITIONED_GRAPH NULL -#define GRIN_NULL_PARTITION (unsigned) ~0 -#define GRIN_NULL_PARTITION_LIST NULL -#define GRIN_NULL_PARTITION_ID (unsigned) ~0 -#define GRIN_NULL_VERTEX_REF -1 -#define GRIN_NULL_EDGE_REF NULL -#define GRIN_NULL_VERTEX_TYPE (unsigned) ~0 -#define GRIN_NULL_VERTEX_TYPE_LIST NULL -#define GRIN_NULL_VERTEX_PROPERTY (unsigned) ~0 -#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL -#define GRIN_NULL_VERTEX_TYPE_ID (unsigned) ~0 -#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned) ~0 -#define GRIN_NULL_EDGE_TYPE (unsigned) ~0 -#define GRIN_NULL_EDGE_TYPE_LIST NULL -#define GRIN_NULL_VEV_TYPE NULL -#define GRIN_NULL_VEV_TYPE_LIST NULL -#define GRIN_NULL_EDGE_PROPERTY (unsigned) ~0 -#define GRIN_NULL_EDGE_PROPERTY_LIST NULL -#define GRIN_NULL_EDGE_TYPE_ID (unsigned) ~0 -#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned) ~0 -#define GRIN_NULL_ROW NULL -#define GRIN_NULL_LABEL NULL -#define GRIN_NULL_LABEL_LIST NULL -#define GRIN_NULL_SIZE (unsigned) ~0 -#define GRIN_NULL_NAME NULL - -#ifdef __cplusplus -} -#endif diff --git a/flex/engines/graph_db/grin/include/storage/v6d/predefine.h b/flex/engines/graph_db/grin/include/storage/v6d/predefine.h deleted file mode 100644 index e1daea396fbb..000000000000 --- a/flex/engines/graph_db/grin/include/storage/v6d/predefine.h +++ /dev/null @@ -1,241 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @file predefine.h - * @brief This template file consists of four parts: - * 1. The predefined enumerate types of GRIN, which should NOT be modified. - * 2. The supported macros which should be specified by storage implementors - * based on storage features. - * 3. The typedefs of the enabled handles. This should be specified by storage. - * 4. The corresponding null values of the enabled handles. This should be - * specified by storage. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* 1. Predefined enumerate types of GRIN */ -/// Enumerates the directions of edges with respect to a certain vertex -typedef enum { - IN = 0, ///< incoming - OUT = 1, ///< outgoing - BOTH = 2, ///< incoming & outgoing -} GRIN_DIRECTION; - -/// Enumerates the datatype supported in the storage -typedef enum { - Undefined = 0, ///< other unknown types - Int32 = 1, ///< int - UInt32 = 2, ///< unsigned int - Int64 = 3, ///< long int - UInt64 = 4, ///< unsigned long int - Float = 5, ///< float - Double = 6, ///< double - String = 7, ///< string - Date32 = 8, ///< date - Time32 = 9, ///< Time32 - Timestamp64 = 10, ///< Timestamp -} GRIN_DATATYPE; - -/// Enumerates the error codes of grin -typedef enum { - NO_ERROR = 0, ///< success - UNKNOWN_ERROR = 1, ///< unknown error - INVALID_VALUE = 2, ///< invalid value - UNKNOWN_DATATYPE = 3, ///< unknown datatype -} GRIN_ERROR_CODE; - -/* Define supported macros based on storage features */ -// Topology -#define GRIN_ASSUME_HAS_DIRECTED_GRAPH -#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH -#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -#define GRIN_ENABLE_VERTEX_LIST -#define GRIN_ENABLE_VERTEX_LIST_ARRAY -#define GRIN_ENABLE_VERTEX_LIST_ITERATOR -#define GRIN_ENABLE_ADJACENT_LIST -#define GRIN_ENABLE_ADJACENT_LIST_ARRAY -#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR -// Partition -#define GRIN_ENABLE_GRAPH_PARTITION -#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -#define GRIN_ENABLE_VERTEX_REF -#define GRIN_TRAIT_FAST_VERTEX_REF -#define GRIN_ASSUME_EDGE_CUT_PARTITION -#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST -// Property -#define GRIN_ENABLE_ROW -#define GRIN_WITH_VERTEX_PROPERTY -#define GRIN_WITH_VERTEX_PROPERTY_NAME -#define GRIN_WITH_VERTEX_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY_NAME -#define GRIN_WITH_EDGE_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS -// Index -#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX -#define GRIN_ENABLE_VERTEX_PK_INDEX - -/* Define the handles using typedef */ -typedef void* GRIN_GRAPH; -typedef unsigned long long int GRIN_VERTEX; -typedef struct GRIN_EDGE { - GRIN_VERTEX src; - GRIN_VERTEX dst; - GRIN_DIRECTION dir; - unsigned etype; - unsigned long long int eid; -} GRIN_EDGE; - -#ifdef GRIN_WITH_VERTEX_DATA -typedef void* GRIN_VERTEX_DATA; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST -typedef void* GRIN_VERTEX_LIST; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef void* GRIN_VERTEX_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST -typedef struct GRIN_ADJACENT_LIST { - const void* begin; - const void* end; - GRIN_VERTEX vid; - GRIN_DIRECTION dir; - unsigned etype; -} GRIN_ADJACENT_LIST; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -typedef void* GRIN_ADJACENT_LIST_ITERATOR; -#endif - -#ifdef GRIN_WITH_EDGE_DATA -typedef void* GRIN_EDGE_DATA; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST -typedef void* GRIN_EDGE_LIST; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR -typedef void* GRIN_EDGE_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -typedef void* GRIN_PARTITIONED_GRAPH; -typedef unsigned GRIN_PARTITION; -typedef void* GRIN_PARTITION_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -typedef unsigned GRIN_PARTITION_ID; -#endif - -#ifdef GRIN_ENABLE_VERTEX_REF -typedef long long int GRIN_VERTEX_REF; -#endif - -#ifdef GRIN_ENABLE_EDGE_REF -typedef void* GRIN_EDGE_REF; -#endif - -#ifdef GRIN_WITH_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_TYPE; -typedef void* GRIN_VERTEX_TYPE_LIST; -typedef unsigned long long int GRIN_VERTEX_PROPERTY; -typedef void* GRIN_VERTEX_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -typedef unsigned GRIN_VERTEX_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_PROPERTY_ID; -#endif - -#ifdef GRIN_WITH_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_TYPE; -typedef void* GRIN_EDGE_TYPE_LIST; -typedef void* GRIN_VEV_TYPE; -typedef void* GRIN_VEV_TYPE_LIST; -typedef unsigned long long int GRIN_EDGE_PROPERTY; -typedef void* GRIN_EDGE_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -typedef unsigned GRIN_EDGE_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_PROPERTY_ID; -#endif - -#ifdef GRIN_ENABLE_ROW -typedef void* GRIN_ROW; -#endif - -#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) -typedef void* GRIN_LABEL; -typedef void* GRIN_LABEL_LIST; -#endif - -/* Define invalid values for returns of handles */ -#define GRIN_NULL_GRAPH NULL -#define GRIN_NULL_VERTEX (unsigned long long int)~0 -#define GRIN_NULL_EDGE GRIN_EDGE{GRIN_NULL_VERTEX, GRIN_NULL_VERTEX, BOTH, (unsigned)~0, (unsigned long long int)~0} -#define GRIN_NULL_VERTEX_LIST NULL -#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL -#define GRIN_NULL_ADJACENT_LIST GRIN_ADJACENT_LIST{NULL, NULL, GRIN_NULL_VERTEX, BOTH, (unsigned)~0} -#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL -#define GRIN_NULL_PARTITIONED_GRAPH NULL -#define GRIN_NULL_PARTITION (unsigned)~0 -#define GRIN_NULL_PARTITION_LIST NULL -#define GRIN_NULL_PARTITION_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_REF -1 -#define GRIN_NULL_VERTEX_TYPE (unsigned)~0 -#define GRIN_NULL_VERTEX_TYPE_LIST NULL -#define GRIN_NULL_VERTEX_PROPERTY (unsigned long long int)~0 -#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL -#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_EDGE_TYPE (unsigned)~0 -#define GRIN_NULL_EDGE_TYPE_LIST NULL -#define GRIN_NULL_VEV_TYPE NULL -#define GRIN_NULL_VEV_TYPE_LIST NULL -#define GRIN_NULL_EDGE_PROPERTY (unsigned long long int)~0 -#define GRIN_NULL_EDGE_PROPERTY_LIST NULL -#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 -#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_ROW NULL -#define GRIN_NULL_SIZE (unsigned)~0 -#define GRIN_NULL_NAME NULL - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/template/features.h b/flex/engines/graph_db/grin/include/template/features.h deleted file mode 100644 index d3ab7431e33f..000000000000 --- a/flex/engines/graph_db/grin/include/template/features.h +++ /dev/null @@ -1,506 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @file features.h - * @brief This file lists ALL the pre-defined macros for storage features, - * and it should NOT be included by users. - * Users should use the predefine.h of the specific storage. - * The macros are organized into several sections such as topology, - * partition, and so on. - * Storage implementors should Turn-ON (i.e., define) the specific - * macros in their predefine.h based the features of the storage. -*/ - -/* Section 1: Toplogy */ - -/** @name TopologyMacros - * @brief Macros for basic graph topology features - */ -///@{ -/** @ingroup TopologyMacros - * @brief The storage supports directed graphs. - */ -#define GRIN_ASSUME_HAS_DIRECTED_GRAPH - -/** @ingroup TopologyMacros - * @brief The storage supports undirected graphs. - */ -#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH - -/** @ingroup TopologyMacros - * @brief The storage supports multiple edges between a pair of vertices. - */ -#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH - -/** @ingroup TopologyMacros - * @brief There is data on vertex. E.g., the PageRank value of a vertex. - */ -#define GRIN_WITH_VERTEX_DATA - -/** @ingroup TopologyMacros - * @brief There is data on edge. E.g., the weight of an edge. -*/ -#define GRIN_WITH_EDGE_DATA - -/** @ingroup TopologyMacros - * @brief Enable the vertex list structure. - * It follows the design for Topology Lists. -*/ -#define GRIN_ENABLE_VERTEX_LIST - -/** @ingroup TopologyMacros - * @brief Enable the vertex list array-style retrieval. -*/ -#define GRIN_ENABLE_VERTEX_LIST_ARRAY - -/** @ingroup TopologyMacros - * @brief Enable the vertex list iterator. -*/ -#define GRIN_ENABLE_VERTEX_LIST_ITERATOR - -/** @ingroup TopologyMacros - * @brief Enable the edge list structure. - * It follows the design for Topology Lists. -*/ -#define GRIN_ENABLE_EDGE_LIST - -/** @ingroup TopologyMacros - * @brief Enable the edge list array-style retrieval. -*/ -#define GRIN_ENABLE_EDGE_LIST_ARRAY - -/** @ingroup TopologyMacros - * @brief Enable the edge list iterator. -*/ -#define GRIN_ENABLE_EDGE_LIST_ITERATOR - -/** @ingroup TopologyMacros - * @brief Enable the adjacent list structure. - * It follows the design for Topology Lists. -*/ -#define GRIN_ENABLE_ADJACENT_LIST - -/** @ingroup TopologyMacros - * @brief Enable the adjacent list array-style retrieval. -*/ -#define GRIN_ENABLE_ADJACENT_LIST_ARRAY - -/** @ingroup TopologyMacros - * @brief Enable the adjacent list iterator. -*/ -#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR -///@} - -/* End of Section 1 */ - -/* Section 2. Partition */ - -/** @name PartitionMacros - * @brief Macros for partitioned graph features - */ -///@{ -/** @ingroup PartitionMacros - * @brief Enable partitioned graph. A partitioned graph usually contains - * several fragments (i.e., local graphs) that are distributedly stored - * in a cluster. In GRIN, GRIN_GRAPH represents to a single fragment that can - * be locally accessed. - */ -#define GRIN_ENABLE_GRAPH_PARTITION - -/** @ingroup PartitionMacros - * @brief The storage provides natural number IDs for partitions. - * It follows the design of natural number ID trait in GRIN. -*/ -#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION - -/** @ingroup PartitionMacros - * @brief The storage provides reference of vertex that can be - * recognized in other partitions where the vertex also appears. -*/ -#define GRIN_ENABLE_VERTEX_REF - -/** @ingroup PartitionMacros - * @brief The storage provides fast reference of vertex, which means - * the vertex ref can be serialized into a int64 using - * grin_serialize_vertex_ref_as_int64 -*/ -#define GRIN_TRAIT_FAST_VERTEX_REF - -/** @ingroup PartitionMacros - * @brief The storage provides reference of edge that can be - * recognized in other partitions where the edge also appears. -*/ -#define GRIN_ENABLE_EDGE_REF -///@} - -/** @name PartitionStrategyMacros - * @brief Macros to define partition strategy assumptions, a partition strategy - * can be seen as a combination of detail partition assumptions which are defined after - * the strategies. Please refer to the documents for strategy details. -*/ -///@{ -/** @ingroup PartitionStrategyMacros - * @brief The storage ONLY uses all-replicate partition strategy. This means the - * storage's replicate the graph among all partitions. -*/ -#define GRIN_ASSUME_ALL_REPLICATE_PARTITION - -/** @ingroup PartitionStrategyMacros - * @brief The storage ONLY uses edge-cut partition strategy. This means the - * storage's entire partition strategy complies with edge-cut strategy - * definition in GRIN. -*/ -#define GRIN_ASSUME_EDGE_CUT_PARTITION - -/** @ingroup PartitionStrategyMacros - * @brief The storage ONLY uses edge-cut partition & edges only follow src strategy. - * This means the storage's entire partition strategy complies with edge-cut strategy - * definition in GRIN, and edges are partitioned to the partition of the source vertex. -*/ -#define GRIN_ASSUME_EDGE_CUT_FOLLOW_SRC_PARTITION - -/** @ingroup PartitionStrategyMacros - * @brief The storage ONLY uses edge-cut partition & edges only follow dst strategy. - * This means the storage's entire partition strategy complies with edge-cut strategy - * definition in GRIN, and edges are partitioned to the partition of the destination vertex. -*/ -#define GRIN_ASSUME_EDGE_CUT_FOLLOW_DST_PARTITION - - -/** @ingroup PartitionStrategyMacros - * @brief The storage ONLY uses vertex-cut partition strategy. This means the - * storage's entire partition strategy complies with vertex-cut strategy - * definition in GRIN. -*/ -#define GRIN_ASSUME_VERTEX_CUT_PARTITION -///@} - -/** @name PartitionAssumptionMacros - * @brief Macros to define detailed partition assumptions with respect to the - * concept of local complete. Please refer to the documents for the meaning of - * local complete. -*/ -///@{ -/** @ingroup PartitionAssumptionMacros - * @brief Assume the vertex data are only stored together with master vertices. -*/ -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_DATA - -/** @ingroup PartitionAssumptionMacros - * @brief Assume the vertex data are replicated on both master and mirror vertices. -*/ -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA - -/** @ingroup PartitionAssumptionMacros - * @brief Assume the edge data are only stored together with master edges. -*/ -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_DATA - -/** @ingroup PartitionAssumptionMacros - * @brief Assume the edge data are replicated on both master and mirror edges. -*/ -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA -///@} - -/** @name TraitMirrorPartitionMacros - * @brief Macros for storage that provides the partition list where the mirror - * vertices are located. This trait is usually enabled by storages using vertex-cut - * partition strategy. -*/ -///@{ -/** @ingroup TraitMirrorPartitionMacros - * @brief The storage provides the partition list where the mirror - * vertices are located of a local master vertex. -*/ -#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST - -/** @ingroup TraitMirrorPartitionMacros - * @brief The storage provides the partition list where the mirror - * vertices are located of a local mirror vertex -*/ -#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST - -/** @ingroup TraitMirrorPartitionMacros - * @brief The storage provides the partition list where the mirror - * edges are located of a local master edge -*/ -#define GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST - -/** @ingroup TraitMirrorPartitionMacros - * @brief The storage provides the partition list where the mirror - * edges are located of a local mirror edge -*/ -#define GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST -///@} - -/** @name TraitFilterMacros - * @brief Macros for storage that provides filtering ability of partitions for - * topology lists. This trait is usually enabled for efficient graph traversal. -*/ -///@{ -/** @ingroup TraitFilterMacros - * @brief The storage provides master vertex filtering for vertex list. - * This means suffix ``_select_master`` or ``_select_mirror`` can be added to a - * ``grin_get_vertex_list`` API to get a master-only or mirror-only vertex list. - * For example, ``grin_get_vertex_list_by_type_select_mirror`` returns - * a vertex list of a given type with mirror vertices only. -*/ -#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST - -/** @ingroup TraitFilterMacros - * @brief The storage provides per partition vertex filtering for vertex list. - * The suffix is ``_select_partition``. -*/ -#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST - -/** @ingroup TraitFilterMacros - * @brief The storage provides master edge filtering for edge list. - * The suffixes ``_select_master`` and ``_select_mirror`` - * are the same as vertex list. -*/ -#define GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST - -/** @ingroup TraitFilterMacros - * @brief The storage provides per partition edge filtering for edge list. - * The suffix is ``_select_partition``. -*/ -#define GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST - -/** @ingroup TraitFilterMacros - * @brief The storage provides master neighbor filtering for adjacent list. - * The suffixes are ``_select_master_neighbor`` and ``_select_mirror_neighbor``. -*/ -#define GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST - -/** @ingroup TraitFilterMacros - * @brief The storage provides per partition neighbor filtering for adjacent list. - * The suffix is ``_select_neighbor_partition``. -*/ -#define GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST -///@} - -/* End of Section 2 */ - -/* Section 3. Property */ - -/** @name PropertyMacros - * @brief Macros for basic property graph features - */ -///@{ -/** @ingroup PropertyMacros - * @brief Enable the pure value structure Row -*/ -#define GRIN_ENABLE_ROW - -/** @ingroup PropertyMacros - * @brief This trait is used to indicate the storage can return a pointer to the - * value of a property. However, this trait is going to be deprecated, because - * it is too complex to use related APIs in the computing side. -*/ -#define GRIN_TRAIT_CONST_VALUE_PTR - -/** @ingroup PropertyMacros - * @brief The graph has vertex properties, meaning it is a property graph. -*/ -#define GRIN_WITH_VERTEX_PROPERTY - -/** @ingroup PropertyMacros - * @brief There are property names for vertex properties. - * The relationship between property name and properties is one-to-many, - * because properties bound to different vertex types are distinguished - * even they may share the same property name. -*/ -#define GRIN_WITH_VERTEX_PROPERTY_NAME - -/** @ingroup PropertyMacros - * @brief There are unique names for each vertex type. -*/ -#define GRIN_WITH_VERTEX_TYPE_NAME - -/** @ingroup PropertyMacros - * @brief The storage provides natural number IDs for vertex types. - * It follows the design of natural ID trait in GRIN. -*/ -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE - -/** @ingroup PropertyMacros - * @brief There are primary keys for vertices. - * Consider each vertex type as a table in relational database, where - * the properties are the columns of the table. - * The storage supports setting a subset of the properties as the primary keys, - * meaning that each vertex of a certain type has its unique property values - * on the primary keys. -*/ -#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS - -/** @ingroup PropertyMacros - * @brief The storage provides natural number IDs for properties bound to - * a certain vertex type. - * It follows the design of natural ID trait in GRIN. -*/ -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY - -/** @ingroup PropertyMacros - * @brief The graph has edge properties, meaning it is a property graph. -*/ -#define GRIN_WITH_EDGE_PROPERTY - -/** @ingroup PropertyMacros - * @brief There are property names for edge properties. - * The relationship between property name and properties is one-to-many, - * because properties bound to different edge types are distinguished - * even they may share the same property name. -*/ -#define GRIN_WITH_EDGE_PROPERTY_NAME - -/** @ingroup PropertyMacros - * @brief There are unique names for each edge type. -*/ -#define GRIN_WITH_EDGE_TYPE_NAME - -/** @ingroup PropertyMacros - * @brief The storage provides natural number IDs for edge types. - * It follows the design of natural ID trait in GRIN. -*/ -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE - -/** @ingroup PropertyMacros - * @brief There are primary keys for edges. - * Consider each edge type as a table in relational database, where - * the properties are the columns of the table. - * The storage supports setting a subset of the properties as the primary keys, - * meaning that each edge of a certain type has its unique property values - * on the primary keys. -*/ -#define GRIN_ENABLE_EDGE_PRIMARY_KEYS - -/** @ingroup PropertyMacros - * @brief The storage provides natural number IDs for properties bound to - * a certain edge type. - * It follows the design of natural ID trait in GRIN. -*/ -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -///@} - -/** @name TraitFilterTypeMacros - * @brief Macros of traits to filter vertex/edge type for - * structures like vertex list and adjacent list. - */ -///@{ -/** @ingroup TraitFilterTypeMacros - * @brief The storage provides specific relationship description for each - * vertex-edge-vertex type traid. This means further optimizations can be - * applied by the callers for vev traid under certain relationships, such as - * one-to-one, one-to-many, or many-to-one. -*/ -#define GRIN_TRAIT_SPECIFIC_VEV_RELATION -///@} - -/** @name PropetyAssumptionMacros - * @brief Macros of assumptions for property local complete, and particularly define - * the by type local complete assumptions for hybrid partiton strategy. - */ -///@{ -/** @ingroup PropetyAssumptionMacros - * @brief Assume full property values of a vertex are ONLY stored with master vertices. -*/ -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY - -/** @ingroup PropetyAssumptionMacros - * @brief Assume full property values of a vertex are replicated with master and mirror vertices. -*/ -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY - -/** @ingroup PropetyAssumptionMacros - * @brief Assume full property values of a vertex are split among master and mirror vertices. -*/ -#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY - -/** @ingroup PropetyAssumptionMacros - * @brief Assume full property values of an edge are ONLY stored with master edges. -*/ -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY - -/** @ingroup PropetyAssumptionMacros - * @brief Assume full property values of an edge are replicated with master and mirror edges. -*/ -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY - -/** @ingroup PropetyAssumptionMacros - * @brief Assume full property values of an edge are split among master and mirror edges. -*/ -#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY -///@} - -/* End of Section 3 */ - -/* Section 4. Index */ -/** @name IndexLabelMacros - * @brief Macros for label features - */ -///@{ -/** @ingroup IndexLabelMacros - * @brief Enable vertex label on graph. -*/ -#define GRIN_WITH_VERTEX_LABEL - -/** @ingroup IndexLabelMacros - * @brief Enable edge label on graph. -*/ -#define GRIN_WITH_EDGE_LABEL -///@} - -/** @name IndexOrderMacros - * @brief Macros for ordering features. - */ -///@{ -/** @ingroup IndexOrderMacros - * @brief assume all vertex list are sorted. - * We will expend the assumption to support master/mirror or - * by type in the future if needed. -*/ -#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED -///@} - -/** @name IndexInternalIDMacros - * @brief Macros for internal ID indexing features - */ -///@{ -/** @ingroup IndexInternalIDMacros - * @brief There is a unique internal ID of type int64 for each vertex, - * and most importantly the internal ID has a range. - */ -#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX -///@} - -/** @name IndexPKMacros - * @brief Macros for pk indexing features - */ -///@{ -/** @ingroup IndexPKMacros - * @brief Enable vertex indexing on primary keys, meaning that - * users can get a vertex handle using its primary key(s) value(s). - */ -#define GRIN_ENABLE_VERTEX_PK_INDEX - -/** @ingroup IndexPKMacros - * @brief Enable edge indexing on primary keys, meaning that - * users can get an edge handle using its primary key(s) value(s). - */ -#define GRIN_ENABLE_EDGE_PK_INDEX -///@} - -/* End of Section 4 */ diff --git a/flex/engines/graph_db/grin/include/template/predefine.h b/flex/engines/graph_db/grin/include/template/predefine.h deleted file mode 100644 index 0a9e66ba433c..000000000000 --- a/flex/engines/graph_db/grin/include/template/predefine.h +++ /dev/null @@ -1,273 +0,0 @@ -/** Copyright 2020 Alibaba Group Holding Limited. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -/** - * @file predefine.h - * @brief This template file consists of four parts: - * 1. The predefined enumerate types of GRIN, which should NOT be modified. - * 2. The supported macros which should be specified by storage implementors - * based on storage features. - * 3. The typedefs of the enabled handles. This should be specified by storage. - * 4. The corresponding null values of the enabled handles. This should be - * specified by storage. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* 1. Predefined enumerate types of GRIN */ -/// Enumerates the directions of edges with respect to a certain vertex -typedef enum { - IN = 0, ///< incoming - OUT = 1, ///< outgoing - BOTH = 2, ///< incoming & outgoing -} GRIN_DIRECTION; - -/// Enumerates the datatype supported in the storage -typedef enum { - Undefined = 0, ///< other unknown types - Int32 = 1, ///< int - UInt32 = 2, ///< unsigned int - Int64 = 3, ///< long int - UInt64 = 4, ///< unsigned long int - Float = 5, ///< float - Double = 6, ///< double - String = 7, ///< string - Date32 = 8, ///< date - Time32 = 9, ///< Time32 - Timestamp64 = 10, ///< Timestamp -} GRIN_DATATYPE; - -/// Enumerates the error codes of grin -typedef enum { - NO_ERROR = 0, ///< success - UNKNOWN_ERROR = 1, ///< unknown error - INVALID_VALUE = 2, ///< invalid value - UNKNOWN_DATATYPE = 3, ///< unknown datatype -} GRIN_ERROR_CODE; - -/* 2. Define supported macros based on storage features */ -// Topology -#define GRIN_ASSUME_HAS_DIRECTED_GRAPH -#define GRIN_ASSUME_HAS_UNDIRECTED_GRAPH -#define GRIN_ASSUME_HAS_MULTI_EDGE_GRAPH -#define GRIN_WITH_VERTEX_DATA -#define GRIN_WITH_EDGE_DATA -#define GRIN_ENABLE_VERTEX_LIST -#define GRIN_ENABLE_VERTEX_LIST_ARRAY -#define GRIN_ENABLE_VERTEX_LIST_ITERATOR -#define GRIN_ENABLE_EDGE_LIST -#define GRIN_ENABLE_EDGE_LIST_ARRAY -#define GRIN_ENABLE_EDGE_LIST_ITERATOR -#define GRIN_ENABLE_ADJACENT_LIST -#define GRIN_ENABLE_ADJACENT_LIST_ARRAY -#define GRIN_ENABLE_ADJACENT_LIST_ITERATOR -// Partition -#define GRIN_ENABLE_GRAPH_PARTITION -#define GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -#define GRIN_ENABLE_VERTEX_REF -#define GRIN_TRAIT_FAST_VERTEX_REF -#define GRIN_ENABLE_EDGE_REF -#define GRIN_ASSUME_ALL_REPLICATE_PARTITION -#define GRIN_ASSUME_EDGE_CUT_PARTITION -#define GRIN_ASSUME_EDGE_CUT_FOLLOW_SRC_PARTITION -#define GRIN_ASSUME_EDGE_CUT_FOLLOW_DST_PARTITION -#define GRIN_ASSUME_VERTEX_CUT_PARTITION -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_DATA -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_DATA -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_DATA -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_DATA -#define GRIN_TRAIT_MASTER_VERTEX_MIRROR_PARTITION_LIST -#define GRIN_TRAIT_MIRROR_VERTEX_MIRROR_PARTITION_LIST -#define GRIN_TRAIT_MASTER_EDGE_MIRROR_PARTITION_LIST -#define GRIN_TRAIT_MIRROR_EDGE_MIRROR_PARTITION_LIST -#define GRIN_TRAIT_SELECT_MASTER_FOR_VERTEX_LIST -#define GRIN_TRAIT_SELECT_PARTITION_FOR_VERTEX_LIST -#define GRIN_TRAIT_SELECT_MASTER_FOR_EDGE_LIST -#define GRIN_TRAIT_SELECT_PARTITION_FOR_EDGE_LIST -#define GRIN_TRAIT_SELECT_MASTER_NEIGHBOR_FOR_ADJACENT_LIST -#define GRIN_TRAIT_SELECT_NEIGHBOR_PARTITION_FOR_ADJACENT_LIST -// Property -#define GRIN_ENABLE_ROW -#define GRIN_TRAIT_CONST_VALUE_PTR -#define GRIN_WITH_VERTEX_PROPERTY -#define GRIN_WITH_VERTEX_PROPERTY_NAME -#define GRIN_WITH_VERTEX_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -#define GRIN_ENABLE_VERTEX_PRIMARY_KEYS -#define GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY -#define GRIN_WITH_EDGE_PROPERTY_NAME -#define GRIN_WITH_EDGE_TYPE_NAME -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -#define GRIN_ENABLE_EDGE_PRIMARY_KEYS -#define GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -#define GRIN_TRAIT_SPECIFIC_VEV_RELATION -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_VERTEX_PROPERTY -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY -#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_VERTEX_PROPERTY -#define GRIN_ASSUME_MASTER_ONLY_PARTITION_FOR_EDGE_PROPERTY -#define GRIN_ASSUME_REPLICATE_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY -#define GRIN_ASSUME_SPLIT_MASTER_MIRROR_PARTITION_FOR_EDGE_PROPERTY -// Index -#define GRIN_WITH_VERTEX_LABEL -#define GRIN_WITH_EDGE_LABEL -#define GRIN_ASSUME_ALL_VERTEX_LIST_SORTED -#define GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX -#define GRIN_ENABLE_VERTEX_PK_INDEX -#define GRIN_ENABLE_EDGE_PK_INDEX - -/* 3. Define the handles using typedef */ -typedef void* GRIN_GRAPH; -typedef void* GRIN_VERTEX; -typedef void* GRIN_EDGE; - -#ifdef GRIN_WITH_VERTEX_DATA -typedef void* GRIN_VERTEX_DATA; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST -typedef void* GRIN_VERTEX_LIST; -#endif - -#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef void* GRIN_VERTEX_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST -typedef void* GRIN_ADJACENT_LIST; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -typedef void* GRIN_ADJACENT_LIST_ITERATOR; -#endif - -#ifdef GRIN_WITH_EDGE_DATA -typedef void* GRIN_EDGE_DATA; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST -typedef void* GRIN_EDGE_LIST; -#endif - -#ifdef GRIN_ENABLE_EDGE_LIST_ITERATOR -typedef void* GRIN_EDGE_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -typedef void* GRIN_PARTITIONED_GRAPH; -typedef void* GRIN_PARTITION; -typedef void* GRIN_PARTITION_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_PARTITION -typedef unsigned GRIN_PARTITION_ID; -#endif - -#ifdef GRIN_ENABLE_VERTEX_REF -typedef void* GRIN_VERTEX_REF; -#endif - -#ifdef GRIN_ENABLE_EDGE_REF -typedef void* GRIN_EDGE_REF; -#endif - - -#ifdef GRIN_WITH_VERTEX_PROPERTY -typedef void* GRIN_VERTEX_TYPE; -typedef void* GRIN_VERTEX_TYPE_LIST; -typedef void* GRIN_VERTEX_PROPERTY; -typedef void* GRIN_VERTEX_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -typedef unsigned GRIN_VERTEX_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY -typedef unsigned GRIN_VERTEX_PROPERTY_ID; -#endif - -#ifdef GRIN_WITH_EDGE_PROPERTY -typedef void* GRIN_EDGE_TYPE; -typedef void* GRIN_EDGE_TYPE_LIST; -typedef void* GRIN_VEV_TYPE; -typedef void* GRIN_VEV_TYPE_LIST; -typedef void* GRIN_EDGE_PROPERTY; -typedef void* GRIN_EDGE_PROPERTY_LIST; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE -typedef unsigned GRIN_EDGE_TYPE_ID; -#endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -typedef unsigned GRIN_EDGE_PROPERTY_ID; -#endif - -#ifdef GRIN_ENABLE_ROW -typedef void* GRIN_ROW; -#endif - -#if defined(GRIN_WITH_VERTEX_LABEL) || defined(GRIN_WITH_EDGE_LABEL) -typedef void* GRIN_LABEL; -typedef void* GRIN_LABEL_LIST; -#endif - -/* 4. Define invalid values for returns of handles */ -#define GRIN_NULL_GRAPH NULL -#define GRIN_NULL_VERTEX NULL -#define GRIN_NULL_EDGE NULL -#define GRIN_NULL_VERTEX_DATA NULL -#define GRIN_NULL_VERTEX_LIST NULL -#define GRIN_NULL_VERTEX_LIST_ITERATOR NULL -#define GRIN_NULL_ADJACENT_LIST NULL -#define GRIN_NULL_ADJACENT_LIST_ITERATOR NULL -#define GRIN_NULL_EDGE_DATA NULL -#define GRIN_NULL_EDGE_LIST NULL -#define GRIN_NULL_EDGE_LIST_ITERATOR NULL -#define GRIN_NULL_PARTITIONED_GRAPH NULL -#define GRIN_NULL_PARTITION NULL -#define GRIN_NULL_PARTITION_LIST NULL -#define GRIN_NULL_PARTITION_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_REF NULL -#define GRIN_NULL_EDGE_REF NULL -#define GRIN_NULL_VERTEX_TYPE NULL -#define GRIN_NULL_VERTEX_TYPE_LIST NULL -#define GRIN_NULL_VERTEX_PROPERTY NULL -#define GRIN_NULL_VERTEX_PROPERTY_LIST NULL -#define GRIN_NULL_VERTEX_TYPE_ID (unsigned)~0 -#define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_EDGE_TYPE NULL -#define GRIN_NULL_EDGE_TYPE_LIST NULL -#define GRIN_NULL_VEV_TYPE NULL -#define GRIN_NULL_VEV_TYPE_LIST NULL -#define GRIN_NULL_EDGE_PROPERTY NULL -#define GRIN_NULL_EDGE_PROPERTY_LIST NULL -#define GRIN_NULL_EDGE_TYPE_ID (unsigned)~0 -#define GRIN_NULL_EDGE_PROPERTY_ID (unsigned)~0 -#define GRIN_NULL_ROW NULL -#define GRIN_NULL_LABEL NULL -#define GRIN_NULL_LABEL_LIST NULL -#define GRIN_NULL_SIZE (unsigned)~0 -#define GRIN_NULL_NAME NULL - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/include/test/test.c b/flex/engines/graph_db/grin/include/test/test.c deleted file mode 100644 index af77a0917521..000000000000 --- a/flex/engines/graph_db/grin/include/test/test.c +++ /dev/null @@ -1,1052 +0,0 @@ -#include -#include -#include -#include -#include "predefine.h" -#include "common/error.h" -#include "index/internal_id.h" -#include "index/label.h" -#include "index/order.h" -#include "index/pk.h" -#include "partition/partition.h" -#include "partition/reference.h" -#include "partition/topology.h" -#include "property/partition.h" -#include "property/primarykey.h" -#include "property/property.h" -#include "property/propertylist.h" -#include "property/row.h" -#include "property/topology.h" -#include "property/type.h" -#include "topology/adjacentlist.h" -#include "topology/edgelist.h" -#include "topology/structure.h" -#include "topology/vertexlist.h" - - -#define FOR_VERTEX_BEGIN(g, vl, v) \ - GRIN_VERTEX_LIST_ITERATOR __vli = grin_get_vertex_list_begin(g, vl); \ - unsigned __vcnt = 0; \ - while (!grin_is_vertex_list_end(g, __vli)) { \ - GRIN_VERTEX v = grin_get_vertex_from_iter(g, __vli); \ - -#ifdef GRIN_WITH_VERTEX_PROPERTY -#define FOR_VERTEX_END(g, vl, v) \ - grin_destroy_vertex(g, v); \ - __vcnt++; \ - grin_get_next_vertex_list_iter(g, __vli); \ - } \ - printf("vertex type %s, checked: %u\n", vt_names[__vtl_i], __vcnt); - -#define FOR_VERTEX_LIST_BEGIN(g, vl) \ -{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ - size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ - for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ - GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, __vt); \ - grin_destroy_vertex_type(g, __vt); - -#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ -{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ - size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ - for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ - GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, __vt); \ - grin_destroy_vertex_type(g, __vt); - -#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ -{ GRIN_VERTEX_TYPE_LIST __vtl = grin_get_vertex_type_list(g); \ - size_t __vtl_sz = grin_get_vertex_type_list_size(g, __vtl); \ - for (size_t __vtl_i = 0; __vtl_i < __vtl_sz; ++__vtl_i) { \ - GRIN_VERTEX_TYPE __vt = grin_get_vertex_type_from_list(g, __vtl, __vtl_i); \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_mirror(g, __vt); \ - grin_destroy_vertex_type(g, __vt); - -#define FOR_VERTEX_LIST_END(g, vl) \ - grin_destroy_vertex_list(g, vl); \ - } \ - grin_destroy_vertex_type_list(g, __vtl);} -#else -#define FOR_VERTEX_END(g, vl) \ - grin_destroy_vertex(g, v); \ - __vcnt++; \ - grin_get_next_vertex_list_iter(g, __vli); \ - } \ - printf("vertex checked: %u\n", __vcnt); - -#define FOR_VERTEX_LIST_BEGIN(g, vl) \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list(g); - -#define FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_master(g); - -#define FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) \ - GRIN_VERTEX_LIST vl = grin_get_vertex_list_select_mirror(g); - -#define FOR_VERTEX_LIST_END(g, vl) \ - grin_destroy_vertex_list(g, vl); -#endif - - - -#ifdef GRIN_WITH_EDGE_PROPERTY -#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ -{ GRIN_EDGE_TYPE_LIST __etl = grin_get_edge_type_list(g); \ - size_t __etl_size = grin_get_edge_type_list_size(g, __etl); \ - for (size_t __etl_i = 0; __etl_i < __etl_size; ++__etl_i) { \ - GRIN_EDGE_TYPE __et = grin_get_edge_type_from_list(g, __etl, __etl_i); \ - GRIN_ADJACENT_LIST al = grin_get_adjacent_list_by_edge_type(g, dir, v, __et); \ - grin_destroy_edge_type(g, __et); -#define FOR_ADJ_LIST_END(g, al) \ - grin_destroy_adjacent_list(g, al); \ - } \ - grin_destroy_edge_type_list(g, __etl);} -#else -#define FOR_ADJ_LIST_BEGIN(g, dir, v, al) \ - GRIN_ADJACENT_LIST al = grin_get_adjacent_list(g, dir, v); -#define FOR_ADJ_LIST_END(g, al) \ - grin_destroy_adjacent_list(g, al); -#endif - - -const char *vt_names[] = {"person", "software"}; -const char *et_names[] = {"created", "knows"}; - -const char *v_names[][4] = { - {"josh", "vadas", "peter", "marko"}, - {"lop", "ripple", "wrong", "wrong"} -}; // TODO align with order in local graph - -GRIN_GRAPH get_graph(int argc, char** argv, int p) { -#ifdef GRIN_ENABLE_GRAPH_PARTITION - GRIN_PARTITIONED_GRAPH pg = - grin_get_partitioned_graph_from_storage(argv[1]); - GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); - assert(p < grin_get_partition_list_size(pg, local_partitions)); - GRIN_PARTITION partition = - grin_get_partition_from_list(pg, local_partitions, p); - GRIN_PARTITION_ID partition_id = grin_get_partition_id(pg, partition); - GRIN_PARTITION p1 = grin_get_partition_by_id(pg, partition_id); - if (!grin_equal_partition(pg, partition, p1)) { - printf("partition not match\n"); - } - grin_destroy_partition(pg, p1); - GRIN_GRAPH g = grin_get_local_graph_by_partition(pg, partition); - grin_destroy_partition(pg, partition); - grin_destroy_partition_list(pg, local_partitions); - grin_destroy_partitioned_graph(pg); -#else - GRIN_GRAPH g = grin_get_graph_from_storage(argv[1]); -#endif - return g; -} - - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -GRIN_VERTEX get_one_master_person(GRIN_GRAPH g) { - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type_select_master(g, vt); - grin_destroy_vertex_type(g, vt); - GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin(g, vl); - GRIN_VERTEX v = grin_get_vertex_from_iter(g, vli); - grin_destroy_vertex_list_iter(g, vli); - grin_destroy_vertex_list(g, vl); -#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); -#endif - return v; -} -#endif - - -GRIN_VERTEX get_one_person(GRIN_GRAPH g) { - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); - GRIN_VERTEX_LIST vl = grin_get_vertex_list_by_type(g, vt); - grin_destroy_vertex_type(g, vt); - GRIN_VERTEX_LIST_ITERATOR vli = grin_get_vertex_list_begin(g, vl); - GRIN_VERTEX v = grin_get_vertex_from_iter(g, vli); - grin_destroy_vertex_list_iter(g, vli); - grin_destroy_vertex_list(g, vl); -#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - printf("Got vertex %s\n", v_names[vt][grin_get_vertex_internal_id_by_type(g, vt, v)]); -#endif - return v; -} - - -void test_property_type(int argc, char** argv) { - printf("+++++++++++++++++++++ Test property/type +++++++++++++++++++++\n"); - - GRIN_GRAPH g = get_graph(argc, argv, 0); - - printf("------------ Vertex Type ------------\n"); - GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); - size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); - printf("vertex type list size: %zu\n", vtl_size); - - for (size_t i = 0; i < vtl_size; ++i) { - printf("------------ Iterate the %zu-th vertex type ------------\n", i); - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); -#ifdef GRIN_WITH_VERTEX_TYPE_NAME - const char* vt_name = grin_get_vertex_type_name(g, vt); - printf("vertex type name: %s\n", vt_name); - GRIN_VERTEX_TYPE vt0 = grin_get_vertex_type_by_name(g, vt_name); - if (!grin_equal_vertex_type(g, vt, vt0)) { - printf("vertex type name not match\n"); - } - grin_destroy_vertex_type(g, vt0); -#endif -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE - printf("vertex type id: %u\n", grin_get_vertex_type_id(g, vt)); - GRIN_VERTEX_TYPE vt1 = - grin_get_vertex_type_by_id(g, grin_get_vertex_type_id(g, vt)); - if (!grin_equal_vertex_type(g, vt, vt1)) { - printf("vertex type id not match\n"); - } - grin_destroy_vertex_type(g, vt1); -#endif - } - grin_destroy_vertex_type_list(g, vtl); - - printf( - "------------ Create a vertex type list of one type \"person\" " - "------------\n"); - GRIN_VERTEX_TYPE_LIST vtl2 = grin_create_vertex_type_list(g); -#ifdef GRIN_WITH_VERTEX_TYPE_NAME - GRIN_VERTEX_TYPE vt2_w = grin_get_vertex_type_by_name(g, "knows"); - if (vt2_w == GRIN_NULL_VERTEX_TYPE) { - printf("(Correct) vertex type of knows does not exists\n"); - } - GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "person"); - if (vt2 == GRIN_NULL_VERTEX_TYPE) { - printf("(Wrong) vertex type of person can not be found\n"); - } else { - const char* vt2_name = grin_get_vertex_type_name(g, vt2); - printf("vertex type name: %s\n", vt2_name); - } -#else - GRIN_VERTEX_TYPE vt2 = get_one_vertex_type(g); -#endif - grin_insert_vertex_type_to_list(g, vtl2, vt2); - size_t vtl2_size = grin_get_vertex_type_list_size(g, vtl2); - printf("created vertex type list size: %zu\n", vtl2_size); - GRIN_VERTEX_TYPE vt3 = grin_get_vertex_type_from_list(g, vtl2, 0); - if (!grin_equal_vertex_type(g, vt2, vt3)) { - printf("vertex type not match\n"); - } - grin_destroy_vertex_type(g, vt2); - grin_destroy_vertex_type(g, vt3); - grin_destroy_vertex_type_list(g, vtl2); - - // edge - printf("------------ Edge Type ------------\n"); - GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); - size_t etl_size = grin_get_edge_type_list_size(g, etl); - printf("edge type list size: %zu\n", etl_size); - - for (size_t i = 0; i < etl_size; ++i) { - printf("------------ Iterate the %zu-th edge type ------------\n", i); - GRIN_EDGE_TYPE et = grin_get_edge_type_from_list(g, etl, i); -#ifdef GRIN_WITH_EDGE_TYPE_NAME - const char* et_name = grin_get_edge_type_name(g, et); - printf("edge type name: %s\n", et_name); - GRIN_EDGE_TYPE et0 = grin_get_edge_type_by_name(g, et_name); - if (!grin_equal_edge_type(g, et, et0)) { - printf("edge type name not match\n"); - } - grin_destroy_edge_type(g, et0); -#endif -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_TYPE - printf("edge type id: %u\n", grin_get_edge_type_id(g, et)); - GRIN_EDGE_TYPE et1 = - grin_get_edge_type_by_id(g, grin_get_edge_type_id(g, et)); - if (!grin_equal_edge_type(g, et, et1)) { - printf("edge type id not match\n"); - } - grin_destroy_edge_type(g, et1); -#endif - // relation - GRIN_VERTEX_TYPE_LIST src_vtl = grin_get_src_types_by_edge_type(g, et); - size_t src_vtl_size = grin_get_vertex_type_list_size(g, src_vtl); - printf("source vertex type list size: %zu\n", src_vtl_size); - - GRIN_VERTEX_TYPE_LIST dst_vtl = grin_get_dst_types_by_edge_type(g, et); - size_t dst_vtl_size = grin_get_vertex_type_list_size(g, dst_vtl); - printf("destination vertex type list size: %zu\n", dst_vtl_size); - - if (src_vtl_size != dst_vtl_size) { - printf("source and destination vertex type list size not match\n"); - } - for (size_t j = 0; j < src_vtl_size; ++j) { - GRIN_VERTEX_TYPE src_vt = grin_get_vertex_type_from_list(g, src_vtl, j); - GRIN_VERTEX_TYPE dst_vt = grin_get_vertex_type_from_list(g, dst_vtl, j); - const char* src_vt_name = grin_get_vertex_type_name(g, src_vt); - const char* dst_vt_name = grin_get_vertex_type_name(g, dst_vt); - const char* et_name = grin_get_edge_type_name(g, et); - printf("edge type name: %s-%s-%s\n", src_vt_name, et_name, dst_vt_name); - grin_destroy_vertex_type(g, src_vt); - grin_destroy_vertex_type(g, dst_vt); - } - grin_destroy_vertex_type_list(g, src_vtl); - grin_destroy_vertex_type_list(g, dst_vtl); - } - grin_destroy_edge_type_list(g, etl); - - printf( - "------------ Create an edge type list of one type \"created\" " - "------------\n"); - GRIN_EDGE_TYPE_LIST etl2 = grin_create_edge_type_list(g); -#ifdef GRIN_WITH_EDGE_TYPE_NAME - GRIN_EDGE_TYPE et2_w = grin_get_edge_type_by_name(g, "person"); - if (et2_w == GRIN_NULL_EDGE_TYPE) { - printf("(Correct) edge type of person does not exists\n"); - } - GRIN_EDGE_TYPE et2 = grin_get_edge_type_by_name(g, "created"); - if (et2 == GRIN_NULL_EDGE_TYPE) { - printf("(Wrong) edge type of created can not be found\n"); - } else { - const char* et2_name = grin_get_edge_type_name(g, et2); - printf("edge type name: %s\n", et2_name); - } -#else - GRIN_EDGE_TYPE et2 = get_one_edge_type(g); -#endif - grin_insert_edge_type_to_list(g, etl2, et2); - size_t etl2_size = grin_get_edge_type_list_size(g, etl2); - printf("created edge type list size: %zu\n", etl2_size); - GRIN_EDGE_TYPE et3 = grin_get_edge_type_from_list(g, etl2, 0); - if (!grin_equal_edge_type(g, et2, et3)) { - printf("edge type not match\n"); - } - grin_destroy_edge_type(g, et2); - grin_destroy_edge_type(g, et3); - grin_destroy_edge_type_list(g, etl2); - - grin_destroy_graph(g); -} - -void test_property_vertex_property_value(int argc, char** argv) { - printf("------------ Test Vertex property value ------------\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - -// value check - printf("------ check value ------\n"); -FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) - GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, __vt); - size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); - FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); - #else - long long int vid = __vcnt; - #endif - #ifdef GRIN_ENABLE_ROW - GRIN_ROW row = grin_get_vertex_row(g, v); - #endif - for (size_t j = 0; j < vpl_size; ++j) { - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); - GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); - if (dt == Int64) { - long long int pv = - grin_get_vertex_property_value_of_int64(g, v, vp); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - long long int rv = grin_get_int64_from_row(g, row, j); - assert(pv == rv); - #endif - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - printf("%s %s: %lld\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); - #else - printf("%s %zu: %lld\n", v_names[__vt][vid], j, pv); - #endif - } else if (dt == String) { - const char* pv = - grin_get_vertex_property_value_of_string(g, v, vp); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - const char* rv = grin_get_string_from_row(g, row, j); - assert(strcmp(pv, rv) == 0); - #endif - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - printf("%s %s: %s\n", v_names[__vt][vid], grin_get_vertex_property_name(g, __vt, vp), pv); - #else - printf("%s %zu: %s\n", v_names[__vt][vid], j, pv); - #endif - grin_destroy_string_value(g, pv); - grin_destroy_string_value(g, rv); - } - grin_destroy_vertex_property(g, vp); - } - #ifdef GRIN_ENABLE_ROW - grin_destroy_row(g, row); - #endif - FOR_VERTEX_END(g, vl, v) - grin_destroy_vertex_property_list(g, vpl); -FOR_VERTEX_LIST_END(g, vl) - -// check schema - printf("------ check schema ------\n"); - GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_type_list(g); - size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); - for (size_t i = 0; i < vtl_size; ++i) { - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); - GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_vertex_property_list_by_type(g, vt); - size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); - for (size_t j = 0; j < vpl_size; ++j) { - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); - GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_from_property(g, vp); - assert(grin_equal_vertex_type(g, vt, vt1)); - grin_destroy_vertex_type(g, vt1); - - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY - unsigned int id = grin_get_vertex_property_id(g, vt, vp); - GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id); - assert(grin_equal_vertex_property(g, vp, vp1)); - grin_destroy_vertex_property(g, vp1); - #else - unsigned int id = i; - #endif - - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - const char* vp_name = grin_get_vertex_property_name(g, vt, vp); - GRIN_VERTEX_PROPERTY vp2 = - grin_get_vertex_property_by_name(g, vt, vp_name); - assert(grin_equal_vertex_property(g, vp, vp2)); - #else - const char* vp_name = "unknown"; - #endif - printf("%s %u %s checked\n", vt_names[i], id, vp_name); - } - grin_destroy_vertex_property_list(g, vpl); - - // corner case - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY - GRIN_VERTEX_PROPERTY vp3 = grin_get_vertex_property_by_id(g, vt, vpl_size); - assert(vp3 == GRIN_NULL_VERTEX_PROPERTY); - #endif - - #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - GRIN_VERTEX_PROPERTY vp4 = - grin_get_vertex_property_by_name(g, vt, "unknown"); - assert(vp4 == GRIN_NULL_VERTEX_PROPERTY); - #endif - grin_destroy_vertex_type(g, vt); - } - grin_destroy_vertex_type_list(g, vtl); - - // corner case -#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - GRIN_VERTEX_PROPERTY_LIST vpl1 = - grin_get_vertex_properties_by_name(g, "unknown"); - assert(vpl1 == GRIN_NULL_VERTEX_PROPERTY_LIST); - - GRIN_VERTEX_PROPERTY_LIST vpl2 = - grin_get_vertex_properties_by_name(g, "name"); - assert(vpl2 != GRIN_NULL_VERTEX_PROPERTY_LIST); - - size_t vpl2_size = grin_get_vertex_property_list_size(g, vpl2); - for (size_t i = 0; i < vpl2_size; ++i) { - GRIN_VERTEX_PROPERTY vp5 = - grin_get_vertex_property_from_list(g, vpl2, i); - GRIN_VERTEX_TYPE vt5 = grin_get_vertex_type_from_property(g, vp5); - const char* vp5_name = grin_get_vertex_property_name(g, vt5, vp5); - assert(strcmp(vp5_name, "name") == 0); - } - grin_destroy_vertex_property_list(g, vpl2); -#endif - - grin_destroy_graph(g); -} - -void test_property_edge_property_value(int argc, char** argv, GRIN_DIRECTION dir) { - printf("------------ Test Edge property value ------------\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - -// value check - printf("------ check value ------\n"); -FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) - FOR_VERTEX_BEGIN(g, vl, v) - FOR_ADJ_LIST_BEGIN(g, dir, v, al) - GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, __et); - size_t epl_size = grin_get_edge_property_list_size(g, epl); - - GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); - size_t acnt = 0; - while (!grin_is_adjacent_list_end(g, ali)) { - GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); - GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); - #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - GRIN_VERTEX_TYPE ut = grin_get_vertex_type(g, u); - long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); - long long int uid = grin_get_vertex_internal_id_by_type(g, ut, u); - grin_destroy_vertex_type(g, ut); - #else - long long int vid = __vcnt; - long long int uid = acnt; - #endif - #ifdef GRIN_ENABLE_ROW - GRIN_ROW row = grin_get_edge_row(g, e); - #endif - for (size_t j = 0; j < epl_size; ++j) { - GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); - GRIN_DATATYPE dt = grin_get_edge_property_datatype(g, ep); - if (dt == Int64) { - long long int pv = - grin_get_edge_property_value_of_int64(g, e, ep); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - long long int rv = grin_get_int64_from_row(g, row, j); - assert(pv == rv); - #endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - printf("%s %s %s: %lld\n", v_names[__vt][vid], v_names[ut][uid], - grin_get_edge_property_name(g, __et, ep), pv); - #else - printf("%s %zu %lld: %lld\n", v_names[__vt][vid], j, uid, pv); - #endif - } else if (dt == Double) { - double pv = grin_get_edge_property_value_of_double(g, e, ep); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - double rv = grin_get_double_from_row(g, row, j); - assert(pv == rv); - #endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - printf("%s %s %s: %lf\n", v_names[__vt][vid], v_names[ut][uid], - grin_get_edge_property_name(g, __et, ep), pv); - #else - printf("%s %zu %lld: %lf\n", v_names[__vt][vid], j, uid, pv); - #endif - } else if (dt == String) { - const char* pv = grin_get_edge_property_value_of_string(g, e, ep); - assert(grin_get_last_error_code() == NO_ERROR); - #ifdef GRIN_ENABLE_ROW - const char* rv = grin_get_string_from_row(g, row, j); - assert(strcmp(pv, rv) == 0); - #endif - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - printf("%s %s %s: %s\n", v_names[__vt][vid], v_names[ut][uid], - grin_get_edge_property_name(g, __et, ep), pv); - #else - printf("%s %zu %lld: %s\n", v_names[__vt][vid], j, uid, pv); - #endif - } - } - #ifdef GRIN_ENABLE_ROW - grin_destroy_row(g, row); - #endif - grin_destroy_edge(g, e); - grin_destroy_vertex(g, u); - acnt++; - grin_get_next_adjacent_list_iter(g, ali); - } - grin_destroy_adjacent_list_iter(g, ali); - grin_destroy_edge_property_list(g, epl); - FOR_ADJ_LIST_END(g, al) - FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) - -// check schema - printf("------ check schema ------\n"); - GRIN_EDGE_TYPE_LIST etl = grin_get_edge_type_list(g); - size_t etl_size = grin_get_edge_type_list_size(g, etl); - for (size_t i = 0; i < etl_size; ++i) { - GRIN_EDGE_TYPE et = grin_get_edge_type_from_list(g, etl, i); - GRIN_EDGE_PROPERTY_LIST epl = grin_get_edge_property_list_by_type(g, et); - size_t epl_size = grin_get_edge_property_list_size(g, epl); - for (size_t j = 0; j < epl_size; ++j) { - GRIN_EDGE_PROPERTY ep = grin_get_edge_property_from_list(g, epl, j); - GRIN_EDGE_TYPE et1 = grin_get_edge_type_from_property(g, ep); - assert(grin_equal_edge_type(g, et, et1)); - grin_destroy_edge_type(g, et1); - - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY - unsigned int id = grin_get_edge_property_id(g, et, ep); - GRIN_EDGE_PROPERTY ep1 = grin_get_edge_property_by_id(g, et, id); - assert(grin_equal_edge_property(g, ep, ep1)); - grin_destroy_edge_property(g, ep1); - #else - unsigned int id = i; - #endif - - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - const char* ep_name = grin_get_edge_property_name(g, et, ep); - GRIN_EDGE_PROPERTY ep2 = - grin_get_edge_property_by_name(g, et, ep_name); - assert(grin_equal_edge_property(g, ep, ep2)); - #else - const char* ep_name = "unknown"; - #endif - printf("%s %u %s checked\n", et_names[i], id, ep_name); - } - grin_destroy_edge_property_list(g, epl); - - // corner case - #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY - GRIN_EDGE_PROPERTY ep3 = grin_get_edge_property_by_id(g, et, epl_size); - assert(ep3 == GRIN_NULL_EDGE_PROPERTY); - #endif - - #ifdef GRIN_WITH_EDGE_PROPERTY_NAME - GRIN_EDGE_PROPERTY ep4 = - grin_get_edge_property_by_name(g, et, "unknown"); - assert(ep4 == GRIN_NULL_EDGE_PROPERTY); - #endif - grin_destroy_edge_type(g, et); - } - grin_destroy_edge_type_list(g, etl); - - // corner case -#ifdef GRIN_WITH_EDGE_PROPERTY_NAME - GRIN_EDGE_PROPERTY_LIST epl1 = - grin_get_edge_properties_by_name(g, "unknown"); - assert(epl1 == GRIN_NULL_EDGE_PROPERTY_LIST); - - GRIN_EDGE_PROPERTY_LIST epl2 = - grin_get_edge_properties_by_name(g, "weight"); - assert(epl2 != GRIN_NULL_EDGE_PROPERTY_LIST); - - size_t epl2_size = grin_get_edge_property_list_size(g, epl2); - for (size_t i = 0; i < epl2_size; ++i) { - GRIN_EDGE_PROPERTY ep5 = - grin_get_edge_property_from_list(g, epl2, i); - GRIN_EDGE_TYPE et5 = grin_get_edge_type_from_property(g, ep5); - const char* ep5_name = grin_get_edge_property_name(g, et5, ep5); - assert(strcmp(ep5_name, "weight") == 0); - } - grin_destroy_edge_property_list(g, epl2); -#endif - - grin_destroy_graph(g); -} - - -#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS -void test_property_primary_key(int argc, char** argv) { - printf( - "+++++++++++++++++++++ Test property/primary key " - "+++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - GRIN_VERTEX_TYPE_LIST vtl = grin_get_vertex_types_with_primary_keys(g); - size_t vtl_size = grin_get_vertex_type_list_size(g, vtl); - printf("vertex type num with primary key: %zu\n", vtl_size); - - unsigned id_type[7] = {~0, 0, 0, 1, 0, 1, 0}; - - for (size_t i = 0; i < vtl_size; ++i) { - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_from_list(g, vtl, i); - const char* vt_name = grin_get_vertex_type_name(g, vt); - printf("vertex type name: %s\n", vt_name); - - GRIN_VERTEX_PROPERTY_LIST vpl = grin_get_primary_keys_by_vertex_type(g, vt); - size_t vpl_size = grin_get_vertex_property_list_size(g, vpl); - assert(vpl_size == 1); - - for (size_t j = 0; j < vpl_size; ++j) { - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, j); - const char* vp_name = grin_get_vertex_property_name(g, vt, vp); - printf("primary key name: %s\n", vp_name); - grin_destroy_vertex_property(g, vp); - } - - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_from_list(g, vpl, 0); - GRIN_DATATYPE dt = grin_get_vertex_property_datatype(g, vp); - - for (size_t j = 1; j <= 6; ++j) { - GRIN_ROW r = grin_create_row(g); - assert(dt == Int64); - grin_insert_int64_to_row(g, r, j); -#ifdef GRIN_ENABLE_VERTEX_PK_INDEX - GRIN_VERTEX v = grin_get_vertex_by_primary_keys_row(g, vt, r); - if (v != GRIN_NULL_VERTEX && id_type[j] == i) { - GRIN_ROW nr = grin_get_vertex_primary_keys_row(g, v); - long long int k = grin_get_int64_from_row(g, nr, 0); - assert(k == j); - grin_destroy_row(g, nr); - grin_destroy_vertex(g, v); - } -#endif - grin_destroy_row(g, r); - } - - grin_destroy_vertex_property(g, vp); - grin_destroy_vertex_property_list(g, vpl); - grin_destroy_vertex_type(g, vt); - } - - grin_destroy_vertex_type_list(g, vtl); - grin_destroy_graph(g); -} -#endif - -void test_error_code(int argc, char** argv) { - printf("+++++++++++++++++++++ Test error code +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - - GRIN_VERTEX_TYPE vt1 = grin_get_vertex_type_by_name(g, "person"); - GRIN_VERTEX_TYPE vt2 = grin_get_vertex_type_by_name(g, "software"); - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt2, "lang"); -#ifdef GRIN_ENABLE_GRAPH_PARTITION - GRIN_VERTEX v = get_one_master_person(g); -#else - GRIN_VERTEX v = get_one_person(g); -#endif - - const char* value = grin_get_vertex_property_value_of_string(g, v, vp); - assert(grin_get_last_error_code() == INVALID_VALUE); -} - - -void test_property(int argc, char** argv) { - test_property_type(argc, argv); - test_property_vertex_property_value(argc, argv); - test_property_edge_property_value(argc, argv, OUT); - test_property_edge_property_value(argc, argv, IN); -#ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS - test_property_primary_key(argc, argv); -#endif -#ifdef GRIN_WITH_VERTEX_PROPERTY_NAME - // test_error_code(argc, argv); -#endif -} - - -void test_partition_reference(int argc, char** argv) { - printf("+++++++++++++++++++++ Test partition/reference +++++++++++++++++++++\n"); - GRIN_PARTITIONED_GRAPH pg = grin_get_partitioned_graph_from_storage(argv[1]); - GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); - assert(grin_get_partition_list_size(pg, local_partitions) >= 2); - - GRIN_PARTITION p0 = grin_get_partition_from_list(pg, local_partitions, 0); - GRIN_PARTITION p1 = grin_get_partition_from_list(pg, local_partitions, 1); - GRIN_GRAPH g0 = grin_get_local_graph_by_partition(pg, p0); - GRIN_GRAPH g1 = grin_get_local_graph_by_partition(pg, p1); - -FOR_VERTEX_LIST_BEGIN(g0, vl0) - size_t mcnt = 0; - FOR_VERTEX_BEGIN(g0, vl0, v0) - GRIN_VERTEX_REF vref0 = grin_get_vertex_ref_by_vertex(g0, v0); - if (grin_is_master_vertex(g0, v0)) { - mcnt++; -#ifdef GRIN_TRAIT_FAST_VERTEX_REF - long long int sref = grin_serialize_vertex_ref_as_int64(g0, vref0); - GRIN_VERTEX_REF vref1 = grin_deserialize_int64_to_vertex_ref(g0, sref); -#else - const char* sref = grin_serialize_vertex_ref(g0, vref0); - GRIN_VERTEX_REF vref1 = grin_deserialize_vertex_ref(g0, sref); - grin_destroy_string_value(g0, sref); -#endif - GRIN_VERTEX v1 = grin_get_vertex_from_vertex_ref(g0, vref1); - if (!grin_equal_vertex(g0, v0, v1)) { - printf("vertex not match after deserialize\n"); - } - GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); - if (!grin_equal_partition(g0, p, p0)) { - printf("(Wrong) partition not match in vertex ref\n"); - } - grin_destroy_partition(pg, p); - grin_destroy_vertex(g0, v1); - grin_destroy_vertex_ref(g0, vref1); - } else if (grin_is_mirror_vertex(g0, v0)) { -#ifdef GRIN_TRAIT_FAST_VERTEX_REF - long long int sref = grin_serialize_vertex_ref_as_int64(g0, vref0); - GRIN_VERTEX_REF vref1 = grin_deserialize_int64_to_vertex_ref(g1, sref); -#else - const char* sref = grin_serialize_vertex_ref(g0, vref0); - GRIN_VERTEX_REF vref1 = grin_deserialize_vertex_ref(g1, sref); - grin_destroy_string_value(g0, sref); -#endif - GRIN_VERTEX v1 = grin_get_vertex_from_vertex_ref(g1, vref1); - if (!grin_is_master_vertex(g1, v1)) { - printf("(Wrong) vertex not master after deserialize\n"); - } - GRIN_PARTITION p = grin_get_master_partition_from_vertex_ref(g0, vref0); - if (!grin_equal_partition(g0, p, p1)) { - printf("(Wrong) partition not match in vertex ref\n"); - } - grin_destroy_partition(pg, p); - grin_destroy_vertex(g1, v1); - grin_destroy_vertex_ref(g1, vref1); - } else { - printf("(Wrong) vertex other than master or mirror\n"); - } - grin_destroy_vertex_ref(g0, vref0); - FOR_VERTEX_END(g0, vl0, v0) - printf("master checked: %zu\n", mcnt); -FOR_VERTEX_LIST_END(g0, vl0) - - grin_destroy_partition(pg, p0); - grin_destroy_partition(pg, p1); - grin_destroy_graph(g0); - grin_destroy_graph(g1); - grin_destroy_partition_list(pg, local_partitions); - grin_destroy_partitioned_graph(pg); -} - - -void test_partition_topology(int argc, char** argv) { - printf("+++++++++++++++++++++ Test partition/topology +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - - printf("----- check master ----- \n"); -FOR_VERTEX_LIST_SELECT_MASTER_BEGIN(g, vl) - FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - #endif - assert(grin_is_master_vertex(g, v)); - FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) - - printf("----- check mirror ----- \n"); -FOR_VERTEX_LIST_SELECT_MIRROR_BEGIN(g, vl) - FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - #endif - assert(grin_is_mirror_vertex(g, v)); - FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) - - grin_destroy_graph(g); -} - -void test_partition(int argc, char** argv) { -#ifdef GRIN_ENABLE_GRAPH_PARTITION - test_partition_reference(argc, argv); - test_partition_topology(argc, argv); -#endif -} - - -void test_topology_structure(int argc, char** argv) { - printf("+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); -#ifndef GRIN_WITH_VERTEX_PROPERTY - printf("vertex num: %zu\n", grin_get_vertex_num(g)); -#endif - -#ifndef GRIN_WITH_EDGE_PROPERTY - printf("edge num: %zu\n", grin_get_edge_num(g)); -#endif - grin_destroy_graph(g); -} - - -void test_topology_vertex_list(int argc, char** argv) { - printf("+++++++++++++++++++++ Test topology/vertex_list +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - -FOR_VERTEX_LIST_BEGIN(g, vl) - FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_LIST_ARRAY - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, __vcnt); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - #endif - FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) - - grin_destroy_graph(g); -} - - -void test_topology_adjacent_list(int argc, char** argv, GRIN_DIRECTION dir) { - if (dir == IN) { - printf("+++++++++++++++++++++ Test topology/adjacent_list IN +++++++++++++++++++++\n"); - } else { - printf("+++++++++++++++++++++ Test topology/adjacent_list OUT +++++++++++++++++++++\n"); - } - - GRIN_GRAPH g = get_graph(argc, argv, 0); - -FOR_VERTEX_LIST_BEGIN(g, vl) - FOR_VERTEX_BEGIN(g, vl, v) - #ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - long long int vid = grin_get_vertex_internal_id_by_type(g, __vt, v); - #else - long long int vid = __vcnt; - #endif - #ifdef GRIN_ENABLE_GRAPH_PARTITION - if (!grin_is_master_vertex(g, v)) { - grin_destroy_vertex(g, v); - grin_get_next_vertex_list_iter(g, __vli); - continue; - } - #endif - - FOR_ADJ_LIST_BEGIN(g, dir, v, al) - GRIN_ADJACENT_LIST_ITERATOR ali = grin_get_adjacent_list_begin(g, al); - size_t acnt = 0; - while (!grin_is_adjacent_list_end(g, ali)) { - GRIN_EDGE e = grin_get_edge_from_adjacent_list_iter(g, ali); - GRIN_VERTEX v1 = grin_get_src_vertex_from_edge(g, e); - GRIN_VERTEX v2 = grin_get_dst_vertex_from_edge(g, e); - GRIN_VERTEX u = grin_get_neighbor_from_adjacent_list_iter(g, ali); - - #ifdef GRIN_ENABLE_ADJACENT_LIST_ARRAY - GRIN_EDGE e1 = grin_get_edge_from_adjacent_list(g, al, acnt); - GRIN_VERTEX e1v1 = grin_get_src_vertex_from_edge(g, e1); - GRIN_VERTEX e1v2 = grin_get_dst_vertex_from_edge(g, e1); - assert(grin_equal_vertex(g, v1, e1v1)); - assert(grin_equal_vertex(g, v2, e1v2)); - grin_destroy_edge(g, e1); - grin_destroy_vertex(g, e1v1); - grin_destroy_vertex(g, e1v2); - #endif - - if (dir == OUT) { - assert(grin_equal_vertex(g, v, v1)); - assert(grin_equal_vertex(g, v2, u)); - } else { - assert(grin_equal_vertex(g, v, v2)); - assert(grin_equal_vertex(g, v1, u)); - } - - grin_destroy_vertex(g, v1); - grin_destroy_vertex(g, v2); - grin_destroy_vertex(g, u); - grin_destroy_edge(g, e); - - acnt++; - grin_get_next_adjacent_list_iter(g, ali); - } - #ifdef GRIN_ENABLE_ADJAECENT_LIST_ARRAY - assert(acnt == grin_get_adjacent_list_size(g, al)); - #endif - grin_destroy_adjacent_list_iter(g, ali); - #ifdef GRIN_WITH_EDGE_PROPERTY - printf("vertex %s adjlist, edgetype: %s, checked num: %zu\n", v_names[__vt][vid], et_names[__etl_i], acnt); - #else - printf("vertex %s adjlist, checked num: %zu\n", v_names[__vt][vid], acnt); - #endif - FOR_ADJ_LIST_END(g, al) - FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) - grin_destroy_graph(g); -} - - -void test_topology(int argc, char** argv) { - test_topology_structure(argc, argv); - test_topology_vertex_list(argc, argv); - test_topology_adjacent_list(argc, argv, OUT); - test_topology_adjacent_list(argc, argv, IN); -} - -#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) -void test_index_order(int argc, char** argv) { - printf("+++++++++++++++++++++ Test index order +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - -FOR_VERTEX_LIST_BEGIN(g, vl) - FOR_VERTEX_BEGIN(g, vl, v) - size_t pos = grin_get_position_of_vertex_from_sorted_list(g, vl, v); - assert(pos == __vcnt); - FOR_VERTEX_END(g, vl, v) - -#ifdef GRIN_ENABLE_GRAPH_PARTITION -{ - GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_master(g, __vt); - size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); - for (size_t i = 0; i < mvlist_sz; ++i) { - GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); - size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); - assert(pos == i); - size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - grin_destroy_vertex(g, v); - } - grin_destroy_vertex_list(g, mvlist); -} -{ - GRIN_VERTEX_LIST mvlist = grin_get_vertex_list_by_type_select_mirror(g, __vt); - size_t mvlist_sz = grin_get_vertex_list_size(g, mvlist); - for (size_t i = 0; i < mvlist_sz; ++i) { - GRIN_VERTEX v = grin_get_vertex_from_list(g, mvlist, i); - size_t pos = grin_get_position_of_vertex_from_sorted_list(g, mvlist, v); - assert(pos == i); - size_t pos1 = grin_get_position_of_vertex_from_sorted_list(g, vl, v); - GRIN_VERTEX v1 = grin_get_vertex_from_list(g, vl, pos1); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); - grin_destroy_vertex(g, v); - } - grin_destroy_vertex_list(g, mvlist); -} -#endif -FOR_VERTEX_LIST_END(g, vl) - - grin_destroy_graph(g); -} -#endif - -void test_index_internal_id(int argc, char** argv) { - printf("+++++++++++++++++++++ Test index internal id +++++++++++++++++++++\n"); - GRIN_GRAPH g = get_graph(argc, argv, 0); - -FOR_VERTEX_LIST_BEGIN(g, vl) - long long int min = grin_get_vertex_internal_id_lower_bound_by_type(g, __vt); - long long int max = grin_get_vertex_internal_id_upper_bound_by_type(g, __vt); - FOR_VERTEX_BEGIN(g, vl, v) -#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - long long int oid = grin_get_vertex_internal_id_by_type(g, __vt, v); - assert(oid >= min && oid < max); - GRIN_VERTEX v1 = grin_get_vertex_by_internal_id_by_type(g, __vt, oid); - assert(grin_equal_vertex(g, v, v1)); - grin_destroy_vertex(g, v1); -#endif - FOR_VERTEX_END(g, vl, v) -FOR_VERTEX_LIST_END(g, vl) - - grin_destroy_graph(g); -} - - -void test_index(int argc, char** argv) { -#if defined(GRIN_ASSUME_ALL_VERTEX_LIST_SORTED) && defined(GRIN_ENABLE_VERTEX_LIST_ARRAY) - test_index_order(argc, argv); -#endif -#ifdef GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX - test_index_internal_id(argc, argv); -#endif -} - -void test_vertex_property_value(int argc, char** argv) { - GRIN_GRAPH g = get_graph(argc, argv, 0); - GRIN_VERTEX_TYPE vt = grin_get_vertex_type_by_name(g, "person"); - GRIN_VERTEX_PROPERTY vp = grin_get_vertex_property_by_name(g, vt, "age"); - GRIN_VERTEX v = get_one_master_person(g); - struct timeval t1, t2; - gettimeofday(&t1, NULL); - for (int i = 0; i < 1000000; ++i) { - long long int age = grin_get_vertex_property_value_of_int64(g, v, vp); - } - gettimeofday(&t2, NULL); - double elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; - elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; - printf("%f ms.\n", elapsedTime); - grin_destroy_vertex(g, v); - grin_destroy_vertex_property(g, vp); - grin_destroy_vertex_type(g, vt); - grin_destroy_graph(g); -} - -void test_perf(int argc, char** argv) { - test_vertex_property_value(argc, argv); -} - -int main(int argc, char** argv) { - test_index(argc, argv); - test_property(argc, argv); - test_partition(argc, argv); - test_topology(argc, argv); - test_perf(argc, argv); - return 0; -} diff --git a/flex/engines/graph_db/grin/include/yaml/schema.yaml b/flex/engines/graph_db/grin/include/yaml/schema.yaml deleted file mode 100644 index b35dd38283e0..000000000000 --- a/flex/engines/graph_db/grin/include/yaml/schema.yaml +++ /dev/null @@ -1,69 +0,0 @@ -gs.gie.dbms.graph: - name: modern - graph: - snapshotId: xx - schema: - vertexTypes: - - typeId: 0 - typeName: person - properties: - - propertyId: 0 - propertyName: id - propertyType: - enumType: DT_UNSIGNED_INT64 - - propertyId: 1 - propertyName: name - propertyType: - enumType: DT_STRING - - propertyId: 2 - propertyName: age - propertyType: - enumType: DT_UNSIGNED_INT32 - primaryKeyIds: - - 0 - - typeId: 1 - typeName: software - properties: - - propertyId: 0 - propertyName: id - propertyType: - enumType: DT_UNSIGNED_INT64 - - propertyId: 1 - propertyName: name - propertyType: - enumType: DT_STRING - - propertyId: 2 - propertyName: lang - propertyType: - enumType: DT_STRING - - propertyId: 3 - propertyName: creationDateTime - propertyType: - dateTime: - dateTimeFormat: DTF_YYYY_MM_DD_HH_MM_SS_SSS - timeZoneFormat: TZF_UTC - primaryKeyIds: - - 0 - edgeTypes: - - typeId: 0 - typeName: knows - properties: - - propertyId: 0 - propertyName: weight - propertyType: - enumType: DT_DOUBLE - vertexTypePairRelations: - - srcTypeId: 0 - dstTypeId: 0 - relation: MANY_TO_MANY - - typeId: 1 - typeName: created - properties: - - propertyId: 0 - propertyName: weight - propertyType: - enumType: DT_DOUBLE - vertexTypePairRelations: - - srcTypeId: 0 - dstTypeId: 1 - relation: MANY_TO_MANY From 1d50c689b10e9d942a21e42cf1d75932d1a01907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 15:44:31 +0800 Subject: [PATCH 07/30] rm include --- flex/engines/graph_db/grin/src/predefine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flex/engines/graph_db/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h index 0fba5dd2ee5f..cd9c45f7ee35 100644 --- a/flex/engines/graph_db/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -1,6 +1,6 @@ #include "grin/predefine.h" -#include "../../storages/rt_mutable_graph/mutable_property_fragment.h" +#include "storages/rt_mutable_graph/mutable_property_fragment.h" typedef gs::oid_t GRIN_OID_T; typedef gs::vid_t GRIN_VID_T; From 10859f3e2623d4198e7a1318d564d7482a0bacfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 16:39:37 +0800 Subject: [PATCH 08/30] update libgrape-lite version --- flex/scripts/install_dependencies.sh | 2 +- flex/utils/property/types.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/flex/scripts/install_dependencies.sh b/flex/scripts/install_dependencies.sh index 43268ccc1110..2e343f8407c4 100644 --- a/flex/scripts/install_dependencies.sh +++ b/flex/scripts/install_dependencies.sh @@ -10,7 +10,7 @@ apt install -y xfslibs-dev libgnutls28-dev liblz4-dev maven openssl pkg-config \ git clone https://github.com/alibaba/libgrape-lite.git cd libgrape-lite -git checkout 976544ef7a9777ed93088459638ff87154e2109d +git checkout 8add4b330c31f8a47d83c5804072a8d42d10d32d mkdir build && cd build && cmake .. make -j && make install cp /usr/local/lib/libgrape-lite.so /usr/lib/libgrape-lite.so diff --git a/flex/utils/property/types.h b/flex/utils/property/types.h index 8bbf54c64bc9..8dc83aa468a1 100644 --- a/flex/utils/property/types.h +++ b/flex/utils/property/types.h @@ -22,7 +22,6 @@ limitations under the License. #include #include -#define nssv_CONFIG_SELECT_STRING_VIEW nssv_STRING_VIEW_NONSTD #include "grape/serialization/in_archive.h" #include "grape/serialization/out_archive.h" From dddeb54f230ff70e3eee5bbeb875864b45711f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 19:13:16 +0800 Subject: [PATCH 09/30] Redesign the data structure for vertex --- flex/engines/graph_db/grin/predefine.h | 23 ++-- .../graph_db/grin/src/index/internal_id.cc | 9 +- flex/engines/graph_db/grin/src/index/pk.cc | 4 +- flex/engines/graph_db/grin/src/predefine.h | 26 +--- .../graph_db/grin/src/property/primarykey.cc | 6 +- .../graph_db/grin/src/property/property.cc | 53 ++++--- .../engines/graph_db/grin/src/property/row.cc | 129 +++++++++--------- .../graph_db/grin/src/property/topology.cc | 8 +- .../graph_db/grin/src/property/type.cc | 7 +- .../grin/src/topology/adjacentlist.cc | 57 ++++---- .../graph_db/grin/src/topology/structure.cc | 15 +- .../graph_db/grin/src/topology/vertexlist.cc | 25 ++-- flex/engines/graph_db/grin/test/test.c | 11 +- 13 files changed, 176 insertions(+), 197 deletions(-) diff --git a/flex/engines/graph_db/grin/predefine.h b/flex/engines/graph_db/grin/predefine.h index f5a5aa6c48e6..70add811db6a 100644 --- a/flex/engines/graph_db/grin/predefine.h +++ b/flex/engines/graph_db/grin/predefine.h @@ -140,7 +140,7 @@ typedef enum { /* 3. Define the handles using typedef */ typedef void* GRIN_GRAPH; -typedef void* GRIN_VERTEX; +typedef uint64_t GRIN_VERTEX; typedef void* GRIN_EDGE; #ifdef GRIN_WITH_VERTEX_DATA @@ -162,11 +162,10 @@ typedef struct GRIN_VERTEX_LIST { #endif #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef void* GRIN_VERTEX_LIST_ITERATOR; -#endif - -#ifdef GRIN_ENABLE_ADJACENT_LIST -typedef void* GRIN_ADJACENT_LIST; +typedef struct GRIN_VERTEX_LIST_ITERATOR { + uint32_t* cur_vid; + GRIN_VERTEX_LIST vertex_list; +} GRIN_VERTEX_LIST_ITERATOR; #endif #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR @@ -206,7 +205,7 @@ typedef void* GRIN_EDGE_REF; #endif #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_TYPE -typedef GRIN_VERTEX_TYPE GRIN_VERTEX_TYPE_ID; +typedef unsigned GRIN_VERTEX_TYPE_ID; #endif #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY @@ -226,6 +225,14 @@ typedef void* GRIN_EDGE_PROPERTY_LIST; typedef unsigned GRIN_EDGE_TYPE_ID; #endif +#ifdef GRIN_ENABLE_ADJACENT_LIST +typedef struct GRIN_ADJACENT_LIST { + GRIN_VERTEX v; + GRIN_DIRECTION dir; + GRIN_EDGE_TYPE edge_label; +} GRIN_ADJACENT_LIST; +#endif + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY typedef unsigned GRIN_EDGE_PROPERTY_ID; #endif @@ -241,7 +248,7 @@ typedef void* GRIN_LABEL_LIST; /* 4. Define invalid values for returns of handles */ #define GRIN_NULL_GRAPH NULL -#define GRIN_NULL_VERTEX NULL +#define GRIN_NULL_VERTEX (1ull << 40) #define GRIN_NULL_EDGE NULL #define GRIN_NULL_VERTEX_DATA NULL #define GRIN_NULL_VERTEX_LIST NULL diff --git a/flex/engines/graph_db/grin/src/index/internal_id.cc b/flex/engines/graph_db/grin/src/index/internal_id.cc index 400f6174471d..9e33b602a6a5 100644 --- a/flex/engines/graph_db/grin/src/index/internal_id.cc +++ b/flex/engines/graph_db/grin/src/index/internal_id.cc @@ -59,8 +59,7 @@ long long int grin_get_vertex_internal_id_lower_bound(GRIN_GRAPH); long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX v) { - auto _v = static_cast(v); - return _v->vid; + return v & (0xffffffff); } /** @@ -73,10 +72,8 @@ long long int grin_get_vertex_internal_id_by_type(GRIN_GRAPH g, GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, long long int id) { - GRIN_VERTEX_T* v = new GRIN_VERTEX_T(); - v->label = vt; - v->vid = id; - return v; + auto v = static_cast(vt); + return (v << 32) + id; } /** diff --git a/flex/engines/graph_db/grin/src/index/pk.cc b/flex/engines/graph_db/grin/src/index/pk.cc index 196185d85df5..12ec62877c82 100644 --- a/flex/engines/graph_db/grin/src/index/pk.cc +++ b/flex/engines/graph_db/grin/src/index/pk.cc @@ -37,9 +37,7 @@ GRIN_VERTEX grin_get_vertex_by_primary_keys_row(GRIN_GRAPH g, if (!_g->get_lid(label, oid, vid)) { return GRIN_NULL_VERTEX; } - GRIN_VERTEX_T* v = new GRIN_VERTEX_T(); - v->label = label; - v->vid = vid; + uint64_t v = ((label * 1ull) << 32) + vid; return v; } #endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h index cd9c45f7ee35..c45ff553d4f4 100644 --- a/flex/engines/graph_db/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -7,31 +7,18 @@ typedef gs::vid_t GRIN_VID_T; typedef gs::MutablePropertyFragment GRIN_GRAPH_T; -typedef struct GRIN_VERTEX_T { - uint8_t label; - uint32_t vid; -} GRIN_VERTEX_T; - typedef struct GRIN_EDGE_T { - GRIN_VERTEX_T dst; - GRIN_VERTEX_T src; + GRIN_VERTEX dst; + GRIN_VERTEX src; GRIN_DIRECTION dir; gs::label_t label; gs::Any data; } GRIN_EDGE_T; -#ifdef GRIN_ENABLE_ADJACENT_LIST -typedef struct GRIN_ADJACENT_LIST_T { - GRIN_VERTEX_T v; - GRIN_DIRECTION dir; - GRIN_EDGE_TYPE edge_label; -} GRIN_ADJACENT_LIST_T; -#endif - #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR typedef struct GRIN_ADJACENT_LIST_ITERATOR_T { std::shared_ptr edge_iter; - GRIN_ADJACENT_LIST_T* adj_list; + GRIN_ADJACENT_LIST adj_list; } GRIN_ADJACENT_LIST_ITERATOR_T; #endif @@ -56,11 +43,4 @@ typedef std::vector GRIN_EDGE_TYPE_LIST_T; typedef std::vector GRIN_EDGE_PROPERTY_LIST_T; #endif -#ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR -typedef struct GRIN_VERTEX_LIST_ITERATOR_T { - size_t cur_vid; - GRIN_VERTEX_LIST vertex_list; -} GRIN_VERTEX_LIST_ITERATOR_T; -#endif - GRIN_DATATYPE _get_data_type(const gs::PropertyType& type); \ No newline at end of file diff --git a/flex/engines/graph_db/grin/src/property/primarykey.cc b/flex/engines/graph_db/grin/src/property/primarykey.cc index 9e501ac2b0d2..de4ac9bf73c1 100644 --- a/flex/engines/graph_db/grin/src/property/primarykey.cc +++ b/flex/engines/graph_db/grin/src/property/primarykey.cc @@ -47,9 +47,9 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_primary_keys_by_vertex_type( GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH g, GRIN_VERTEX v) { GRIN_ROW_T* row = new GRIN_ROW_T(); auto _g = static_cast(g); - auto _v = static_cast(v); - auto vid = _v->vid; - auto oid = _g->get_oid(_v->label, vid); + auto vid = v & (0xffffffff); + auto label = v >> 32; + auto oid = _g->get_oid(label, vid); auto p = new gs::oid_t(oid); row->emplace_back(p); return row; diff --git a/flex/engines/graph_db/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc index 826bec89af7c..a8547130ec09 100644 --- a/flex/engines/graph_db/grin/src/property/property.cc +++ b/flex/engines/graph_db/grin/src/property/property.cc @@ -118,8 +118,9 @@ int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - auto _v = static_cast(v); - if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Int32) { + auto label = v >> 32; + auto vid = v & (0xffffffff); + if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Int32) { grin_error_code = INVALID_VALUE; return 0; } @@ -130,7 +131,7 @@ int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, grin_error_code = INVALID_VALUE; return 0; } - return col->get_view(_v->vid); + return col->get_view(vid); } unsigned int grin_get_vertex_property_value_of_uint32(GRIN_GRAPH g, @@ -145,8 +146,11 @@ long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - auto _v = static_cast(v); - if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Int64) { + // auto _v = static_cast(v); + auto label = v >> 32; + auto vid = v & (0xffffffff); + + if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Int64) { grin_error_code = INVALID_VALUE; return 0; } @@ -157,7 +161,7 @@ long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, grin_error_code = INVALID_VALUE; return 0; } - return col->get_view(_v->vid); + return col->get_view(vid); } unsigned long long int grin_get_vertex_property_value_of_uint64( @@ -176,8 +180,10 @@ double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - auto _v = static_cast(v); - if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Double) { + auto label = v >> 32; + auto vid = v & (0xffffffff); + + if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Double) { grin_error_code = INVALID_VALUE; return 0.0; } @@ -189,7 +195,7 @@ double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, grin_error_code = INVALID_VALUE; return 0.0; } - return col->get_view(_v->vid); + return col->get_view(vid); } const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, @@ -197,8 +203,10 @@ const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - auto _v = static_cast(v); - if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::String) { + auto label = v >> 32; + auto vid = v & (0xffffffff); + + if (label != _vp->label || _vp->dt != GRIN_DATATYPE::String) { grin_error_code = INVALID_VALUE; return NULL; } @@ -209,7 +217,7 @@ const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, grin_error_code = INVALID_VALUE; return NULL; } - auto s = col->get_view(_v->vid); + auto s = col->get_view(vid); auto len = s.size() + 1; char* out = new char[len]; snprintf(out, len, "%s", s.data()); @@ -232,8 +240,10 @@ long long int grin_get_vertex_property_value_of_timestamp64( GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); auto _vp = static_cast(vp); - auto _v = static_cast(v); - if (_v->label != _vp->label || _vp->dt != GRIN_DATATYPE::Timestamp64) { + auto label = v >> 32; + auto vid = v & (0xffffffff); + + if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Timestamp64) { grin_error_code = INVALID_VALUE; return 0; } @@ -245,7 +255,7 @@ long long int grin_get_vertex_property_value_of_timestamp64( grin_error_code = INVALID_VALUE; return 0; } - return col->get_view(_v->vid).milli_second; + return col->get_view(vid).milli_second; } GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH g, @@ -263,27 +273,28 @@ const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, auto& table = _g->get_vertex_table(_vp->label); const auto& col = table.get_column(_vp->name); auto type = grin_get_vertex_property_datatype(g, vp); - auto _v = static_cast(v); + auto vid = v & (0xffffffff); + switch (type) { case GRIN_DATATYPE::Int32: { auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + _v->vid; + return _col->buffer().data() + vid; } case GRIN_DATATYPE::Int64: { auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + _v->vid; + return _col->buffer().data() + vid; } case GRIN_DATATYPE::String: { auto _col = std::dynamic_pointer_cast(col); - return _col->buffer()[_v->vid].data(); + return _col->buffer()[vid].data(); } case GRIN_DATATYPE::Timestamp64: { auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + _v->vid; + return _col->buffer().data() + vid; } case GRIN_DATATYPE::Double: { auto _col = std::dynamic_pointer_cast(col); - return _col->buffer().data() + _v->vid; + return _col->buffer().data() + vid; } default: grin_error_code = UNKNOWN_DATATYPE; diff --git a/flex/engines/graph_db/grin/src/property/row.cc b/flex/engines/graph_db/grin/src/property/row.cc index 8d5296e33989..13857e6188e2 100644 --- a/flex/engines/graph_db/grin/src/property/row.cc +++ b/flex/engines/graph_db/grin/src/property/row.cc @@ -178,48 +178,48 @@ const void* grin_get_value_from_row(GRIN_GRAPH g, GRIN_ROW r, GRIN_DATATYPE dt, #if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_ENABLE_ROW) GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { auto _g = static_cast(g); - auto _v = static_cast(v); - auto& table = _g->get_vertex_table(_v->label); + auto vid = v & (0xffffffff); + auto label = v >> 32; + auto& table = _g->get_vertex_table(label); auto prop_size = table.col_num(); const auto& types = table.column_types(); auto r = new GRIN_ROW_T(); for (size_t prop_id = 0; prop_id < prop_size; prop_id++) { auto col = table.get_column_by_id(prop_id); auto type = _get_data_type(types[prop_id]); - switch(type){ - case GRIN_DATATYPE::Int32:{ - auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data()+ _v->vid); - break; - } - case GRIN_DATATYPE::Int64:{ - auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data()+ _v->vid); - break; - } - case GRIN_DATATYPE::String:{ - auto _col = std::dynamic_pointer_cast(col); - auto s = _col->get_view(_v->vid); - auto len = s.size() + 1; - char* out = new char[len]; - snprintf(out, len, "%s", s.data()); + switch (type) { + case GRIN_DATATYPE::Int32: { + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data() + vid); + break; + } + case GRIN_DATATYPE::Int64: { + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data() + vid); + break; + } + case GRIN_DATATYPE::String: { + auto _col = std::dynamic_pointer_cast(col); + auto s = _col->get_view(vid); + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); - r->emplace_back(out); - break; - } - case GRIN_DATATYPE::Timestamp64:{ - auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data()+ _v->vid); - break; - } - case GRIN_DATATYPE::Double:{ - auto _col = std::dynamic_pointer_cast(col); - r->emplace_back(_col->buffer().data() + _v->vid); - break; - } - default: - r->emplace_back(static_cast(NULL)); - + r->emplace_back(out); + break; + } + case GRIN_DATATYPE::Timestamp64: { + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data() + vid); + break; + } + case GRIN_DATATYPE::Double: { + auto _col = std::dynamic_pointer_cast(col); + r->emplace_back(_col->buffer().data() + vid); + break; + } + default: + r->emplace_back(static_cast(NULL)); } } return r; @@ -227,40 +227,39 @@ GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { #endif #if defined(GRIN_WITH_EDGE_PROPERTY) && defined(GRIN_ENABLE_ROW) -GRIN_ROW grin_get_edge_row(GRIN_GRAPH g, GRIN_EDGE e){ +GRIN_ROW grin_get_edge_row(GRIN_GRAPH g, GRIN_EDGE e) { auto _e = static_cast(e); auto type = _get_data_type(_e->data.type); GRIN_ROW_T* r = new GRIN_ROW_T(); - switch(type){ - case GRIN_DATATYPE::Int32:{ - r->emplace_back(new int(_e->data.value.i)); - break; - } - case GRIN_DATATYPE::Int64:{ - r->emplace_back(new int64_t(_e->data.value.l)); - break; - } - case GRIN_DATATYPE::String:{ - auto s = _e->data.value.s; - auto len = s.size() + 1; - char* out = new char[len]; - snprintf(out, len, "%s", s.data()); + switch (type) { + case GRIN_DATATYPE::Int32: { + r->emplace_back(new int(_e->data.value.i)); + break; + } + case GRIN_DATATYPE::Int64: { + r->emplace_back(new int64_t(_e->data.value.l)); + break; + } + case GRIN_DATATYPE::String: { + auto s = _e->data.value.s; + auto len = s.size() + 1; + char* out = new char[len]; + snprintf(out, len, "%s", s.data()); - r->emplace_back(out); - break; - } - case GRIN_DATATYPE::Timestamp64:{ - r->emplace_back(new int64_t(_e->data.value.d.milli_second)); - break; - } - case GRIN_DATATYPE::Double:{ - r->emplace_back(new double(_e->data.value.db)); - break; - } - default: - r->emplace_back(static_cast(NULL)); - - } + r->emplace_back(out); + break; + } + case GRIN_DATATYPE::Timestamp64: { + r->emplace_back(new int64_t(_e->data.value.d.milli_second)); + break; + } + case GRIN_DATATYPE::Double: { + r->emplace_back(new double(_e->data.value.db)); + break; + } + default: + r->emplace_back(static_cast(NULL)); + } return r; } #endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/src/property/topology.cc b/flex/engines/graph_db/grin/src/property/topology.cc index 69bfc250b00f..d4d73f785492 100644 --- a/flex/engines/graph_db/grin/src/property/topology.cc +++ b/flex/engines/graph_db/grin/src/property/topology.cc @@ -66,10 +66,10 @@ GRIN_ADJACENT_LIST grin_get_adjacent_list_by_edge_type(GRIN_GRAPH g, GRIN_DIRECTION dir, GRIN_VERTEX v, GRIN_EDGE_TYPE et) { - GRIN_ADJACENT_LIST_T* adj_list = new GRIN_ADJACENT_LIST_T(); - adj_list->v = *static_cast(v); - adj_list->dir = dir; - adj_list->edge_label = et; + GRIN_ADJACENT_LIST adj_list; + adj_list.v = v; + adj_list.dir = dir; + adj_list.edge_label = et; return adj_list; } #endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/src/property/type.cc b/flex/engines/graph_db/grin/src/property/type.cc index 80ef8ff2237a..fe23cdf9bd2f 100644 --- a/flex/engines/graph_db/grin/src/property/type.cc +++ b/flex/engines/graph_db/grin/src/property/type.cc @@ -22,8 +22,7 @@ bool grin_equal_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt1, } GRIN_VERTEX_TYPE grin_get_vertex_type(GRIN_GRAPH g, GRIN_VERTEX v) { - auto _v = static_cast(v); - return _v->label; + return v >> 32; } void grin_destroy_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) {} @@ -110,7 +109,9 @@ bool grin_equal_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et1, GRIN_EDGE_TYPE grin_get_edge_type(GRIN_GRAPH g, GRIN_EDGE e) { auto _e = static_cast(e); - return _e->label + (_e->src.label << 16) + (_e->dst.label << 8); + auto src_label = _e->src >> 32; + auto dst_label = _e->dst >> 32; + return _e->label + (src_label << 16) + (dst_label << 8); } void grin_destroy_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { diff --git a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc index 6e6fd932ba8f..5725d9541494 100644 --- a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc +++ b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc @@ -20,43 +20,41 @@ limitations under the License. #if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_ENABLE_EDGE_PROPERTY) GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH g, GRIN_DIRECTION dir, GRIN_VERTEX v) { - GRIN_ADJACENT_LIST_T* alt = new GRIN_ADJACENT_LIST_T(); - alt->dir = dir; - alt->v = *static_cast(v); + GRIN_ADJACENT_LIST alt; + alt.dir = dir; + alt.v = v; return alt; } #endif #ifdef GRIN_ENABLE_ADJACENT_LIST -void grin_destroy_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) { - auto adj = static_cast(adj_list); - delete adj; -} +void grin_destroy_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) {} #endif #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) { auto _g = static_cast(g); - auto _adj_list = static_cast(adj_list); auto iter = new GRIN_ADJACENT_LIST_ITERATOR_T(); - auto& v = _adj_list->v; - iter->adj_list = _adj_list; - auto label = _adj_list->edge_label; + auto& v = adj_list.v; + iter->adj_list = adj_list; + auto label = adj_list.edge_label; auto src_label = label >> 16; auto dst_label = (label >> 8) & 0xff; auto edge_label = label & 0xff; - if (_adj_list->dir == GRIN_DIRECTION::OUT) { - if (src_label == v.label) { + auto v_label = v >> 32; + auto vid = v & (0xffffffff); + if (adj_list.dir == GRIN_DIRECTION::OUT) { + if (src_label == v_label) { iter->edge_iter = - _g->get_outgoing_edges(src_label, v.vid, dst_label, edge_label); + _g->get_outgoing_edges(src_label, vid, dst_label, edge_label); } else { iter->edge_iter = nullptr; } } else { - if (dst_label == v.label) { + if (dst_label == v_label) { iter->edge_iter = - _g->get_incoming_edges(dst_label, v.vid, src_label, edge_label); + _g->get_incoming_edges(dst_label, vid, src_label, edge_label); } else { iter->edge_iter = nullptr; } @@ -84,33 +82,32 @@ bool grin_is_adjacent_list_end(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter( GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); - auto v = new GRIN_VERTEX_T(); - v->vid = _iter->edge_iter->get_neighbor(); - auto label = _iter->adj_list->edge_label; - if (_iter->adj_list->dir == GRIN_DIRECTION::OUT) { - v->label = (label >> 8) & 0xff; + auto vid = _iter->edge_iter->get_neighbor(); + auto label = _iter->adj_list.edge_label; + + if (_iter->adj_list.dir == GRIN_DIRECTION::OUT) { + label = (label >> 8) & 0xff; } else { - v->label = label >> 16; + label = label >> 16; } - return v; + return ((label * 1ull) << 32) + vid; } GRIN_EDGE grin_get_edge_from_adjacent_list_iter( GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); GRIN_EDGE_T* edge = new GRIN_EDGE_T(); - auto nbr = *static_cast( - grin_get_neighbor_from_adjacent_list_iter(g, iter)); - if (_iter->adj_list->dir == GRIN_DIRECTION::IN) { + auto nbr = grin_get_neighbor_from_adjacent_list_iter(g, iter); + if (_iter->adj_list.dir == GRIN_DIRECTION::IN) { edge->src = nbr; - edge->dst = _iter->adj_list->v; + edge->dst = _iter->adj_list.v; } else { - edge->src = _iter->adj_list->v; + edge->src = _iter->adj_list.v; edge->dst = nbr; } - edge->dir = _iter->adj_list->dir; + edge->dir = _iter->adj_list.dir; edge->data = _iter->edge_iter->get_data(); - auto label = _iter->adj_list->edge_label; + auto label = _iter->adj_list.edge_label; edge->label = label & 0xff; return edge; } diff --git a/flex/engines/graph_db/grin/src/topology/structure.cc b/flex/engines/graph_db/grin/src/topology/structure.cc index 47721aae071a..ce10233ed356 100644 --- a/flex/engines/graph_db/grin/src/topology/structure.cc +++ b/flex/engines/graph_db/grin/src/topology/structure.cc @@ -73,15 +73,10 @@ size_t grin_get_edge_num(GRIN_GRAPH); #endif // Vertex -void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX v) { - auto _v = static_cast(v); - delete _v; -} +void grin_destroy_vertex(GRIN_GRAPH, GRIN_VERTEX v) {} bool grin_equal_vertex(GRIN_GRAPH g, GRIN_VERTEX v1, GRIN_VERTEX v2) { - auto _v1 = static_cast(v1); - auto _v2 = static_cast(v2); - return _v1->label == _v2->label && _v1->vid == _v2->vid; + return v1 == v2; } // Data @@ -99,15 +94,13 @@ void grin_destroy_edge(GRIN_GRAPH, GRIN_EDGE e) { GRIN_VERTEX grin_get_src_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e) { auto _e = static_cast(e); - auto v = new GRIN_VERTEX_T(); - memcpy(v, &(_e->src), sizeof(GRIN_VERTEX_T)); + auto v = _e->src; return v; } GRIN_VERTEX grin_get_dst_vertex_from_edge(GRIN_GRAPH, GRIN_EDGE e) { auto _e = static_cast(e); - auto v = new GRIN_VERTEX_T(); - memcpy(v, &(_e->dst), sizeof(GRIN_VERTEX_T)); + auto v = _e->dst; return v; } diff --git a/flex/engines/graph_db/grin/src/topology/vertexlist.cc b/flex/engines/graph_db/grin/src/topology/vertexlist.cc index c3d43053e82b..6523a8ea7f3c 100644 --- a/flex/engines/graph_db/grin/src/topology/vertexlist.cc +++ b/flex/engines/graph_db/grin/src/topology/vertexlist.cc @@ -28,36 +28,31 @@ void grin_destroy_vertex_list(GRIN_GRAPH g, GRIN_VERTEX_LIST vl) {} #ifdef GRIN_ENABLE_VERTEX_LIST_ITERATOR GRIN_VERTEX_LIST_ITERATOR grin_get_vertex_list_begin(GRIN_GRAPH g, GRIN_VERTEX_LIST vl) { - GRIN_VERTEX_LIST_ITERATOR_T* vlt = new GRIN_VERTEX_LIST_ITERATOR_T(); - vlt->cur_vid = 0; - vlt->vertex_list = vl; + GRIN_VERTEX_LIST_ITERATOR vlt; + vlt.cur_vid = new uint32_t(0); + vlt.vertex_list = vl; return vlt; } void grin_destroy_vertex_list_iter(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - delete _iter; + delete iter.cur_vid; } void grin_get_next_vertex_list_iter(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - if (_iter->cur_vid < _iter->vertex_list.vertex_num) - ++_iter->cur_vid; + if (*iter.cur_vid < iter.vertex_list.vertex_num) + ++(*iter.cur_vid); } bool grin_is_vertex_list_end(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - return _iter->cur_vid == _iter->vertex_list.vertex_num; + return *iter.cur_vid == iter.vertex_list.vertex_num; } GRIN_VERTEX grin_get_vertex_from_iter(GRIN_GRAPH g, GRIN_VERTEX_LIST_ITERATOR iter) { - auto v = new GRIN_VERTEX_T(); - auto _iter = static_cast(iter); - v->label = _iter->vertex_list.label; - v->vid = _iter->cur_vid; - return v; + auto label = iter.vertex_list.label; + auto vid = *iter.cur_vid; + return ((label * 1ull) << 32) + vid; } #endif \ No newline at end of file diff --git a/flex/engines/graph_db/grin/test/test.c b/flex/engines/graph_db/grin/test/test.c index a59a20ddbdb6..8abcbeded816 100644 --- a/flex/engines/graph_db/grin/test/test.c +++ b/flex/engines/graph_db/grin/test/test.c @@ -712,12 +712,13 @@ void test_property(const char* uri_str) { test_error_code(uri_str); #endif } - /** void test_partition_reference(const char* uri_str) { printf("+++++++++++++++++++++ Test partition/reference -+++++++++++++++++++++\n"); GRIN_PARTITIONED_GRAPH pg = -grin_get_partitioned_graph_from_storage(argv[1]); GRIN_PARTITION_LIST ++++++++++++++++++++++\n"); +GRIN_PARTITIONED_GRAPH pg = +grin_get_partitioned_graph_from_storage(argv[1]); +GRIN_PARTITION_LIST local_partitions = grin_get_local_partition_list(pg); assert(grin_get_partition_list_size(pg, local_partitions) >= 2); @@ -824,8 +825,8 @@ void test_partition(const char* uri_str) { test_partition_reference(uri_str); test_partition_topology(uri_str); #endif -}*/ - +} +*/ void test_topology_structure(const char* uri_str) { printf( "+++++++++++++++++++++ Test topology/structure +++++++++++++++++++++\n"); From 17c2cb66bbae674a4f4df0e708b807349c9da223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Fri, 14 Jul 2023 19:31:38 +0800 Subject: [PATCH 10/30] remove not supported feature --- .../graph_db/grin/src/property/primarykey.cc | 9 --------- .../graph_db/grin/src/property/property.cc | 18 ------------------ .../graph_db/grin/src/property/propertylist.cc | 12 ------------ 3 files changed, 39 deletions(-) diff --git a/flex/engines/graph_db/grin/src/property/primarykey.cc b/flex/engines/graph_db/grin/src/property/primarykey.cc index de4ac9bf73c1..81a635e140fd 100644 --- a/flex/engines/graph_db/grin/src/property/primarykey.cc +++ b/flex/engines/graph_db/grin/src/property/primarykey.cc @@ -55,12 +55,3 @@ GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH g, GRIN_VERTEX v) { return row; } #endif - -#ifdef GRIN_ENABLE_EDGE_PRIMARY_KEYS -GRIN_EDGE_TYPE_LIST grin_get_edge_types_with_primary_keys(GRIN_GRAPH); - -GRIN_EDGE_PROPERTY_LIST grin_get_primary_keys_by_edge_type(GRIN_GRAPH, - GRIN_EDGE_TYPE); - -GRIN_ROW grin_get_edge_primary_keys_row(GRIN_GRAPH, GRIN_EDGE); -#endif diff --git a/flex/engines/graph_db/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc index a8547130ec09..58eea57adcf4 100644 --- a/flex/engines/graph_db/grin/src/property/property.cc +++ b/flex/engines/graph_db/grin/src/property/property.cc @@ -73,24 +73,6 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, } #endif -#ifdef GRIN_WITH_EDGE_PROPERTY_NAME -const char* grin_get_edge_property_name(GRIN_GRAPH g, GRIN_EDGE_TYPE etype, - GRIN_EDGE_PROPERTY ep) { - return static_cast(NULL); -} - -GRIN_EDGE_PROPERTY grin_get_edge_property_by_name(GRIN_GRAPH g, - GRIN_EDGE_TYPE et, - const char* name) { - return NULL; -} - -GRIN_EDGE_PROPERTY_LIST grin_get_edge_properties_by_name(GRIN_GRAPH g, - const char* name) { - return NULL; -} -#endif - #ifdef GRIN_WITH_VERTEX_PROPERTY bool grin_equal_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp1, GRIN_VERTEX_PROPERTY vp2) { diff --git a/flex/engines/graph_db/grin/src/property/propertylist.cc b/flex/engines/graph_db/grin/src/property/propertylist.cc index c23715758f4f..dc9423573228 100644 --- a/flex/engines/graph_db/grin/src/property/propertylist.cc +++ b/flex/engines/graph_db/grin/src/property/propertylist.cc @@ -159,15 +159,3 @@ bool grin_insert_edge_property_to_list(GRIN_GRAPH g, return true; } #endif - -#ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY -GRIN_EDGE_PROPERTY grin_get_edge_property_by_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et, - GRIN_EDGE_PROPERTY_ID pid) { - return NULL; -} - -GRIN_EDGE_PROPERTY_ID grin_get_edge_property_id(GRIN_GRAPH g, GRIN_EDGE_TYPE et, - GRIN_EDGE_PROPERTY ep) { - return 0; -} -#endif \ No newline at end of file From 4f4045733e756ce8c8c27da8cab62d02096866db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Mon, 17 Jul 2023 12:03:02 +0800 Subject: [PATCH 11/30] Remove unnecessary dependencies --- flex/engines/graph_db/grin/CMakeLists.txt | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/flex/engines/graph_db/grin/CMakeLists.txt b/flex/engines/graph_db/grin/CMakeLists.txt index 566d1d538c12..8d2d507e1a9d 100644 --- a/flex/engines/graph_db/grin/CMakeLists.txt +++ b/flex/engines/graph_db/grin/CMakeLists.txt @@ -16,11 +16,6 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g") # find_libraries # ------------------------------------------------------------------------------ -find_package(MPI REQUIRED) -include_directories(SYSTEM ${MPI_CXX_INCLUDE_PATH}) - -find_package(OpenMP REQUIRED) - find_package(libgrapelite REQUIRED) include_directories(${LIBGRAPELITE_INCLUDE_DIRS}) @@ -38,16 +33,12 @@ if (GLOG_FOUND) set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${GLOG_LIBRARIES}") endif () -#find_package(etcd-cpp-api REQUIRED) -#include_directories(${ETCD_CPP_INCLUDE_DIR}) -#link_libraries(${ETCD_CPP_LIBRARIES}) +find_package(yaml-cpp REQUIRED) +include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) -#find_package(yaml-cpp REQUIRED) +#set(yaml-cpp_INCLUDE_DIRS "/usr/local/Cellar/yaml-cpp/0.7.0/include") #include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) - -set(yaml-cpp_INCLUDE_DIRS "/usr/local/Cellar/yaml-cpp/0.7.0/include") -include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) -set(YAML_CPP_LIBRARIES "/usr/local/Cellar/yaml-cpp/0.7.0/lib/libyaml-cpp.0.7.0.dylib") +#set(YAML_CPP_LIBRARIES "/usr/local/Cellar/yaml-cpp/0.7.0/lib/libyaml-cpp.0.7.0.dylib") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -67,11 +58,11 @@ add_custom_target(grin_clformat file(GLOB SOURCES "src/*.cc" "src/topology/*.cc" "src/property/*.cc" "src/index/*.cc" "src/common/*.cc" "../../../utils/property/*.cc" "../../../storages/rt_mutable_graph/*.cc") add_library(flex_grin SHARED ${SOURCES}) -target_link_libraries(flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES} ${YAML_CPP_LIBRARIES}) +target_link_libraries(flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${YAML_CPP_LIBRARIES}) add_executable(run_grin_test test/test.c) target_include_directories(run_grin_test PRIVATE ${LIBGRAPELITE_INCLUDE_DIRS}/grape/analytical_apps fragment) -target_link_libraries(run_grin_test flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS} ${MPI_CXX_LIBRARIES}) -target_link_libraries(run_grin_test OpenMP::OpenMP_CXX) +target_link_libraries(run_grin_test flex_grin ${LIBGRAPELITE_LIBRARIES} ${GFLAGS_LIBRARIES} ${CMAKE_DL_LIBS}) +target_link_libraries(run_grin_test) From 543c726eea83fc795f1bfbd17a23dfe8c0d5cffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Mon, 17 Jul 2023 19:27:50 +0800 Subject: [PATCH 12/30] use raw pointer instead of shared_ptr --- flex/engines/graph_db/grin/src/predefine.h | 6 +++--- .../grin/src/topology/adjacentlist.cc | 8 ++++++-- flex/storages/rt_mutable_graph/mutable_csr.h | 13 +++++++++++++ .../mutable_property_fragment.cc | 19 ++++++++++++++++++- .../mutable_property_fragment.h | 9 ++++++++- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/flex/engines/graph_db/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h index c45ff553d4f4..404ca39a00ca 100644 --- a/flex/engines/graph_db/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -16,10 +16,10 @@ typedef struct GRIN_EDGE_T { } GRIN_EDGE_T; #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -typedef struct GRIN_ADJACENT_LIST_ITERATOR_T { - std::shared_ptr edge_iter; +struct GRIN_ADJACENT_LIST_ITERATOR_T { + gs::MutableCsrConstEdgeIterBase* edge_iter; GRIN_ADJACENT_LIST adj_list; -} GRIN_ADJACENT_LIST_ITERATOR_T; +}; #endif #ifdef GRIN_WITH_VERTEX_PROPERTY diff --git a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc index 5725d9541494..57ea998a489b 100644 --- a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc +++ b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc @@ -47,14 +47,15 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( if (adj_list.dir == GRIN_DIRECTION::OUT) { if (src_label == v_label) { iter->edge_iter = - _g->get_outgoing_edges(src_label, vid, dst_label, edge_label); + _g->get_outgoing_edges_raw(src_label, vid, dst_label, edge_label); + } else { iter->edge_iter = nullptr; } } else { if (dst_label == v_label) { iter->edge_iter = - _g->get_incoming_edges(dst_label, vid, src_label, edge_label); + _g->get_incoming_edges_raw(dst_label, vid, src_label, edge_label); } else { iter->edge_iter = nullptr; } @@ -65,6 +66,9 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( void grin_destroy_adjacent_list_iter(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { auto _iter = static_cast(iter); + if (_iter->edge_iter != nullptr) { + delete _iter->edge_iter; + } delete _iter; } diff --git a/flex/storages/rt_mutable_graph/mutable_csr.h b/flex/storages/rt_mutable_graph/mutable_csr.h index 113bbb7e382f..5fa6b245103a 100644 --- a/flex/storages/rt_mutable_graph/mutable_csr.h +++ b/flex/storages/rt_mutable_graph/mutable_csr.h @@ -319,6 +319,8 @@ class MutableCsrBase { virtual std::shared_ptr edge_iter( vid_t v) const = 0; + virtual MutableCsrConstEdgeIterBase* edge_iter_raw(vid_t v) const = 0; + virtual std::shared_ptr edge_iter_mut(vid_t v) = 0; }; @@ -474,6 +476,9 @@ class MutableCsr : public TypedMutableCsrBase { get_edges(v)); } + MutableCsrConstEdgeIterBase* edge_iter_raw(vid_t v) const override { + return new TypedMutableCsrConstEdgeIter(get_edges(v)); + } std::shared_ptr edge_iter_mut(vid_t v) override { return std::make_shared>(get_edges_mut(v)); } @@ -578,6 +583,10 @@ class MutableCsr : public TypedMutableCsrBase { get_edges(v)); } + MutableCsrConstEdgeIterBase* edge_iter_raw(vid_t v) const override { + return new TypedMutableCsrConstEdgeIter(get_edges(v)); + } + std::shared_ptr edge_iter_mut(vid_t v) override { return std::make_shared>( get_edges_mut(v)); @@ -682,6 +691,10 @@ class SingleMutableCsr : public TypedMutableCsrBase { get_edges(v)); } + MutableCsrConstEdgeIterBase* edge_iter_raw(vid_t v) const override { + return new TypedMutableCsrConstEdgeIter(get_edges(v)); + } + std::shared_ptr edge_iter_mut(vid_t v) override { return std::make_shared>(get_edges_mut(v)); } diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc index 5a4e1381d963..ca716c2802d5 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.cc +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.cc @@ -97,7 +97,10 @@ class EmptyCsr : public TypedMutableCsrBase { return std::make_shared>( MutableNbrSlice::empty()); } - + MutableCsrConstEdgeIterBase* edge_iter_raw(vid_t v) const override { + return new TypedMutableCsrConstEdgeIter( + MutableNbrSlice::empty()); + } std::shared_ptr edge_iter_mut(vid_t v) override { return std::make_shared>( MutableNbrSliceMut::empty()); @@ -587,6 +590,20 @@ MutablePropertyFragment::get_incoming_edges(label_t label, vid_t u, return ie_[index]->edge_iter(u); } +MutableCsrConstEdgeIterBase* MutablePropertyFragment::get_outgoing_edges_raw( + label_t label, vid_t u, label_t neighbor_label, label_t edge_label) const { + size_t index = label * vertex_label_num_ * edge_label_num_ + + neighbor_label * edge_label_num_ + edge_label; + return oe_[index]->edge_iter_raw(u); +} + +MutableCsrConstEdgeIterBase* MutablePropertyFragment::get_incoming_edges_raw( + label_t label, vid_t u, label_t neighbor_label, label_t edge_label) const { + size_t index = neighbor_label * vertex_label_num_ * edge_label_num_ + + label * edge_label_num_ + edge_label; + return ie_[index]->edge_iter_raw(u); +} + std::shared_ptr MutablePropertyFragment::get_outgoing_edges_mut(label_t label, vid_t u, label_t neighbor_label, diff --git a/flex/storages/rt_mutable_graph/mutable_property_fragment.h b/flex/storages/rt_mutable_graph/mutable_property_fragment.h index b275c301d6fb..3b3454b97c97 100644 --- a/flex/storages/rt_mutable_graph/mutable_property_fragment.h +++ b/flex/storages/rt_mutable_graph/mutable_property_fragment.h @@ -65,7 +65,6 @@ class MutablePropertyFragment { oid_t get_oid(label_t label, vid_t lid) const; vid_t add_vertex(label_t label, oid_t id); - std::shared_ptr get_outgoing_edges( label_t label, vid_t u, label_t neighbor_label, label_t edge_label) const; @@ -78,6 +77,14 @@ class MutablePropertyFragment { std::shared_ptr get_incoming_edges_mut( label_t label, vid_t u, label_t neighbor_label, label_t edge_label); + MutableCsrConstEdgeIterBase* get_outgoing_edges_raw(label_t label, vid_t u, + label_t neighbor_label, + label_t edge_label) const; + + MutableCsrConstEdgeIterBase* get_incoming_edges_raw(label_t label, vid_t u, + label_t neighbor_label, + label_t edge_label) const; + MutableCsrBase* get_oe_csr(label_t label, label_t neighbor_label, label_t edge_label); From 9f9dadf661e56e847929b817e81d8a8461e64457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 08:08:59 +0800 Subject: [PATCH 13/30] GRIN_VERTEX_PROPERTY as u32 --- flex/engines/graph_db/grin/predefine.h | 14 ++- flex/engines/graph_db/grin/src/predefine.h | 9 +- .../graph_db/grin/src/property/primarykey.cc | 8 +- .../graph_db/grin/src/property/property.cc | 101 +++++++++--------- .../grin/src/property/propertylist.cc | 41 +++---- flex/engines/graph_db/grin/test/test.c | 2 + flex/utils/property/table.cc | 16 +++ flex/utils/property/table.h | 4 + 8 files changed, 104 insertions(+), 91 deletions(-) diff --git a/flex/engines/graph_db/grin/predefine.h b/flex/engines/graph_db/grin/predefine.h index 70add811db6a..dac8a812f3af 100644 --- a/flex/engines/graph_db/grin/predefine.h +++ b/flex/engines/graph_db/grin/predefine.h @@ -150,7 +150,15 @@ typedef void* GRIN_VERTEX_DATA; #ifdef GRIN_WITH_VERTEX_PROPERTY typedef unsigned GRIN_VERTEX_TYPE; typedef void* GRIN_VERTEX_TYPE_LIST; -typedef void* GRIN_VERTEX_PROPERTY; +// dt: 8, label: 8, idx:8 +typedef uint32_t GRIN_VERTEX_PROPERTY; +/** +typedef struct GRIN_VERTEX_PROPERTY { + unsigned idx; + GRIN_DATATYPE dt; + GRIN_VERTEX_TYPE label; +} GRIN_VERTEX_PROPERTY; +*/ typedef void* GRIN_VERTEX_PROPERTY_LIST; #endif @@ -248,7 +256,7 @@ typedef void* GRIN_LABEL_LIST; /* 4. Define invalid values for returns of handles */ #define GRIN_NULL_GRAPH NULL -#define GRIN_NULL_VERTEX (1ull << 40) +#define GRIN_NULL_VERTEX (unsigned long long) ~0 #define GRIN_NULL_EDGE NULL #define GRIN_NULL_VERTEX_DATA NULL #define GRIN_NULL_VERTEX_LIST NULL @@ -266,7 +274,7 @@ typedef void* GRIN_LABEL_LIST; #define GRIN_NULL_EDGE_REF NULL #define GRIN_NULL_VERTEX_TYPE (unsigned) ~0 #define GRIN_NULL_VERTEX_TYPE_LIST NULL -#define GRIN_NULL_VERTEX_PROPERTY NULL +#define GRIN_NULL_VERTEX_PROPERTY (unsigned) ~0 #define GRIN_NULL_VERTEX_PROPERTY_LIST NULL #define GRIN_NULL_VERTEX_TYPE_ID (unsigned) ~0 #define GRIN_NULL_VERTEX_PROPERTY_ID (unsigned) ~0 diff --git a/flex/engines/graph_db/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h index 404ca39a00ca..4038d23b7de7 100644 --- a/flex/engines/graph_db/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -24,14 +24,7 @@ struct GRIN_ADJACENT_LIST_ITERATOR_T { #ifdef GRIN_WITH_VERTEX_PROPERTY typedef std::vector GRIN_VERTEX_TYPE_LIST_T; - -typedef struct GRIN_VERTEX_PROPERTY_T { - std::string name; - GRIN_DATATYPE dt; - GRIN_VERTEX_TYPE label; -} GRIN_VERTEX_PROPERTY_T; - -typedef std::vector GRIN_VERTEX_PROPERTY_LIST_T; +typedef std::vector GRIN_VERTEX_PROPERTY_LIST_T; #endif #if defined(GRIN_WITH_VERTEX_PROPERTY) || defined(GRIN_WITH_EDGE_PROPERTY) diff --git a/flex/engines/graph_db/grin/src/property/primarykey.cc b/flex/engines/graph_db/grin/src/property/primarykey.cc index 81a635e140fd..53afbd25ff00 100644 --- a/flex/engines/graph_db/grin/src/property/primarykey.cc +++ b/flex/engines/graph_db/grin/src/property/primarykey.cc @@ -29,10 +29,10 @@ GRIN_VERTEX_TYPE_LIST grin_get_vertex_types_with_primary_keys(GRIN_GRAPH g) { GRIN_VERTEX_PROPERTY_LIST grin_get_primary_keys_by_vertex_type( GRIN_GRAPH, GRIN_VERTEX_TYPE label) { GRIN_VERTEX_PROPERTY_LIST_T* vpl = new GRIN_VERTEX_PROPERTY_LIST_T(); - GRIN_VERTEX_PROPERTY_T vp; - vp.name = "oid"; - vp.label = label; - vp.dt = GRIN_DATATYPE::Int64; + GRIN_VERTEX_PROPERTY vp; + vp = 0; + vp += (label * 1u) << 8; + vp += (GRIN_DATATYPE::Int64 * 1u) << 16; vpl->emplace_back(vp); return vpl; } diff --git a/flex/engines/graph_db/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc index 58eea57adcf4..a2322954443b 100644 --- a/flex/engines/graph_db/grin/src/property/property.cc +++ b/flex/engines/graph_db/grin/src/property/property.cc @@ -20,10 +20,12 @@ void grin_destroy_string_value(GRIN_GRAPH g, const char* value) { } #ifdef GRIN_WITH_VERTEX_PROPERTY_NAME -const char* grin_get_vertex_property_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vtype, +const char* grin_get_vertex_property_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX_PROPERTY vp) { - auto _vp = static_cast(vp); - const auto& name = _vp->name; + auto _g = static_cast(g); + auto& table = _g->get_vertex_table(vt); + + const auto& name = table.column_name(vp & (0xff)); auto len = name.length() + 1; char* out = new char[len]; snprintf(out, len, "%s", name.c_str()); @@ -39,10 +41,10 @@ GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH g, if (col == nullptr) { return GRIN_NULL_VERTEX_PROPERTY; } - auto vp = new GRIN_VERTEX_PROPERTY_T(); - vp->name = std::string(name); - vp->label = vt; - vp->dt = _get_data_type(col->type()); + GRIN_VERTEX_PROPERTY vp; + vp = table.get_column_id_by_name(name); + vp += (vt * 1u) << 8; + vp += (_get_data_type(col->type()) * 1u) << 16; return vp; } @@ -58,10 +60,10 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, auto col = table.get_column(name); if (col != nullptr) { - GRIN_VERTEX_PROPERTY_T vp; - vp.name = _name; - vp.label = idx; - vp.dt = _get_data_type(col->type()); + GRIN_VERTEX_PROPERTY vp; + vp = table.get_column_id_by_name(name); + vp += (idx * 1u) << 8; + vp += (_get_data_type(col->type()) * 1u) << 16; vps->emplace_back(vp); } } @@ -76,39 +78,34 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, #ifdef GRIN_WITH_VERTEX_PROPERTY bool grin_equal_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp1, GRIN_VERTEX_PROPERTY vp2) { - auto _vp1 = static_cast(vp1); - auto _vp2 = static_cast(vp2); - return (_vp1->name == _vp2->name) && (_vp1->label == _vp2->label) && - (_vp1->dt == _vp2->dt); + return vp1 == vp2; } -void grin_destroy_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { - auto _vp = static_cast(vp); - delete _vp; -} +void grin_destroy_vertex_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) {} /** * @TODO add type for GRIN_VERTEX_PROPERTY_T */ GRIN_DATATYPE grin_get_vertex_property_datatype(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { - auto _vp = static_cast(vp); - return _vp->dt; + return (GRIN_DATATYPE) (vp >> 16); } int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto _vp = static_cast(vp); auto label = v >> 32; auto vid = v & (0xffffffff); - if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Int32) { + auto plabel = (vp >> 8) & (0xff); + auto pdt = (vp >> 16); + auto pid = vp & (0xff); + if (label != plabel || pdt != GRIN_DATATYPE::Int32) { grin_error_code = INVALID_VALUE; return 0; } - auto& table = _g->get_vertex_table(_vp->label); + auto& table = _g->get_vertex_table(plabel); auto col = - std::dynamic_pointer_cast(table.get_column(_vp->name)); + std::dynamic_pointer_cast(table.get_column_by_id(pid)); if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0; @@ -127,18 +124,19 @@ long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto _vp = static_cast(vp); - // auto _v = static_cast(v); auto label = v >> 32; auto vid = v & (0xffffffff); + auto plabel = (vp >> 8) & (0xff); + auto pdt = (vp >> 16); + auto pid = vp & (0xff); - if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Int64) { + if (label != plabel || pdt != GRIN_DATATYPE::Int64) { grin_error_code = INVALID_VALUE; return 0; } - auto& table = _g->get_vertex_table(_vp->label); + auto& table = _g->get_vertex_table(plabel); auto col = - std::dynamic_pointer_cast(table.get_column(_vp->name)); + std::dynamic_pointer_cast(table.get_column_by_id(pid)); if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0; @@ -161,18 +159,20 @@ float grin_get_vertex_property_value_of_float(GRIN_GRAPH g, GRIN_VERTEX v, double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto _vp = static_cast(vp); auto label = v >> 32; auto vid = v & (0xffffffff); + auto plabel = (vp >> 8) & (0xff); + auto pdt = (vp >> 16); + auto pid = vp & (0xff); - if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Double) { + if (label != plabel || pdt != GRIN_DATATYPE::Double) { grin_error_code = INVALID_VALUE; return 0.0; } - auto& table = _g->get_vertex_table(_vp->label); + auto& table = _g->get_vertex_table(plabel); auto col = - std::dynamic_pointer_cast(table.get_column(_vp->name)); + std::dynamic_pointer_cast(table.get_column_by_id(pid)); if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0.0; @@ -184,17 +184,19 @@ const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto _vp = static_cast(vp); auto label = v >> 32; auto vid = v & (0xffffffff); + auto plabel = (vp >> 8) & (0xff); + auto pdt = (vp >> 16); + auto pid = vp & (0xff); - if (label != _vp->label || _vp->dt != GRIN_DATATYPE::String) { + if (label != plabel || pdt != GRIN_DATATYPE::String) { grin_error_code = INVALID_VALUE; return NULL; } - auto& table = _g->get_vertex_table(_vp->label); + auto& table = _g->get_vertex_table(plabel); auto col = - std::dynamic_pointer_cast(table.get_column(_vp->name)); + std::dynamic_pointer_cast(table.get_column_by_id(pid)); if (col == nullptr) { grin_error_code = INVALID_VALUE; return NULL; @@ -221,18 +223,20 @@ int grin_get_vertex_property_value_of_time32(GRIN_GRAPH g, GRIN_VERTEX v, long long int grin_get_vertex_property_value_of_timestamp64( GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto _vp = static_cast(vp); auto label = v >> 32; auto vid = v & (0xffffffff); + auto plabel = (vp >> 8) & (0xff); + auto pdt = (vp >> 16); + auto pid = vp & (0xff); - if (label != _vp->label || _vp->dt != GRIN_DATATYPE::Timestamp64) { + if (label != plabel || pdt != GRIN_DATATYPE::Timestamp64) { grin_error_code = INVALID_VALUE; return 0; } - auto& table = _g->get_vertex_table(_vp->label); + auto& table = _g->get_vertex_table(plabel); auto col = - std::dynamic_pointer_cast(table.get_column(_vp->name)); + std::dynamic_pointer_cast(table.get_column_by_id(pid)); if (col == nullptr) { grin_error_code = INVALID_VALUE; return 0; @@ -242,19 +246,20 @@ long long int grin_get_vertex_property_value_of_timestamp64( GRIN_VERTEX_TYPE grin_get_vertex_type_from_property(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY vp) { - auto _vp = static_cast(vp); - return _vp->label; + return (vp >> 8) & (0xff); } #endif #if defined(GRIN_WITH_VERTEX_PROPERTY) && defined(GRIN_TRAIT_CONST_VALUE_PTR) const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, GRIN_VERTEX_PROPERTY vp) { + auto plabel = (vp >> 8) & (0xff); + auto type = (vp >> 16); + auto pid = vp & (0xff); + auto _g = static_cast(g); - auto _vp = static_cast(vp); - auto& table = _g->get_vertex_table(_vp->label); - const auto& col = table.get_column(_vp->name); - auto type = grin_get_vertex_property_datatype(g, vp); + auto& table = _g->get_vertex_table(plabel); + const auto& col = table.get_column_by_id(pid); auto vid = v & (0xffffffff); switch (type) { diff --git a/flex/engines/graph_db/grin/src/property/propertylist.cc b/flex/engines/graph_db/grin/src/property/propertylist.cc index dc9423573228..08b5f800f4e6 100644 --- a/flex/engines/graph_db/grin/src/property/propertylist.cc +++ b/flex/engines/graph_db/grin/src/property/propertylist.cc @@ -22,14 +22,13 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type( auto vertex_prop_num = table.col_num(); GRIN_VERTEX_PROPERTY_LIST_T* vpl = new GRIN_VERTEX_PROPERTY_LIST_T(); - const auto& prop_names = table.column_names(); const auto& prop_types = table.column_types(); for (size_t i = 0; i < vertex_prop_num; ++i) { - GRIN_VERTEX_PROPERTY_T vpt; - vpt.name = prop_names[i]; - vpt.label = vt; - vpt.dt = _get_data_type(prop_types[i]); - vpl->emplace_back(vpt); + GRIN_VERTEX_PROPERTY vp; + vp = i; + vp += (vt * 1u) << 8; + vp += (_get_data_type(prop_types[i]) * 1u) << 16; + vpl->emplace_back(vp); } return vpl; } @@ -43,9 +42,7 @@ size_t grin_get_vertex_property_list_size(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY grin_get_vertex_property_from_list( GRIN_GRAPH g, GRIN_VERTEX_PROPERTY_LIST vpl, size_t idx) { auto _vpl = static_cast(vpl); - GRIN_VERTEX_PROPERTY_T* vp = new GRIN_VERTEX_PROPERTY_T(); - *vp = (*_vpl)[idx]; - return vp; + return (*_vpl)[idx]; } GRIN_VERTEX_PROPERTY_LIST grin_create_vertex_property_list(GRIN_GRAPH g) { @@ -61,10 +58,8 @@ void grin_destroy_vertex_property_list(GRIN_GRAPH g, bool grin_insert_vertex_property_to_list(GRIN_GRAPH g, GRIN_VERTEX_PROPERTY_LIST vpl, GRIN_VERTEX_PROPERTY vp) { - auto _vp = static_cast(vp); - auto p = *_vp; auto _vpl = static_cast(vpl); - _vpl->push_back(p); + _vpl->push_back(vp); return true; } #endif @@ -80,28 +75,18 @@ GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id( if (pid >= vertex_prop_num) { return GRIN_NULL_VERTEX_PROPERTY; } - const auto& prop_names = table.column_names(); const auto& prop_types = table.column_types(); - GRIN_VERTEX_PROPERTY_T* vpt = new GRIN_VERTEX_PROPERTY_T(); - vpt->name = prop_names[pid]; - vpt->label = vt; - vpt->dt = _get_data_type(prop_types[pid]); - return vpt; + GRIN_VERTEX_PROPERTY vp; + vp = pid; + vp += (vt * 1u) << 8; + vp += (_get_data_type(prop_types[pid]) * 1u) << 16; + return vp; } GRIN_VERTEX_PROPERTY_ID grin_get_vertex_property_id(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX_PROPERTY vp) { - auto _g = static_cast(g); - auto& table = _g->get_vertex_table(vt); - const auto& prop_names = table.column_names(); - auto _vp = static_cast(vp); - for (size_t i = 0; i < prop_names.size(); ++i) { - if (prop_names.at(i) == _vp->name) { - return i; - } - } - return GRIN_NULL_VERTEX_PROPERTY_ID; + return vp & (0xff); } #endif diff --git a/flex/engines/graph_db/grin/test/test.c b/flex/engines/graph_db/grin/test/test.c index 8abcbeded816..ca2e48906674 100644 --- a/flex/engines/graph_db/grin/test/test.c +++ b/flex/engines/graph_db/grin/test/test.c @@ -411,7 +411,9 @@ void test_property_vertex_property_value(const char* uri_str) { #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY unsigned int id = grin_get_vertex_property_id(g, vt, vp); + printf("%d %d\n",id,vp); GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id); + printf("%u vs. %u %u %u\n",vp,vp1,vp>>16,vp1>>16); assert(grin_equal_vertex_property(g, vp, vp1)); grin_destroy_vertex_property(g, vp1); #else diff --git a/flex/utils/property/table.cc b/flex/utils/property/table.cc index 2833717f77e2..2c53de48db1c 100644 --- a/flex/utils/property/table.cc +++ b/flex/utils/property/table.cc @@ -60,6 +60,22 @@ std::vector Table::column_names() const { return names; } +std::string Table::column_name(size_t index) const { + size_t col_num = col_id_indexer_.size(); + CHECK(index < col_num); + std::string name{}; + CHECK(col_id_indexer_.get_key(index, name)); + return name; +} + +int Table::get_column_id_by_name(const std::string& name) const { + int col_id; + if (col_id_indexer_.get_index(name, col_id)) { + return col_id; + } + return -1; +} + std::vector Table::column_types() const { size_t col_num = col_id_indexer_.size(); std::vector types(col_num); diff --git a/flex/utils/property/table.h b/flex/utils/property/table.h index 0b4e5fcbdc42..4fa2110ffab4 100644 --- a/flex/utils/property/table.h +++ b/flex/utils/property/table.h @@ -41,6 +41,10 @@ class Table { std::vector column_names() const; + std::string column_name(size_t index) const; + + int get_column_id_by_name(const std::string& name) const; + std::vector column_types() const; std::shared_ptr get_column(const std::string& name); From d647eacc34b4b308d8470c18b78d088ba6b6907f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 08:11:18 +0800 Subject: [PATCH 14/30] GRIN_VERTEX_PROPERTY as u32 --- flex/engines/graph_db/grin/test/test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/flex/engines/graph_db/grin/test/test.c b/flex/engines/graph_db/grin/test/test.c index ca2e48906674..8abcbeded816 100644 --- a/flex/engines/graph_db/grin/test/test.c +++ b/flex/engines/graph_db/grin/test/test.c @@ -411,9 +411,7 @@ void test_property_vertex_property_value(const char* uri_str) { #ifdef GRIN_TRAIT_NATURAL_ID_FOR_VERTEX_PROPERTY unsigned int id = grin_get_vertex_property_id(g, vt, vp); - printf("%d %d\n",id,vp); GRIN_VERTEX_PROPERTY vp1 = grin_get_vertex_property_by_id(g, vt, id); - printf("%u vs. %u %u %u\n",vp,vp1,vp>>16,vp1>>16); assert(grin_equal_vertex_property(g, vp, vp1)); grin_destroy_vertex_property(g, vp1); #else From 1e2f3fd04b6b1a8df4ec727b92b17381f6353d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 10:15:24 +0800 Subject: [PATCH 15/30] add note --- flex/engines/graph_db/grin/predefine.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/flex/engines/graph_db/grin/predefine.h b/flex/engines/graph_db/grin/predefine.h index dac8a812f3af..1dac954151ae 100644 --- a/flex/engines/graph_db/grin/predefine.h +++ b/flex/engines/graph_db/grin/predefine.h @@ -140,6 +140,7 @@ typedef enum { /* 3. Define the handles using typedef */ typedef void* GRIN_GRAPH; +// label: 8, vid: 32 typedef uint64_t GRIN_VERTEX; typedef void* GRIN_EDGE; @@ -150,7 +151,7 @@ typedef void* GRIN_VERTEX_DATA; #ifdef GRIN_WITH_VERTEX_PROPERTY typedef unsigned GRIN_VERTEX_TYPE; typedef void* GRIN_VERTEX_TYPE_LIST; -// dt: 8, label: 8, idx:8 +// datatype: 8, vertex label: 8, property index:8 typedef uint32_t GRIN_VERTEX_PROPERTY; /** typedef struct GRIN_VERTEX_PROPERTY { @@ -221,10 +222,10 @@ typedef unsigned GRIN_VERTEX_PROPERTY_ID; #endif #ifdef GRIN_WITH_EDGE_PROPERTY +// src_label: 8, dst_label: 8, edge_label: 8 typedef unsigned GRIN_EDGE_TYPE; typedef void* GRIN_EDGE_TYPE_LIST; -typedef void* GRIN_VEV_TYPE; -typedef void* GRIN_VEV_TYPE_LIST; +// index: 8, src_label: 8, dst_label: 8, edge_label: 8 typedef unsigned GRIN_EDGE_PROPERTY; typedef void* GRIN_EDGE_PROPERTY_LIST; #endif From 6c69f78dc1f889f5aa6d76b0cf353f5a6054da72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 10:40:49 +0800 Subject: [PATCH 16/30] Redesigned adj iter --- flex/engines/graph_db/grin/predefine.h | 12 +++- flex/engines/graph_db/grin/src/predefine.h | 7 --- .../grin/src/topology/adjacentlist.cc | 57 +++++++++++-------- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/flex/engines/graph_db/grin/predefine.h b/flex/engines/graph_db/grin/predefine.h index 1dac954151ae..f61936236e47 100644 --- a/flex/engines/graph_db/grin/predefine.h +++ b/flex/engines/graph_db/grin/predefine.h @@ -177,9 +177,7 @@ typedef struct GRIN_VERTEX_LIST_ITERATOR { } GRIN_VERTEX_LIST_ITERATOR; #endif -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -typedef void* GRIN_ADJACENT_LIST_ITERATOR; -#endif + #ifdef GRIN_WITH_EDGE_DATA typedef void* GRIN_EDGE_DATA; @@ -242,6 +240,14 @@ typedef struct GRIN_ADJACENT_LIST { } GRIN_ADJACENT_LIST; #endif +#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR +typedef struct GRIN_ADJACENT_LIST_ITERATOR { + //gs::MutableCsrConstEdgeIterBase* + void* edge_iter; + GRIN_ADJACENT_LIST adj_list; +} GRIN_ADJACENT_LIST_ITERATOR; +#endif + #ifdef GRIN_TRAIT_NATURAL_ID_FOR_EDGE_PROPERTY typedef unsigned GRIN_EDGE_PROPERTY_ID; #endif diff --git a/flex/engines/graph_db/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h index 4038d23b7de7..39a26b6c7222 100644 --- a/flex/engines/graph_db/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -15,13 +15,6 @@ typedef struct GRIN_EDGE_T { gs::Any data; } GRIN_EDGE_T; -#ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR -struct GRIN_ADJACENT_LIST_ITERATOR_T { - gs::MutableCsrConstEdgeIterBase* edge_iter; - GRIN_ADJACENT_LIST adj_list; -}; -#endif - #ifdef GRIN_WITH_VERTEX_PROPERTY typedef std::vector GRIN_VERTEX_TYPE_LIST_T; typedef std::vector GRIN_VERTEX_PROPERTY_LIST_T; diff --git a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc index 57ea998a489b..133fb6558c09 100644 --- a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc +++ b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc @@ -35,9 +35,9 @@ void grin_destroy_adjacent_list(GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) {} GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( GRIN_GRAPH g, GRIN_ADJACENT_LIST adj_list) { auto _g = static_cast(g); - auto iter = new GRIN_ADJACENT_LIST_ITERATOR_T(); + GRIN_ADJACENT_LIST_ITERATOR iter; auto& v = adj_list.v; - iter->adj_list = adj_list; + iter.adj_list = adj_list; auto label = adj_list.edge_label; auto src_label = label >> 16; auto dst_label = (label >> 8) & 0xff; @@ -46,18 +46,18 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( auto vid = v & (0xffffffff); if (adj_list.dir == GRIN_DIRECTION::OUT) { if (src_label == v_label) { - iter->edge_iter = + iter.edge_iter = _g->get_outgoing_edges_raw(src_label, vid, dst_label, edge_label); } else { - iter->edge_iter = nullptr; + iter.edge_iter = nullptr; } } else { if (dst_label == v_label) { - iter->edge_iter = + iter.edge_iter = _g->get_incoming_edges_raw(dst_label, vid, src_label, edge_label); } else { - iter->edge_iter = nullptr; + iter.edge_iter = nullptr; } } return iter; @@ -65,31 +65,37 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( void grin_destroy_adjacent_list_iter(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - if (_iter->edge_iter != nullptr) { - delete _iter->edge_iter; + if (iter.edge_iter != nullptr) { + auto edge_iter = + static_cast(iter.edge_iter); + delete edge_iter; } - delete _iter; } void grin_get_next_adjacent_list_iter(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - _iter->edge_iter->next(); + auto edge_iter = + static_cast(iter.edge_iter); + edge_iter->next(); } bool grin_is_adjacent_list_end(GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - return _iter->edge_iter == nullptr || !_iter->edge_iter->is_valid(); + if (iter.edge_iter == nullptr) { + return true; + } + auto edge_iter = + static_cast(iter.edge_iter); + return !edge_iter->is_valid(); } GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter( GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); - auto vid = _iter->edge_iter->get_neighbor(); - auto label = _iter->adj_list.edge_label; + auto edge_iter = + static_cast(iter.edge_iter); + auto vid = edge_iter->get_neighbor(); + auto label = iter.adj_list.edge_label; - if (_iter->adj_list.dir == GRIN_DIRECTION::OUT) { + if (iter.adj_list.dir == GRIN_DIRECTION::OUT) { label = (label >> 8) & 0xff; } else { label = label >> 16; @@ -99,19 +105,20 @@ GRIN_VERTEX grin_get_neighbor_from_adjacent_list_iter( GRIN_EDGE grin_get_edge_from_adjacent_list_iter( GRIN_GRAPH g, GRIN_ADJACENT_LIST_ITERATOR iter) { - auto _iter = static_cast(iter); + auto edge_iter = + static_cast(iter.edge_iter); GRIN_EDGE_T* edge = new GRIN_EDGE_T(); auto nbr = grin_get_neighbor_from_adjacent_list_iter(g, iter); - if (_iter->adj_list.dir == GRIN_DIRECTION::IN) { + if (iter.adj_list.dir == GRIN_DIRECTION::IN) { edge->src = nbr; - edge->dst = _iter->adj_list.v; + edge->dst = iter.adj_list.v; } else { - edge->src = _iter->adj_list.v; + edge->src = iter.adj_list.v; edge->dst = nbr; } - edge->dir = _iter->adj_list.dir; - edge->data = _iter->edge_iter->get_data(); - auto label = _iter->adj_list.edge_label; + edge->dir = iter.adj_list.dir; + edge->data = edge_iter->get_data(); + auto label = iter.adj_list.edge_label; edge->label = label & 0xff; return edge; } From fc263ea3b54fd4bd30f7bd4aac809281e1ecbb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 11:34:56 +0800 Subject: [PATCH 17/30] use SCNd64 for int64 --- flex/engines/graph_db/grin/predefine.h | 12 ++---------- flex/utils/property/types.cc | 4 ++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/flex/engines/graph_db/grin/predefine.h b/flex/engines/graph_db/grin/predefine.h index f61936236e47..85578a8c4a8c 100644 --- a/flex/engines/graph_db/grin/predefine.h +++ b/flex/engines/graph_db/grin/predefine.h @@ -153,13 +153,7 @@ typedef unsigned GRIN_VERTEX_TYPE; typedef void* GRIN_VERTEX_TYPE_LIST; // datatype: 8, vertex label: 8, property index:8 typedef uint32_t GRIN_VERTEX_PROPERTY; -/** -typedef struct GRIN_VERTEX_PROPERTY { - unsigned idx; - GRIN_DATATYPE dt; - GRIN_VERTEX_TYPE label; -} GRIN_VERTEX_PROPERTY; -*/ + typedef void* GRIN_VERTEX_PROPERTY_LIST; #endif @@ -177,8 +171,6 @@ typedef struct GRIN_VERTEX_LIST_ITERATOR { } GRIN_VERTEX_LIST_ITERATOR; #endif - - #ifdef GRIN_WITH_EDGE_DATA typedef void* GRIN_EDGE_DATA; #endif @@ -242,7 +234,7 @@ typedef struct GRIN_ADJACENT_LIST { #ifdef GRIN_ENABLE_ADJACENT_LIST_ITERATOR typedef struct GRIN_ADJACENT_LIST_ITERATOR { - //gs::MutableCsrConstEdgeIterBase* + // gs::MutableCsrConstEdgeIterBase* void* edge_iter; GRIN_ADJACENT_LIST adj_list; } GRIN_ADJACENT_LIST_ITERATOR; diff --git a/flex/utils/property/types.cc b/flex/utils/property/types.cc index dcfc8cf7ff35..f1e93c687802 100644 --- a/flex/utils/property/types.cc +++ b/flex/utils/property/types.cc @@ -109,7 +109,11 @@ void ParseRecordX(const char* line, int64_t& src, int64_t& dst, } void ParseRecordX(const char* line, int64_t& src, int64_t& dst, double& prop) { +#ifdef __APPLE__ sscanf(line, "%lld|%lld|%lf", &src, &dst, &prop); +#else + sscanf(line, "%" SCNd64 "|%" SCNd64 "|%lf", &src, &dst, &prop); +#endif } void ParseRecordX(const char* line, int64_t& src, int64_t& dst, int64_t& prop) { From fdaf968c229f2a383b8d346aed6f50f226a2bc86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 14:30:02 +0800 Subject: [PATCH 18/30] Adjusting the grin include directory --- .gitmodules | 5 ++- flex/GRIN | 1 + flex/engines/graph_db/grin/CMakeLists.txt | 3 +- .../engines/graph_db/grin/src/common/error.cc | 2 +- .../graph_db/grin/src/index/internal_id.cc | 2 +- flex/engines/graph_db/grin/src/index/pk.cc | 2 +- .../graph_db/grin/src/property/primarykey.cc | 4 +- .../graph_db/grin/src/property/property.cc | 4 +- .../grin/src/property/propertylist.cc | 2 +- .../engines/graph_db/grin/src/property/row.cc | 2 +- .../graph_db/grin/src/property/topology.cc | 2 +- .../graph_db/grin/src/property/type.cc | 2 +- .../grin/src/topology/adjacentlist.cc | 2 +- .../graph_db/grin/src/topology/structure.cc | 2 +- .../graph_db/grin/src/topology/vertexlist.cc | 2 +- flex/engines/graph_db/grin/test/test.c | 38 +++++++++---------- flex/scripts/install_dependencies.sh | 2 +- 17 files changed, 40 insertions(+), 37 deletions(-) create mode 160000 flex/GRIN diff --git a/.gitmodules b/.gitmodules index 54582c5e0b39..dabe493f60bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "learning_engine/graph-learn"] path = learning_engine/graph-learn url = https://github.com/alibaba/graph-learn.git -[submodule "flex/engines/graph_db/grin/include"] - path = flex/engines/graph_db/grin/include + +[submodule "flex/grin"] + path = flex/grin url = https://github.com/GraphScope/GRIN.git diff --git a/flex/GRIN b/flex/GRIN new file mode 160000 index 000000000000..bcafca761f7a --- /dev/null +++ b/flex/GRIN @@ -0,0 +1 @@ +Subproject commit bcafca761f7ac44f2fb20f599d8ce7c13daae3d9 diff --git a/flex/engines/graph_db/grin/CMakeLists.txt b/flex/engines/graph_db/grin/CMakeLists.txt index 8d2d507e1a9d..99d717c5dea6 100644 --- a/flex/engines/graph_db/grin/CMakeLists.txt +++ b/flex/engines/graph_db/grin/CMakeLists.txt @@ -40,9 +40,10 @@ include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) #include_directories(SYSTEM ${yaml-cpp_INCLUDE_DIRS}) #set(YAML_CPP_LIBRARIES "/usr/local/Cellar/yaml-cpp/0.7.0/lib/libyaml-cpp.0.7.0.dylib") -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../..) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../..) message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../storages/rt_mutable_graph) diff --git a/flex/engines/graph_db/grin/src/common/error.cc b/flex/engines/graph_db/grin/src/common/error.cc index 893bfab3fcaf..d910f0b74892 100644 --- a/flex/engines/graph_db/grin/src/common/error.cc +++ b/flex/engines/graph_db/grin/src/common/error.cc @@ -17,7 +17,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/common/error.h" +#include "grin/include/common/error.h" __thread GRIN_ERROR_CODE grin_error_code = GRIN_ERROR_CODE::NO_ERROR; diff --git a/flex/engines/graph_db/grin/src/index/internal_id.cc b/flex/engines/graph_db/grin/src/index/internal_id.cc index 9e33b602a6a5..1be66927ccf4 100644 --- a/flex/engines/graph_db/grin/src/index/internal_id.cc +++ b/flex/engines/graph_db/grin/src/index/internal_id.cc @@ -12,7 +12,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/index/internal_id.h" +#include "grin/include/index/internal_id.h" #if defined(GRIN_ENABLE_VERTEX_INTERNAL_ID_INDEX) && \ !defined(GRIN_WITH_VERTEX_PROPERTY) diff --git a/flex/engines/graph_db/grin/src/index/pk.cc b/flex/engines/graph_db/grin/src/index/pk.cc index 12ec62877c82..73df6ce38f09 100644 --- a/flex/engines/graph_db/grin/src/index/pk.cc +++ b/flex/engines/graph_db/grin/src/index/pk.cc @@ -12,7 +12,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/index/pk.h" +#include "grin/include/index/pk.h" #if defined(GRIN_ENABLE_VERTEX_PK_INDEX) && \ defined(GRIN_ENABLE_VERTEX_PRIMARY_KEYS) diff --git a/flex/engines/graph_db/grin/src/property/primarykey.cc b/flex/engines/graph_db/grin/src/property/primarykey.cc index 53afbd25ff00..3c4fe3bf1cbc 100644 --- a/flex/engines/graph_db/grin/src/property/primarykey.cc +++ b/flex/engines/graph_db/grin/src/property/primarykey.cc @@ -1,7 +1,7 @@ #include "grin/src/predefine.h" -#include "grin/include/include/common/error.h" -#include "grin/include/include/property/primarykey.h" +#include "grin/include/common/error.h" +#include "grin/include/property/primarykey.h" #ifdef GRIN_ENABLE_VERTEX_PRIMARY_KEYS /** * @brief Get the vertex types that have primary keys diff --git a/flex/engines/graph_db/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc index a2322954443b..b31c6aa7f6ee 100644 --- a/flex/engines/graph_db/grin/src/property/property.cc +++ b/flex/engines/graph_db/grin/src/property/property.cc @@ -12,8 +12,8 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/common/error.h" -#include "grin/include/include/property/property.h" +#include "grin/include/common/error.h" +#include "grin/include/property/property.h" void grin_destroy_string_value(GRIN_GRAPH g, const char* value) { delete value; diff --git a/flex/engines/graph_db/grin/src/property/propertylist.cc b/flex/engines/graph_db/grin/src/property/propertylist.cc index 08b5f800f4e6..c9b96e05f3d9 100644 --- a/flex/engines/graph_db/grin/src/property/propertylist.cc +++ b/flex/engines/graph_db/grin/src/property/propertylist.cc @@ -12,7 +12,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/property/propertylist.h" +#include "grin/include/property/propertylist.h" #ifdef GRIN_WITH_VERTEX_PROPERTY GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type( diff --git a/flex/engines/graph_db/grin/src/property/row.cc b/flex/engines/graph_db/grin/src/property/row.cc index 13857e6188e2..9bb28bceaa3a 100644 --- a/flex/engines/graph_db/grin/src/property/row.cc +++ b/flex/engines/graph_db/grin/src/property/row.cc @@ -12,7 +12,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/property/row.h" +#include "grin/include/property/row.h" #ifdef GRIN_ENABLE_ROW void grin_destroy_row(GRIN_GRAPH g, GRIN_ROW r) { diff --git a/flex/engines/graph_db/grin/src/property/topology.cc b/flex/engines/graph_db/grin/src/property/topology.cc index d4d73f785492..9b43d24dea94 100644 --- a/flex/engines/graph_db/grin/src/property/topology.cc +++ b/flex/engines/graph_db/grin/src/property/topology.cc @@ -12,7 +12,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/property/topology.h" +#include "grin/include/property/topology.h" #ifdef GRIN_WITH_VERTEX_PROPERTY size_t grin_get_vertex_num_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { diff --git a/flex/engines/graph_db/grin/src/property/type.cc b/flex/engines/graph_db/grin/src/property/type.cc index fe23cdf9bd2f..b134eb409944 100644 --- a/flex/engines/graph_db/grin/src/property/type.cc +++ b/flex/engines/graph_db/grin/src/property/type.cc @@ -12,7 +12,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/property/type.h" +#include "grin/include/property/type.h" #ifdef GRIN_WITH_VERTEX_PROPERTY // Vertex type diff --git a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc index 133fb6558c09..2a49cabf9fdc 100644 --- a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc +++ b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc @@ -15,7 +15,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/topology/adjacentlist.h" +#include "grin/include/topology/adjacentlist.h" #if defined(GRIN_ENABLE_ADJACENT_LIST) && !defined(GRIN_ENABLE_EDGE_PROPERTY) GRIN_ADJACENT_LIST grin_get_adjacent_list(GRIN_GRAPH g, GRIN_DIRECTION dir, diff --git a/flex/engines/graph_db/grin/src/topology/structure.cc b/flex/engines/graph_db/grin/src/topology/structure.cc index ce10233ed356..6181cb8c2fe8 100644 --- a/flex/engines/graph_db/grin/src/topology/structure.cc +++ b/flex/engines/graph_db/grin/src/topology/structure.cc @@ -15,7 +15,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/topology/structure.h" +#include "grin/include/topology/structure.h" /** * @brief Get a (non-partitioned) graph from storage diff --git a/flex/engines/graph_db/grin/src/topology/vertexlist.cc b/flex/engines/graph_db/grin/src/topology/vertexlist.cc index 6523a8ea7f3c..413525e24980 100644 --- a/flex/engines/graph_db/grin/src/topology/vertexlist.cc +++ b/flex/engines/graph_db/grin/src/topology/vertexlist.cc @@ -15,7 +15,7 @@ limitations under the License. #include "grin/src/predefine.h" -#include "grin/include/include/topology/vertexlist.h" +#include "grin/include/topology/vertexlist.h" #if defined(GRIN_ENABLE_VERTEX_LIST) && !defined(GRIN_WITH_VERTEX_PROPERTY) GRIN_VERTEX_LIST grin_get_vertex_list(GRIN_GRAPH g) {} diff --git a/flex/engines/graph_db/grin/test/test.c b/flex/engines/graph_db/grin/test/test.c index 8abcbeded816..c2117e108b8c 100644 --- a/flex/engines/graph_db/grin/test/test.c +++ b/flex/engines/graph_db/grin/test/test.c @@ -6,25 +6,25 @@ #include "grin/predefine.h" -#include "../include/include/common/error.h" -#include "../include/include/index/internal_id.h" -#include "../include/include/index/label.h" -#include "../include/include/index/order.h" -#include "../include/include/index/pk.h" -#include "../include/include/partition/partition.h" -#include "../include/include/partition/reference.h" -#include "../include/include/partition/topology.h" -#include "../include/include/property/partition.h" -#include "../include/include/property/primarykey.h" -#include "../include/include/property/property.h" -#include "../include/include/property/propertylist.h" -#include "../include/include/property/row.h" -#include "../include/include/property/topology.h" -#include "../include/include/property/type.h" -#include "../include/include/topology/adjacentlist.h" -#include "../include/include/topology/edgelist.h" -#include "../include/include/topology/structure.h" -#include "../include/include/topology/vertexlist.h" +#include "grin/include/common/error.h" +#include "grin/include/index/internal_id.h" +#include "grin/include/index/label.h" +#include "grin/include/index/order.h" +#include "grin/include/index/pk.h" +#include "grin/include/partition/partition.h" +#include "grin/include/partition/reference.h" +#include "grin/include/partition/topology.h" +#include "grin/include/property/partition.h" +#include "grin/include/property/primarykey.h" +#include "grin/include/property/property.h" +#include "grin/include/property/propertylist.h" +#include "grin/include/property/row.h" +#include "grin/include/property/topology.h" +#include "grin/include/property/type.h" +#include "grin/include/topology/adjacentlist.h" +#include "grin/include/topology/edgelist.h" +#include "grin/include/topology/structure.h" +#include "grin/include/topology/vertexlist.h" #define eps (1e-8) #define FOR_VERTEX_BEGIN(g, vl, v) \ diff --git a/flex/scripts/install_dependencies.sh b/flex/scripts/install_dependencies.sh index 2e343f8407c4..1d72c6f9e860 100644 --- a/flex/scripts/install_dependencies.sh +++ b/flex/scripts/install_dependencies.sh @@ -10,7 +10,7 @@ apt install -y xfslibs-dev libgnutls28-dev liblz4-dev maven openssl pkg-config \ git clone https://github.com/alibaba/libgrape-lite.git cd libgrape-lite -git checkout 8add4b330c31f8a47d83c5804072a8d42d10d32d +git checkout v0.3.2 mkdir build && cd build && cmake .. make -j && make install cp /usr/local/lib/libgrape-lite.so /usr/lib/libgrape-lite.so From 16d57680595480bcf37ff36d1281eee6374b640f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 14:51:55 +0800 Subject: [PATCH 19/30] Adjusting the grin include directory --- flex/engines/graph_db/grin/include | 1 - flex/{GRIN => grin} | 0 2 files changed, 1 deletion(-) delete mode 160000 flex/engines/graph_db/grin/include rename flex/{GRIN => grin} (100%) diff --git a/flex/engines/graph_db/grin/include b/flex/engines/graph_db/grin/include deleted file mode 160000 index bcafca761f7a..000000000000 --- a/flex/engines/graph_db/grin/include +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bcafca761f7ac44f2fb20f599d8ce7c13daae3d9 diff --git a/flex/GRIN b/flex/grin similarity index 100% rename from flex/GRIN rename to flex/grin From 5168b13e133a6f68d66cac0657f3abd166d09ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 15:29:20 +0800 Subject: [PATCH 20/30] add CI --- .github/workflows/flex.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/flex.yml b/.github/workflows/flex.yml index 2f751b3112a8..3e6763729e00 100644 --- a/.github/workflows/flex.yml +++ b/.github/workflows/flex.yml @@ -44,4 +44,10 @@ jobs: run: | cd flex mkdir build && cd build - cmake .. && make -j$(nproc) \ No newline at end of file + cmake .. && make -j$(nproc) + - name: GRIN on Mutable Csr Test + run: | + cd flex/engines/graph_db/grin + mkdir build && cd build + cmake .. && make -j$(nproc) + ./run_grin_test \ No newline at end of file From 9f76b6973d0ca33318afbcb879ebaefc3b830b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 15:40:17 +0800 Subject: [PATCH 21/30] add CI --- .github/workflows/flex.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flex.yml b/.github/workflows/flex.yml index 473fb06f5d81..78980d5e931a 100644 --- a/.github/workflows/flex.yml +++ b/.github/workflows/flex.yml @@ -47,8 +47,9 @@ jobs: cd ${GITHUB_WORKSPACE}/flex mkdir build && cd build cmake .. && sudo make -j$(nproc) - - - name: GRIN on Mutable Csr Test + + + - name: GRIN on mutable csr test run: | cd flex/engines/graph_db/grin mkdir build && cd build From 576aaae07b01f0be81f9d792aba531ce8cd17278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 15:43:50 +0800 Subject: [PATCH 22/30] add CI --- .github/workflows/flex.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flex.yml b/.github/workflows/flex.yml index 78980d5e931a..a4926a05f317 100644 --- a/.github/workflows/flex.yml +++ b/.github/workflows/flex.yml @@ -53,5 +53,5 @@ jobs: run: | cd flex/engines/graph_db/grin mkdir build && cd build - cmake .. && make -j$(nproc) + cmake .. && sudo make -j$(nproc) ./run_grin_test From 6e67c565173f93822e3c984017192b3cbfc0f8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 15:49:58 +0800 Subject: [PATCH 23/30] add CI --- .github/workflows/flex.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flex.yml b/.github/workflows/flex.yml index a4926a05f317..e3a911dfbfa5 100644 --- a/.github/workflows/flex.yml +++ b/.github/workflows/flex.yml @@ -47,10 +47,10 @@ jobs: cd ${GITHUB_WORKSPACE}/flex mkdir build && cd build cmake .. && sudo make -j$(nproc) - - name: GRIN on mutable csr test run: | + git submodule update --init cd flex/engines/graph_db/grin mkdir build && cd build cmake .. && sudo make -j$(nproc) From ff245a65accb92bd79e77f8a5c7f3650fb09834d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 17:03:11 +0800 Subject: [PATCH 24/30] add CI --- flex/engines/graph_db/grin/CMakeLists.txt | 4 ++-- flex/engines/graph_db/grin/src/property/topology.cc | 4 ++-- flex/engines/graph_db/grin/src/property/type.cc | 7 ++++--- flex/engines/graph_db/grin/src/topology/structure.cc | 4 ++++ flex/engines/graph_db/grin/test/test.c | 3 +-- .../storages/rt_mutable_graph/modern_graph/bulk_load.yaml | 8 ++++---- .../modern_graph/person_created_software.csv | 2 +- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/flex/engines/graph_db/grin/CMakeLists.txt b/flex/engines/graph_db/grin/CMakeLists.txt index 99d717c5dea6..3a066292b992 100644 --- a/flex/engines/graph_db/grin/CMakeLists.txt +++ b/flex/engines/graph_db/grin/CMakeLists.txt @@ -9,8 +9,8 @@ project(grin_reader LANGUAGES C CXX VERSION ${GRIN_READER_VERSION}) # Set flags set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") # ------------------------------------------------------------------------------ # find_libraries diff --git a/flex/engines/graph_db/grin/src/property/topology.cc b/flex/engines/graph_db/grin/src/property/topology.cc index 9b43d24dea94..c181c1247fdd 100644 --- a/flex/engines/graph_db/grin/src/property/topology.cc +++ b/flex/engines/graph_db/grin/src/property/topology.cc @@ -31,7 +31,7 @@ size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { auto oe = _g->get_oe_csr(src_label, dst_label, edge_label); auto vertex_num = _g->vertex_num(src_label); size_t edge_num = 0; - for (auto i = 0; i < vertex_num; ++i) { + for (size_t i = 0; i < vertex_num; ++i) { edge_num += oe->edge_iter(i)->size(); } if (edge_num != 0) { @@ -39,7 +39,7 @@ size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { } auto ie = _g->get_ie_csr(dst_label, src_label, edge_label); vertex_num = _g->vertex_num(dst_label); - for (auto i = 0; i < vertex_num; ++i) { + for (size_t i = 0; i < vertex_num; ++i) { edge_num += ie->edge_iter(i)->size(); } return edge_num; diff --git a/flex/engines/graph_db/grin/src/property/type.cc b/flex/engines/graph_db/grin/src/property/type.cc index b134eb409944..75467104f659 100644 --- a/flex/engines/graph_db/grin/src/property/type.cc +++ b/flex/engines/graph_db/grin/src/property/type.cc @@ -124,11 +124,12 @@ GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH g) { auto etl = new GRIN_EDGE_TYPE_LIST_T(); auto edge_label_num = _g->edge_label_num_; auto vertex_label_num = _g->vertex_label_num_; - for (auto src_label_i = 0; src_label_i < vertex_label_num; ++src_label_i) { + for (size_t src_label_i = 0; src_label_i < vertex_label_num; ++src_label_i) { const auto& src_label = _g->schema().get_vertex_label_name(src_label_i); - for (auto dst_label_i = 0; dst_label_i < vertex_label_num; ++dst_label_i) { + for (size_t dst_label_i = 0; dst_label_i < vertex_label_num; + ++dst_label_i) { const auto& dst_label = _g->schema().get_vertex_label_name(dst_label_i); - for (auto edge_label_i = 0; edge_label_i < edge_label_num; + for (size_t edge_label_i = 0; edge_label_i < edge_label_num; ++edge_label_i) { const auto& edge_label = _g->schema().get_edge_label_name(edge_label_i); if (_g->schema().exist(src_label, dst_label, edge_label)) { diff --git a/flex/engines/graph_db/grin/src/topology/structure.cc b/flex/engines/graph_db/grin/src/topology/structure.cc index 6181cb8c2fe8..4b2177e830e3 100644 --- a/flex/engines/graph_db/grin/src/topology/structure.cc +++ b/flex/engines/graph_db/grin/src/topology/structure.cc @@ -38,6 +38,10 @@ GRIN_GRAPH grin_get_graph_from_storage(const char* uri) { std::string graph_schema_path = _uri + "/modern_graph.yaml"; std::string data_path = uri; std::string bulk_load_config_path = _uri + "/bulk_load.yaml"; + if (!std::filesystem::exists(graph_schema_path) || + !(std::filesystem::exists(bulk_load_config_path))) { + return GRIN_NULL_GRAPH; + } auto ret = gs::Schema::LoadFromYaml(graph_schema_path, bulk_load_config_path); const auto& schema = std::get<0>(ret); auto& vertex_files = std::get<1>(ret); diff --git a/flex/engines/graph_db/grin/test/test.c b/flex/engines/graph_db/grin/test/test.c index c2117e108b8c..4612d041885b 100644 --- a/flex/engines/graph_db/grin/test/test.c +++ b/flex/engines/graph_db/grin/test/test.c @@ -1054,8 +1054,7 @@ void test_perf(const char* uri_str) { test_vertex_property_value(uri_str); } int main(int argc, char** argv) { const char* uri_str = "flex://" - "/Users/liulx/Downloads/code/GraphScope/flex/storages/rt_mutable_graph/" - "modern_graph"; + "../../../../storages/rt_mutable_graph/modern_graph/"; test_index(uri_str); test_property(uri_str); diff --git a/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml b/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml index 33d3874a89b0..2b44146d37b8 100644 --- a/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml +++ b/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml @@ -2,22 +2,22 @@ graph: vertex: - label_name: person files: - - path: person.csv + - path: ../../../../storages/rt_mutable_graph/modern_graph/person.csv format: standard_csv - label_name: software files: - - path: software.csv + - path: ../../../../storages/rt_mutable_graph/modern_graph/software.csv format: standard_csv edge: - src_label_name: person dst_label_name: software edge_label_name: created files: - - path: person_created_software.csv + - path: ../../../../storages/rt_mutable_graph/modern_graph/person_created_software.csv format: standard_csv - src_label_name: person dst_label_name: person edge_label_name: knows files: - - path: person_knows_person.csv + - path: ../../../../storages/rt_mutable_graph/modern_graph/person_knows_person.csv format: standard_csv \ No newline at end of file diff --git a/flex/storages/rt_mutable_graph/modern_graph/person_created_software.csv b/flex/storages/rt_mutable_graph/modern_graph/person_created_software.csv index 2b1d262322b5..248331e15956 100644 --- a/flex/storages/rt_mutable_graph/modern_graph/person_created_software.csv +++ b/flex/storages/rt_mutable_graph/modern_graph/person_created_software.csv @@ -2,4 +2,4 @@ person.id|software.id|weight 1|3|0.4 4|3|0.4 6|3|0.2 -4|5|1.0 \ No newline at end of file +2|5|1.0 \ No newline at end of file From 04aa88aa6eeed4b19c20860105ecd5b410d1e15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 18:14:31 +0800 Subject: [PATCH 25/30] add CI --- .github/workflows/flex.yml | 1 + .../modern_graph/bulk_load.yaml | 8 ++--- flex/storages/rt_mutable_graph/schema.cc | 32 ++++++++++++++++--- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/flex.yml b/.github/workflows/flex.yml index e3a911dfbfa5..54fded3178b1 100644 --- a/.github/workflows/flex.yml +++ b/.github/workflows/flex.yml @@ -54,4 +54,5 @@ jobs: cd flex/engines/graph_db/grin mkdir build && cd build cmake .. && sudo make -j$(nproc) + export FLEX_DATA_DIR=../../../../storages/rt_mutable_graph/modern_graph ./run_grin_test diff --git a/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml b/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml index 2b44146d37b8..33d3874a89b0 100644 --- a/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml +++ b/flex/storages/rt_mutable_graph/modern_graph/bulk_load.yaml @@ -2,22 +2,22 @@ graph: vertex: - label_name: person files: - - path: ../../../../storages/rt_mutable_graph/modern_graph/person.csv + - path: person.csv format: standard_csv - label_name: software files: - - path: ../../../../storages/rt_mutable_graph/modern_graph/software.csv + - path: software.csv format: standard_csv edge: - src_label_name: person dst_label_name: software edge_label_name: created files: - - path: ../../../../storages/rt_mutable_graph/modern_graph/person_created_software.csv + - path: person_created_software.csv format: standard_csv - src_label_name: person dst_label_name: person edge_label_name: knows files: - - path: ../../../../storages/rt_mutable_graph/modern_graph/person_knows_person.csv + - path: person_knows_person.csv format: standard_csv \ No newline at end of file diff --git a/flex/storages/rt_mutable_graph/schema.cc b/flex/storages/rt_mutable_graph/schema.cc index 878e02337869..67e0139d7a70 100644 --- a/flex/storages/rt_mutable_graph/schema.cc +++ b/flex/storages/rt_mutable_graph/schema.cc @@ -545,6 +545,29 @@ static bool parse_edges_schema(YAML::Node node, Schema& schema) { return true; } +static bool access_file(std::string& file_path) { + if (file_path.size() == 0) { + return false; + } + if (file_path[0] == '/') { + std::filesystem::path path(file_path); + return std::filesystem::exists(path); + } + char* flex_data_dir = std::getenv("FLEX_DATA_DIR"); + if (flex_data_dir != NULL) { + auto temp = std::string(flex_data_dir) + file_path; + std::filesystem::path path(temp); + if (std::filesystem::exists(path)) { + file_path = temp; + return true; + } + } + file_path = + std::filesystem::current_path().generic_string() + "/" + file_path; + std::filesystem::path path(file_path); + return std::filesystem::exists(path); +} + static bool parse_vertex_files( YAML::Node node, std::vector>& files) { std::string label_name; @@ -571,10 +594,10 @@ static bool parse_vertex_files( if (!get_scalar(files_node[i], "path", file_path)) { return false; } - std::filesystem::path path(file_path); - if (!std::filesystem::exists(path)) { + if (!access_file(file_path)) { LOG(ERROR) << "vertex file - " << file_path << " file not found..."; } + std::filesystem::path path(file_path); files.emplace_back(label_name, std::filesystem::canonical(path)); } return true; @@ -632,10 +655,11 @@ static bool parse_edge_files( if (!get_scalar(files_node[i], "path", file_path)) { return false; } - std::filesystem::path path(file_path); - if (!std::filesystem::exists(path)) { + if (!access_file(file_path)) { LOG(ERROR) << "edge file - " << file_path << " file not found..."; } + std::filesystem::path path(file_path); + printf("file_path === %s\n", file_path.c_str()); files.emplace_back(src_label, dst_label, edge_label, std::filesystem::canonical(path)); } From 6c283a48ac90ec3f20a482eb137a471d3a195668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 18:21:24 +0800 Subject: [PATCH 26/30] add CI --- .github/workflows/flex.yml | 2 +- flex/engines/graph_db/grin/src/property/propertylist.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flex.yml b/.github/workflows/flex.yml index 54fded3178b1..84d1e0414703 100644 --- a/.github/workflows/flex.yml +++ b/.github/workflows/flex.yml @@ -54,5 +54,5 @@ jobs: cd flex/engines/graph_db/grin mkdir build && cd build cmake .. && sudo make -j$(nproc) - export FLEX_DATA_DIR=../../../../storages/rt_mutable_graph/modern_graph + export FLEX_DATA_DIR=../../../../storages/rt_mutable_graph/modern_graph/ ./run_grin_test diff --git a/flex/engines/graph_db/grin/src/property/propertylist.cc b/flex/engines/graph_db/grin/src/property/propertylist.cc index c9b96e05f3d9..672ae974b6c4 100644 --- a/flex/engines/graph_db/grin/src/property/propertylist.cc +++ b/flex/engines/graph_db/grin/src/property/propertylist.cc @@ -104,7 +104,7 @@ GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH g, auto edge_label = _g->schema().get_edge_label_name(edge_label_i); auto sz = _g->schema().get_edge_properties(src_label, dst_label, edge_label).size(); - for (auto i = 0; i < sz; ++i) { + for (size_t i = 0; i < sz; ++i) { p->emplace_back(et + (i << 24)); } return p; From 1f9bf477c10e243bcf7770ad5703ffc5ec59b23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 19:01:28 +0800 Subject: [PATCH 27/30] add CI test --- flex/storages/rt_mutable_graph/schema.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flex/storages/rt_mutable_graph/schema.cc b/flex/storages/rt_mutable_graph/schema.cc index 67e0139d7a70..43ad6eccd6ad 100644 --- a/flex/storages/rt_mutable_graph/schema.cc +++ b/flex/storages/rt_mutable_graph/schema.cc @@ -555,7 +555,7 @@ static bool access_file(std::string& file_path) { } char* flex_data_dir = std::getenv("FLEX_DATA_DIR"); if (flex_data_dir != NULL) { - auto temp = std::string(flex_data_dir) + file_path; + auto temp = std::string(flex_data_dir) + "/" + file_path; std::filesystem::path path(temp); if (std::filesystem::exists(path)) { file_path = temp; From 906740586e17c1b6594efc00d915cbb8bc78105d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Tue, 18 Jul 2023 19:05:58 +0800 Subject: [PATCH 28/30] add CI --- flex/storages/rt_mutable_graph/schema.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/flex/storages/rt_mutable_graph/schema.cc b/flex/storages/rt_mutable_graph/schema.cc index 43ad6eccd6ad..c17c78f5d50d 100644 --- a/flex/storages/rt_mutable_graph/schema.cc +++ b/flex/storages/rt_mutable_graph/schema.cc @@ -659,7 +659,6 @@ static bool parse_edge_files( LOG(ERROR) << "edge file - " << file_path << " file not found..."; } std::filesystem::path path(file_path); - printf("file_path === %s\n", file_path.c_str()); files.emplace_back(src_label, dst_label, edge_label, std::filesystem::canonical(path)); } From b2dd5ea9e52d72e8d559664c88033302b5f42d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Wed, 19 Jul 2023 14:24:55 +0800 Subject: [PATCH 29/30] add cache for vertex properties --- .../graph_db/grin/src/index/internal_id.cc | 2 +- flex/engines/graph_db/grin/src/index/pk.cc | 2 +- flex/engines/graph_db/grin/src/predefine.cc | 36 +++++++++ flex/engines/graph_db/grin/src/predefine.h | 12 ++- .../graph_db/grin/src/property/primarykey.cc | 4 +- .../graph_db/grin/src/property/property.cc | 76 +++++++++---------- .../grin/src/property/propertylist.cc | 15 ++-- .../engines/graph_db/grin/src/property/row.cc | 15 ++-- .../graph_db/grin/src/property/topology.cc | 12 +-- .../graph_db/grin/src/property/type.cc | 29 +++---- .../grin/src/topology/adjacentlist.cc | 4 +- .../graph_db/grin/src/topology/structure.cc | 4 +- 12 files changed, 127 insertions(+), 84 deletions(-) diff --git a/flex/engines/graph_db/grin/src/index/internal_id.cc b/flex/engines/graph_db/grin/src/index/internal_id.cc index 1be66927ccf4..923f5692d988 100644 --- a/flex/engines/graph_db/grin/src/index/internal_id.cc +++ b/flex/engines/graph_db/grin/src/index/internal_id.cc @@ -85,7 +85,7 @@ GRIN_VERTEX grin_get_vertex_by_internal_id_by_type(GRIN_GRAPH g, long long int grin_get_vertex_internal_id_upper_bound_by_type( GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { auto _g = static_cast(g); - return _g->vertex_num(vt); + return _g->g.vertex_num(vt); } /** diff --git a/flex/engines/graph_db/grin/src/index/pk.cc b/flex/engines/graph_db/grin/src/index/pk.cc index 73df6ce38f09..6227edd46482 100644 --- a/flex/engines/graph_db/grin/src/index/pk.cc +++ b/flex/engines/graph_db/grin/src/index/pk.cc @@ -34,7 +34,7 @@ GRIN_VERTEX grin_get_vertex_by_primary_keys_row(GRIN_GRAPH g, auto oid = *static_cast((*_r)[0]); uint32_t vid; - if (!_g->get_lid(label, oid, vid)) { + if (!_g->g.get_lid(label, oid, vid)) { return GRIN_NULL_VERTEX; } uint64_t v = ((label * 1ull) << 32) + vid; diff --git a/flex/engines/graph_db/grin/src/predefine.cc b/flex/engines/graph_db/grin/src/predefine.cc index 8afdc169258e..75ee84d8e3b0 100644 --- a/flex/engines/graph_db/grin/src/predefine.cc +++ b/flex/engines/graph_db/grin/src/predefine.cc @@ -14,4 +14,40 @@ GRIN_DATATYPE _get_data_type(const gs::PropertyType& type) { } else { return GRIN_DATATYPE::Undefined; } +} + +void init_cache(GRIN_GRAPH_T* g) { + auto v_label_num = g->g.vertex_label_num_; + for (size_t i = 0; i < v_label_num; ++i) { + std::vector tmp; + const auto& vec = g->g.schema().get_vertex_properties(i); + const auto& table = g->g.get_vertex_table(i); + for (size_t idx = 0; idx < vec.size(); ++idx) { + const auto& type = vec[idx]; + if (type == gs::PropertyType::kInt32) { + tmp.emplace_back(std::dynamic_pointer_cast( + table.get_column_by_id(idx)) + .get()); + } else if (type == gs::PropertyType::kInt64) { + tmp.emplace_back(std::dynamic_pointer_cast( + table.get_column_by_id(idx)) + .get()); + } else if (type == gs::PropertyType::kString) { + tmp.emplace_back(std::dynamic_pointer_cast( + table.get_column_by_id(idx)) + .get()); + } else if (type == gs::PropertyType::kDate) { + tmp.emplace_back(std::dynamic_pointer_cast( + table.get_column_by_id(idx)) + .get()); + } else if (type == gs::PropertyType::kDouble) { + tmp.emplace_back(std::dynamic_pointer_cast( + table.get_column_by_id(idx)) + .get()); + } else { + tmp.emplace_back((const void*) NULL); + } + } + g->vproperties.emplace_back(tmp); + } } \ No newline at end of file diff --git a/flex/engines/graph_db/grin/src/predefine.h b/flex/engines/graph_db/grin/src/predefine.h index 39a26b6c7222..a04ccf186565 100644 --- a/flex/engines/graph_db/grin/src/predefine.h +++ b/flex/engines/graph_db/grin/src/predefine.h @@ -1,11 +1,16 @@ -#include "grin/predefine.h" +#include +#include "grin/predefine.h" #include "storages/rt_mutable_graph/mutable_property_fragment.h" typedef gs::oid_t GRIN_OID_T; typedef gs::vid_t GRIN_VID_T; -typedef gs::MutablePropertyFragment GRIN_GRAPH_T; +typedef struct GRIN_GRAPH_T { + gs::MutablePropertyFragment g; + std::vector> vproperties; + // std::vector> eproperties; +} GRIN_GRAPH_T; typedef struct GRIN_EDGE_T { GRIN_VERTEX dst; @@ -29,4 +34,5 @@ typedef std::vector GRIN_EDGE_TYPE_LIST_T; typedef std::vector GRIN_EDGE_PROPERTY_LIST_T; #endif -GRIN_DATATYPE _get_data_type(const gs::PropertyType& type); \ No newline at end of file +GRIN_DATATYPE _get_data_type(const gs::PropertyType& type); +void init_cache(GRIN_GRAPH_T* g); \ No newline at end of file diff --git a/flex/engines/graph_db/grin/src/property/primarykey.cc b/flex/engines/graph_db/grin/src/property/primarykey.cc index 3c4fe3bf1cbc..878fa0b2b32f 100644 --- a/flex/engines/graph_db/grin/src/property/primarykey.cc +++ b/flex/engines/graph_db/grin/src/property/primarykey.cc @@ -12,7 +12,7 @@ GRIN_VERTEX_TYPE_LIST grin_get_vertex_types_with_primary_keys(GRIN_GRAPH g) { auto _g = static_cast(g); GRIN_VERTEX_TYPE_LIST_T* vtl = new GRIN_VERTEX_TYPE_LIST_T(); - for (size_t idx = 0; idx < _g->vertex_label_num_; ++idx) { + for (size_t idx = 0; idx < _g->g.vertex_label_num_; ++idx) { vtl->push_back(idx); } return vtl; @@ -49,7 +49,7 @@ GRIN_ROW grin_get_vertex_primary_keys_row(GRIN_GRAPH g, GRIN_VERTEX v) { auto _g = static_cast(g); auto vid = v & (0xffffffff); auto label = v >> 32; - auto oid = _g->get_oid(label, vid); + auto oid = _g->g.get_oid(label, vid); auto p = new gs::oid_t(oid); row->emplace_back(p); return row; diff --git a/flex/engines/graph_db/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc index b31c6aa7f6ee..249a8901b0a2 100644 --- a/flex/engines/graph_db/grin/src/property/property.cc +++ b/flex/engines/graph_db/grin/src/property/property.cc @@ -23,7 +23,7 @@ void grin_destroy_string_value(GRIN_GRAPH g, const char* value) { const char* grin_get_vertex_property_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX_PROPERTY vp) { auto _g = static_cast(g); - auto& table = _g->get_vertex_table(vt); + auto& table = _g->g.get_vertex_table(vt); const auto& name = table.column_name(vp & (0xff)); auto len = name.length() + 1; @@ -36,7 +36,7 @@ GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, const char* name) { auto _g = static_cast(g); - auto& table = _g->get_vertex_table(vt); + auto& table = _g->g.get_vertex_table(vt); auto col = table.get_column(name); if (col == nullptr) { return GRIN_NULL_VERTEX_PROPERTY; @@ -54,8 +54,8 @@ GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_properties_by_name(GRIN_GRAPH g, std::string prop_name(name); auto vps = new GRIN_VERTEX_PROPERTY_LIST_T(); std::string _name = std::string(name); - for (auto idx = 0; idx < _g->schema().vertex_label_num(); idx++) { - auto& table = _g->get_vertex_table(static_cast(idx)); + for (auto idx = 0; idx < _g->g.vertex_label_num_; idx++) { + auto& table = _g->g.get_vertex_table(static_cast(idx)); auto col = table.get_column(name); @@ -103,13 +103,12 @@ int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, grin_error_code = INVALID_VALUE; return 0; } - auto& table = _g->get_vertex_table(plabel); - auto col = - std::dynamic_pointer_cast(table.get_column_by_id(pid)); - if (col == nullptr) { + auto pcol = _g->vproperties[label][pid]; + if (pcol == NULL) { grin_error_code = INVALID_VALUE; return 0; } + auto col = static_cast(pcol); return col->get_view(vid); } @@ -134,13 +133,12 @@ long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, grin_error_code = INVALID_VALUE; return 0; } - auto& table = _g->get_vertex_table(plabel); - auto col = - std::dynamic_pointer_cast(table.get_column_by_id(pid)); - if (col == nullptr) { + auto pcol = _g->vproperties[label][pid]; + if (pcol == NULL) { grin_error_code = INVALID_VALUE; return 0; } + auto col = static_cast(pcol); return col->get_view(vid); } @@ -169,14 +167,12 @@ double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, grin_error_code = INVALID_VALUE; return 0.0; } - auto& table = _g->get_vertex_table(plabel); - - auto col = - std::dynamic_pointer_cast(table.get_column_by_id(pid)); - if (col == nullptr) { + auto pcol = _g->vproperties[label][pid]; + if (pcol == NULL) { grin_error_code = INVALID_VALUE; - return 0.0; + return 0; } + auto col = static_cast(pcol); return col->get_view(vid); } @@ -194,13 +190,13 @@ const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, grin_error_code = INVALID_VALUE; return NULL; } - auto& table = _g->get_vertex_table(plabel); - auto col = - std::dynamic_pointer_cast(table.get_column_by_id(pid)); - if (col == nullptr) { + auto pcol = _g->vproperties[label][pid]; + if (pcol == NULL) { grin_error_code = INVALID_VALUE; - return NULL; + return 0; } + auto col = static_cast(pcol); + auto s = col->get_view(vid); auto len = s.size() + 1; char* out = new char[len]; @@ -234,13 +230,12 @@ long long int grin_get_vertex_property_value_of_timestamp64( return 0; } - auto& table = _g->get_vertex_table(plabel); - auto col = - std::dynamic_pointer_cast(table.get_column_by_id(pid)); - if (col == nullptr) { + auto pcol = _g->vproperties[label][pid]; + if (pcol == NULL) { grin_error_code = INVALID_VALUE; return 0; } + auto col = static_cast(pcol); return col->get_view(vid).milli_second; } @@ -258,29 +253,34 @@ const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, auto pid = vp & (0xff); auto _g = static_cast(g); - auto& table = _g->get_vertex_table(plabel); - const auto& col = table.get_column_by_id(pid); + + auto col = _g->vproperties[plabel][pid]; + if (col == NULL) { + grin_error_code = UNKNOWN_DATATYPE; + return 0; + } + auto vid = v & (0xffffffff); switch (type) { case GRIN_DATATYPE::Int32: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); return _col->buffer().data() + vid; } case GRIN_DATATYPE::Int64: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); return _col->buffer().data() + vid; } case GRIN_DATATYPE::String: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); return _col->buffer()[vid].data(); } case GRIN_DATATYPE::Timestamp64: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); return _col->buffer().data() + vid; } case GRIN_DATATYPE::Double: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); return _col->buffer().data() + vid; } default: @@ -302,13 +302,13 @@ GRIN_DATATYPE grin_get_edge_property_datatype(GRIN_GRAPH g, GRIN_EDGE_PROPERTY ep) { auto _g = static_cast(g); auto src_label_i = (ep >> 16) & 0xff; - const auto& src_label = _g->schema().get_vertex_label_name(src_label_i); + const auto& src_label = _g->g.schema().get_vertex_label_name(src_label_i); auto dst_label_i = (ep >> 8) & 0xff; - const auto& dst_label = _g->schema().get_vertex_label_name(dst_label_i); + const auto& dst_label = _g->g.schema().get_vertex_label_name(dst_label_i); auto edge_label_i = ep & 0xff; - const auto& edge_label = _g->schema().get_edge_label_name(edge_label_i); + const auto& edge_label = _g->g.schema().get_edge_label_name(edge_label_i); const auto& type = - _g->schema().get_edge_properties(src_label, dst_label, edge_label); + _g->g.schema().get_edge_properties(src_label, dst_label, edge_label); auto idx = ep >> 24; return _get_data_type(type[idx]); } diff --git a/flex/engines/graph_db/grin/src/property/propertylist.cc b/flex/engines/graph_db/grin/src/property/propertylist.cc index 672ae974b6c4..a52639f105c9 100644 --- a/flex/engines/graph_db/grin/src/property/propertylist.cc +++ b/flex/engines/graph_db/grin/src/property/propertylist.cc @@ -18,7 +18,7 @@ limitations under the License. GRIN_VERTEX_PROPERTY_LIST grin_get_vertex_property_list_by_type( GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { auto _g = static_cast(g); - auto& table = _g->get_vertex_table(vt); + auto& table = _g->g.get_vertex_table(vt); auto vertex_prop_num = table.col_num(); GRIN_VERTEX_PROPERTY_LIST_T* vpl = new GRIN_VERTEX_PROPERTY_LIST_T(); @@ -69,7 +69,7 @@ GRIN_VERTEX_PROPERTY grin_get_vertex_property_by_id( GRIN_GRAPH g, GRIN_VERTEX_TYPE vt, GRIN_VERTEX_PROPERTY_ID pid) { auto _g = static_cast(g); - auto& table = _g->get_vertex_table(vt); + auto& table = _g->g.get_vertex_table(vt); auto vertex_prop_num = table.col_num(); if (pid >= vertex_prop_num) { @@ -97,13 +97,14 @@ GRIN_EDGE_PROPERTY_LIST grin_get_edge_property_list_by_type(GRIN_GRAPH g, auto _g = static_cast(g); auto src_label_i = et >> 16; - auto src_label = _g->schema().get_vertex_label_name(src_label_i); + auto src_label = _g->g.schema().get_vertex_label_name(src_label_i); auto dst_label_i = (et >> 8) & (0xff); - auto dst_label = _g->schema().get_vertex_label_name(dst_label_i); + auto dst_label = _g->g.schema().get_vertex_label_name(dst_label_i); auto edge_label_i = et & 0xff; - auto edge_label = _g->schema().get_edge_label_name(edge_label_i); - auto sz = - _g->schema().get_edge_properties(src_label, dst_label, edge_label).size(); + auto edge_label = _g->g.schema().get_edge_label_name(edge_label_i); + auto sz = _g->g.schema() + .get_edge_properties(src_label, dst_label, edge_label) + .size(); for (size_t i = 0; i < sz; ++i) { p->emplace_back(et + (i << 24)); } diff --git a/flex/engines/graph_db/grin/src/property/row.cc b/flex/engines/graph_db/grin/src/property/row.cc index 9bb28bceaa3a..5311ca43bfbe 100644 --- a/flex/engines/graph_db/grin/src/property/row.cc +++ b/flex/engines/graph_db/grin/src/property/row.cc @@ -180,41 +180,40 @@ GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { auto _g = static_cast(g); auto vid = v & (0xffffffff); auto label = v >> 32; - auto& table = _g->get_vertex_table(label); + auto& table = _g->g.get_vertex_table(label); auto prop_size = table.col_num(); const auto& types = table.column_types(); auto r = new GRIN_ROW_T(); for (size_t prop_id = 0; prop_id < prop_size; prop_id++) { - auto col = table.get_column_by_id(prop_id); + auto col = _g->vproperties[label][prop_id]; auto type = _get_data_type(types[prop_id]); switch (type) { case GRIN_DATATYPE::Int32: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); r->emplace_back(_col->buffer().data() + vid); break; } case GRIN_DATATYPE::Int64: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); r->emplace_back(_col->buffer().data() + vid); break; } case GRIN_DATATYPE::String: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); auto s = _col->get_view(vid); auto len = s.size() + 1; char* out = new char[len]; snprintf(out, len, "%s", s.data()); - r->emplace_back(out); break; } case GRIN_DATATYPE::Timestamp64: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); r->emplace_back(_col->buffer().data() + vid); break; } case GRIN_DATATYPE::Double: { - auto _col = std::dynamic_pointer_cast(col); + auto _col = static_cast(col); r->emplace_back(_col->buffer().data() + vid); break; } diff --git a/flex/engines/graph_db/grin/src/property/topology.cc b/flex/engines/graph_db/grin/src/property/topology.cc index c181c1247fdd..5a58e07ecb03 100644 --- a/flex/engines/graph_db/grin/src/property/topology.cc +++ b/flex/engines/graph_db/grin/src/property/topology.cc @@ -17,7 +17,7 @@ limitations under the License. #ifdef GRIN_WITH_VERTEX_PROPERTY size_t grin_get_vertex_num_by_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { auto _g = static_cast(g); - return _g->vertex_num(vt); + return _g->g.vertex_num(vt); } #endif @@ -28,8 +28,8 @@ size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { auto edge_label = et & (0xff); auto _g = static_cast(g); - auto oe = _g->get_oe_csr(src_label, dst_label, edge_label); - auto vertex_num = _g->vertex_num(src_label); + auto oe = _g->g.get_oe_csr(src_label, dst_label, edge_label); + auto vertex_num = _g->g.vertex_num(src_label); size_t edge_num = 0; for (size_t i = 0; i < vertex_num; ++i) { edge_num += oe->edge_iter(i)->size(); @@ -37,8 +37,8 @@ size_t grin_get_edge_num_by_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { if (edge_num != 0) { return edge_num; } - auto ie = _g->get_ie_csr(dst_label, src_label, edge_label); - vertex_num = _g->vertex_num(dst_label); + auto ie = _g->g.get_ie_csr(dst_label, src_label, edge_label); + vertex_num = _g->g.vertex_num(dst_label); for (size_t i = 0; i < vertex_num; ++i) { edge_num += ie->edge_iter(i)->size(); } @@ -52,7 +52,7 @@ GRIN_VERTEX_LIST grin_get_vertex_list_by_type(GRIN_GRAPH g, GRIN_VERTEX_LIST vl; vl.label = vt; auto _g = static_cast(g); - vl.vertex_num = _g->vertex_num(vt); + vl.vertex_num = _g->g.vertex_num(vt); return vl; } #endif diff --git a/flex/engines/graph_db/grin/src/property/type.cc b/flex/engines/graph_db/grin/src/property/type.cc index 75467104f659..ea40c524b980 100644 --- a/flex/engines/graph_db/grin/src/property/type.cc +++ b/flex/engines/graph_db/grin/src/property/type.cc @@ -31,7 +31,7 @@ void grin_destroy_vertex_type(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) {} GRIN_VERTEX_TYPE_LIST grin_get_vertex_type_list(GRIN_GRAPH g) { auto _g = static_cast(g); auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); - auto vertex_label_num = _g->schema().vertex_label_num(); + auto vertex_label_num = _g->g.schema().vertex_label_num(); for (size_t idx = 0; idx < vertex_label_num; ++idx) { vtl->push_back(idx); } @@ -71,7 +71,7 @@ GRIN_VERTEX_TYPE grin_get_vertex_type_from_list(GRIN_GRAPH g, #ifdef GRIN_WITH_VERTEX_TYPE_NAME const char* grin_get_vertex_type_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { auto _g = static_cast(g); - std::string type_name = _g->schema().get_vertex_label_name(vt); + std::string type_name = _g->g.schema().get_vertex_label_name(vt); auto len = type_name.length() + 1; char* out = new char[len]; snprintf(out, len, "%s", type_name.c_str()); @@ -81,10 +81,10 @@ const char* grin_get_vertex_type_name(GRIN_GRAPH g, GRIN_VERTEX_TYPE vt) { GRIN_VERTEX_TYPE grin_get_vertex_type_by_name(GRIN_GRAPH g, const char* name) { auto _g = static_cast(g); std::string type_name(name); - if ((!_g->schema().contains_vertex_label(type_name))) { + if ((!_g->g.schema().contains_vertex_label(type_name))) { return GRIN_NULL_VERTEX_TYPE; } - auto type = _g->schema().get_vertex_label_id(type_name); + auto type = _g->g.schema().get_vertex_label_id(type_name); return type; } #endif @@ -122,17 +122,18 @@ void grin_destroy_edge_type(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { GRIN_EDGE_TYPE_LIST grin_get_edge_type_list(GRIN_GRAPH g) { auto _g = static_cast(g); auto etl = new GRIN_EDGE_TYPE_LIST_T(); - auto edge_label_num = _g->edge_label_num_; - auto vertex_label_num = _g->vertex_label_num_; + auto edge_label_num = _g->g.edge_label_num_; + auto vertex_label_num = _g->g.vertex_label_num_; for (size_t src_label_i = 0; src_label_i < vertex_label_num; ++src_label_i) { - const auto& src_label = _g->schema().get_vertex_label_name(src_label_i); + const auto& src_label = _g->g.schema().get_vertex_label_name(src_label_i); for (size_t dst_label_i = 0; dst_label_i < vertex_label_num; ++dst_label_i) { - const auto& dst_label = _g->schema().get_vertex_label_name(dst_label_i); + const auto& dst_label = _g->g.schema().get_vertex_label_name(dst_label_i); for (size_t edge_label_i = 0; edge_label_i < edge_label_num; ++edge_label_i) { - const auto& edge_label = _g->schema().get_edge_label_name(edge_label_i); - if (_g->schema().exist(src_label, dst_label, edge_label)) { + const auto& edge_label = + _g->g.schema().get_edge_label_name(edge_label_i); + if (_g->g.schema().exist(src_label, dst_label, edge_label)) { auto label = (src_label_i << 16) + (dst_label_i << 8) + edge_label_i; etl->push_back(label); } @@ -175,7 +176,7 @@ GRIN_EDGE_TYPE grin_get_edge_type_from_list(GRIN_GRAPH g, #ifdef GRIN_WITH_EDGE_TYPE_NAME const char* grin_get_edge_type_name(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { auto _g = static_cast(g); - const auto& schema = _g->schema(); + const auto& schema = _g->g.schema(); auto edge_label_i = et & 0xff; auto src_label_i = et >> 16; auto dst_label_i = (et >> 8) & 0xff; @@ -192,7 +193,7 @@ const char* grin_get_edge_type_name(GRIN_GRAPH g, GRIN_EDGE_TYPE et) { GRIN_EDGE_TYPE grin_get_edge_type_by_name(GRIN_GRAPH g, const char* name) { auto _g = static_cast(g); - const auto& schema = _g->schema(); + const auto& schema = _g->g.schema(); std::vector vec; size_t len = strlen(name); std::string ss{}; @@ -253,8 +254,8 @@ GRIN_EDGE_TYPE_LIST grin_get_edge_types_by_vertex_type_pair( auto _g = static_cast(g); auto vtl = new GRIN_VERTEX_TYPE_LIST_T(); - const auto& schema = _g->schema(); - auto edge_label_num = _g->edge_label_num_; + const auto& schema = _g->g.schema(); + auto edge_label_num = _g->g.edge_label_num_; std::string src_label = schema.get_vertex_label_name(static_cast(vt1)); std::string dst_label = diff --git a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc index 2a49cabf9fdc..112da2e552d3 100644 --- a/flex/engines/graph_db/grin/src/topology/adjacentlist.cc +++ b/flex/engines/graph_db/grin/src/topology/adjacentlist.cc @@ -47,7 +47,7 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( if (adj_list.dir == GRIN_DIRECTION::OUT) { if (src_label == v_label) { iter.edge_iter = - _g->get_outgoing_edges_raw(src_label, vid, dst_label, edge_label); + _g->g.get_outgoing_edges_raw(src_label, vid, dst_label, edge_label); } else { iter.edge_iter = nullptr; @@ -55,7 +55,7 @@ GRIN_ADJACENT_LIST_ITERATOR grin_get_adjacent_list_begin( } else { if (dst_label == v_label) { iter.edge_iter = - _g->get_incoming_edges_raw(dst_label, vid, src_label, edge_label); + _g->g.get_incoming_edges_raw(dst_label, vid, src_label, edge_label); } else { iter.edge_iter = nullptr; } diff --git a/flex/engines/graph_db/grin/src/topology/structure.cc b/flex/engines/graph_db/grin/src/topology/structure.cc index 4b2177e830e3..469cfa672c33 100644 --- a/flex/engines/graph_db/grin/src/topology/structure.cc +++ b/flex/engines/graph_db/grin/src/topology/structure.cc @@ -49,7 +49,8 @@ GRIN_GRAPH grin_get_graph_from_storage(const char* uri) { auto& edge_files = std::get<2>(ret); GRIN_GRAPH_T* g = new GRIN_GRAPH_T(); - g->Init(schema, vertex_files, edge_files); + g->g.Init(schema, vertex_files, edge_files); + init_cache(g); return g; } @@ -117,7 +118,6 @@ GRIN_DATATYPE grin_get_edge_data_datatype(GRIN_GRAPH, GRIN_EDGE e) { const void* grin_get_edge_data_value(GRIN_GRAPH, GRIN_EDGE e) { auto _e = static_cast(e); - // new 返回? auto type = _e->data.type; switch (_get_data_type(type)) { case GRIN_DATATYPE::Int32: { From a5d95743e654966f776bf0398dbfed487739a1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=90=E7=AE=AB?= Date: Wed, 19 Jul 2023 14:33:46 +0800 Subject: [PATCH 30/30] add cache for vertex properties --- .../graph_db/grin/src/property/property.cc | 37 ++++++++++++++++++- .../engines/graph_db/grin/src/property/row.cc | 4 ++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/flex/engines/graph_db/grin/src/property/property.cc b/flex/engines/graph_db/grin/src/property/property.cc index 249a8901b0a2..0a5c2d2f4262 100644 --- a/flex/engines/graph_db/grin/src/property/property.cc +++ b/flex/engines/graph_db/grin/src/property/property.cc @@ -103,6 +103,11 @@ int grin_get_vertex_property_value_of_int32(GRIN_GRAPH g, GRIN_VERTEX v, grin_error_code = INVALID_VALUE; return 0; } + if (label >= _g->g.vertex_label_num_ || + pid >= _g->vproperties[label].size()) { + grin_error_code = INVALID_VALUE; + return 0; + } auto pcol = _g->vproperties[label][pid]; if (pcol == NULL) { grin_error_code = INVALID_VALUE; @@ -133,10 +138,16 @@ long long int grin_get_vertex_property_value_of_int64(GRIN_GRAPH g, grin_error_code = INVALID_VALUE; return 0; } + + if (label >= _g->g.vertex_label_num_ || + pid >= _g->vproperties[label].size()) { + grin_error_code = INVALID_VALUE; + return 0; + } auto pcol = _g->vproperties[label][pid]; if (pcol == NULL) { grin_error_code = INVALID_VALUE; - return 0; + return 0.0f; } auto col = static_cast(pcol); return col->get_view(vid); @@ -167,6 +178,12 @@ double grin_get_vertex_property_value_of_double(GRIN_GRAPH g, GRIN_VERTEX v, grin_error_code = INVALID_VALUE; return 0.0; } + + if (label >= _g->g.vertex_label_num_ || + pid >= _g->vproperties[label].size()) { + grin_error_code = INVALID_VALUE; + return 0.0; + } auto pcol = _g->vproperties[label][pid]; if (pcol == NULL) { grin_error_code = INVALID_VALUE; @@ -190,10 +207,16 @@ const char* grin_get_vertex_property_value_of_string(GRIN_GRAPH g, grin_error_code = INVALID_VALUE; return NULL; } + + if (label >= _g->g.vertex_label_num_ || + pid >= _g->vproperties[label].size()) { + grin_error_code = INVALID_VALUE; + return ""; + } auto pcol = _g->vproperties[label][pid]; if (pcol == NULL) { grin_error_code = INVALID_VALUE; - return 0; + return ""; } auto col = static_cast(pcol); @@ -230,6 +253,11 @@ long long int grin_get_vertex_property_value_of_timestamp64( return 0; } + if (label >= _g->g.vertex_label_num_ || + pid >= _g->vproperties[label].size()) { + grin_error_code = INVALID_VALUE; + return 0; + } auto pcol = _g->vproperties[label][pid]; if (pcol == NULL) { grin_error_code = INVALID_VALUE; @@ -254,6 +282,11 @@ const void* grin_get_vertex_property_value(GRIN_GRAPH g, GRIN_VERTEX v, auto _g = static_cast(g); + if (plabel >= _g->g.vertex_label_num_ || + pid >= _g->vproperties[plabel].size()) { + grin_error_code = INVALID_VALUE; + return 0; + } auto col = _g->vproperties[plabel][pid]; if (col == NULL) { grin_error_code = UNKNOWN_DATATYPE; diff --git a/flex/engines/graph_db/grin/src/property/row.cc b/flex/engines/graph_db/grin/src/property/row.cc index 5311ca43bfbe..c81af3f08099 100644 --- a/flex/engines/graph_db/grin/src/property/row.cc +++ b/flex/engines/graph_db/grin/src/property/row.cc @@ -180,6 +180,10 @@ GRIN_ROW grin_get_vertex_row(GRIN_GRAPH g, GRIN_VERTEX v) { auto _g = static_cast(g); auto vid = v & (0xffffffff); auto label = v >> 32; + + if (label >= _g->g.vertex_label_num_) { + return NULL; + } auto& table = _g->g.get_vertex_table(label); auto prop_size = table.col_num(); const auto& types = table.column_types();