Query modules C API
This is the API documentation for mg_procedure.h
that contains declarations
of all functions that can be used to implement a query module procedure. The
source file can be found in the Memgraph installation directory, under
/usr/include/memgraph
.
For an example of how to implement query modules in C, take a look at the example we provided.
If you install any C modules after running Memgraph, you'll have to load them into Memgraph or restart Memgraph in order to use them.
Classes
Name | Description |
---|---|
mgp_label | Label of a vertex. |
mgp_edge_type | Type of an edge. |
mgp_property | Reference to a named property value. |
mgp_vertex_id | ID of a vertex; valid during a single query execution. |
mgp_edge_id | ID of an edge; valid during a single query execution. |
mgp_date_parameters | |
mgp_local_time_parameters | |
mgp_local_date_time_parameters | |
mgp_duration_parameters | |
mgp_execution_headers | Headers of the query that's executed through the API. |
mgp_execution_result | Type handling the pulling logic of the query executing through the API. |
Types
Name | |
---|---|
enum | mgp_value_type {MGP_VALUE_TYPE_NULL, MGP_VALUE_TYPE_BOOL, MGP_VALUE_TYPE_INT, MGP_VALUE_TYPE_DOUBLE, MGP_VALUE_TYPE_STRING, MGP_VALUE_TYPE_LIST, MGP_VALUE_TYPE_MAP, MGP_VALUE_TYPE_VERTEX, MGP_VALUE_TYPE_EDGE, MGP_VALUE_TYPE_PATH, MGP_VALUE_TYPE_DATE, MGP_VALUE_TYPE_LOCAL_TIME, MGP_VALUE_TYPE_LOCAL_DATE_TIME, MGP_VALUE_TYPE_DURATION} All available types that can be stored in a mgp_value. |
typedef void(*)(struct mgp_list *, struct mgp_graph *, struct mgp_result *, struct mgp_memory *) | mgp_proc_cb Entry-point for a query module read procedure, invoked through openCypher. |
typedef void(*)(struct mgp_list *, struct mgp_graph *, struct mgp_memory *) | mgp_proc_initializer Initialization point for a query module read procedure, invoked before procedure. |
typedef void(*)() | mgp_proc_cleanup Cleanup for a query module read procedure |
typedef void(*)(struct mgp_messages *, struct mgp_graph *, struct mgp_result *, struct mgp_memory *) | mgp_trans_cb Entry-point for a module transformation, invoked through a stream transformation. |
Functions
Name | |
---|---|
enum mgp_error | mgp_alloc(struct mgp_memory * memory, size_t size_in_bytes, void ** result) Allocate a block of memory with given size in bytes. |
enum mgp_error | mgp_aligned_alloc(struct mgp_memory * memory, size_t size_in_bytes, size_t alignment, void ** result) Allocate an aligned block of memory with given size in bytes. |
void | mgp_free(struct mgp_memory * memory, void * ptr) Deallocate an allocation from mgp_alloc or mgp_aligned_alloc. |
enum mgp_error | mgp_global_alloc(size_t size_in_bytes, void ** result) Allocate a global block of memory with given size in bytes. |
enum mgp_error | mgp_global_aligned_alloc(size_t size_in_bytes, size_t alignment, void ** result) Allocate an aligned global block of memory with given size in bytes. |
void | mgp_global_free(void * p) Deallocate an allocation from mgp_global_alloc or mgp_global_aligned_alloc. |
void | mgp_value_destroy(struct mgp_value * val) Free the memory used by the given mgp_value instance. |
enum mgp_error | mgp_value_make_null(struct mgp_memory * memory, struct mgp_value ** result) Construct a value representing null in openCypher. |
enum mgp_error | mgp_value_make_bool(int val, struct mgp_memory * memory, struct mgp_value ** result) Construct a boolean value. |
enum mgp_error | mgp_value_make_int(int64_t val, struct mgp_memory * memory, struct mgp_value ** result) Construct an integer value. |
enum mgp_error | mgp_value_make_double(double val, struct mgp_memory * memory, struct mgp_value ** result) Construct a double floating point value. |
enum mgp_error | mgp_value_make_string(const char * val, struct mgp_memory * memory, struct mgp_value ** result) Construct a character string value from a NULL terminated string. |
enum mgp_error | mgp_value_make_list(struct mgp_list * val, struct mgp_value ** result) Create a mgp_value storing a mgp_list. |
enum mgp_error | mgp_value_make_map(struct mgp_map * val, struct mgp_value ** result) Create a mgp_value storing a mgp_map. |
enum mgp_error | mgp_value_make_vertex(struct mgp_vertex * val, struct mgp_value ** result) Create a mgp_value storing a mgp_vertex. |
enum mgp_error | mgp_value_make_edge(struct mgp_edge * val, struct mgp_value ** result) Create a mgp_value storing a mgp_edge. |
enum mgp_error | mgp_value_make_path(struct mgp_path * val, struct mgp_value ** result) Create a mgp_value storing a mgp_path. |
enum mgp_error | mgp_value_make_date(struct mgp_date * val, struct mgp_value ** result) Create a mgp_value storing a mgp_date. |
enum mgp_error | mgp_value_make_local_time(struct mgp_local_time * val, struct mgp_value ** result) Create a mgp_value storing a mgp_local_time. |
enum mgp_error | mgp_value_make_local_date_time(struct mgp_local_date_time * val, struct mgp_value ** result) Create a mgp_value storing a mgp_local_date_time. |
enum mgp_error | mgp_value_make_duration(struct mgp_duration * val, struct mgp_value ** result) Create a mgp_value storing a mgp_duration. |
enum mgp_error | mgp_value_get_type(struct mgp_value * val, enum mgp_value_type * result) Get the type of the value contained in mgp_value. |
enum mgp_error | mgp_value_is_null(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value represents null . |
enum mgp_error | mgp_value_is_bool(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a boolean. |
enum mgp_error | mgp_value_is_int(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores an integer. |
enum mgp_error | mgp_value_is_double(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a double floating-point. |
enum mgp_error | mgp_value_is_string(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a character string. |
enum mgp_error | mgp_value_is_list(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a list of values. |
enum mgp_error | mgp_value_is_map(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a map of values. |
enum mgp_error | mgp_value_is_vertex(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a vertex. |
enum mgp_error | mgp_value_is_edge(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores an edge. |
enum mgp_error | mgp_value_is_path(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a path. |
enum mgp_error | mgp_value_is_date(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a date. |
enum mgp_error | mgp_value_is_local_time(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a local time. |
enum mgp_error | mgp_value_is_local_date_time(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a local date-time. |
enum mgp_error | mgp_value_is_duration(struct mgp_value * val, int * result) Result is non-zero if the given mgp_value stores a duration. |
enum mgp_error | mgp_value_get_bool(struct mgp_value * val, int * result) Get the contained boolean value. |
enum mgp_error | mgp_value_get_int(struct mgp_value * val, int64_t * result) Get the contained integer. |
enum mgp_error | mgp_value_get_double(struct mgp_value * val, double * result) Get the contained double floating-point. |
enum mgp_error | mgp_value_get_string(struct mgp_value * val, const char ** result) Get the contained character string. |
enum mgp_error | mgp_value_get_list(struct mgp_value * val, struct mgp_list ** result) Get the contained list of values. |
enum mgp_error | mgp_value_get_map(struct mgp_value * val, struct mgp_map ** result) Get the contained map of values. |
enum mgp_error | mgp_value_get_vertex(struct mgp_value * val, struct mgp_vertex ** result) Get the contained vertex. |
enum mgp_error | mgp_value_get_edge(struct mgp_value * val, struct mgp_edge ** result) Get the contained edge. |
enum mgp_error | mgp_value_get_path(struct mgp_value * val, struct mgp_path ** result) Get the contained path. |
enum mgp_error | mgp_value_get_date(struct mgp_value * val, struct mgp_date ** result) Get the contained date. |
enum mgp_error | mgp_value_get_local_time(struct mgp_value * val, struct mgp_local_time ** result) Get the contained local time. |
enum mgp_error | mgp_value_get_local_date_time(struct mgp_value * val, struct mgp_local_date_time ** result) Get the contained local date-time. |
enum mgp_error | mgp_value_get_duration(struct mgp_value * val, struct mgp_duration ** result) Get the contained duration. |
enum mgp_error | mgp_list_make_empty(size_t capacity, struct mgp_memory * memory, struct mgp_list ** result) Create an empty list with given capacity. |
void | mgp_list_destroy(struct mgp_list * list) Free the memory used by the given mgp_list and contained elements. |
enum mgp_error | mgp_list_contains_deleted(struct mgp_list * list, int * result) Result is non-zero if the given list contains any deleted values, otherwise 0. |
enum mgp_error | mgp_list_append(struct mgp_list * list, struct mgp_value * val) Append a copy of mgp_value to mgp_list if capacity allows. |
enum mgp_error | mgp_list_append_extend(struct mgp_list * list, struct mgp_value * val) Append a copy of mgp_value to mgp_list increasing capacity if needed. |
enum mgp_error | mgp_list_size(struct mgp_list * list, size_t * result) Get the number of elements stored in mgp_list. |
enum mgp_error | mgp_list_capacity(struct mgp_list * list, size_t * result) Get the total number of elements for which there's already allocated memory in mgp_list. |
enum mgp_error | mgp_list_at(struct mgp_list * list, size_t index, struct mgp_value ** result) Get the element in mgp_list at given position. |
enum mgp_error | mgp_map_make_empty(struct mgp_memory * memory, struct mgp_map ** result) Create an empty map of character strings to mgp_value instances. |
void | mgp_map_destroy(struct mgp_map * map) Free the memory used by the given mgp_map and contained items. |
enum mgp_error | mgp_map_contains_deleted(struct mgp_map * map, int * result) Result is non-zero if the given map contains any deleted values, otherwise 0. |
enum mgp_error | mgp_map_insert(struct mgp_map * map, const char * key, struct mgp_value * value) Insert a new mapping from a NULL terminated character string to a value. |
enum mgp_error | mgp_map_update(struct mgp_map * map, const char * key, struct mgp_value * value) Insert a new mapping from a NULL terminated character string to a value, replacing the old value if it exists. |
enum mgp_error | mgp_map_erase(struct mgp_map * map, const char * key) Erase a mapping by key. |
enum mgp_error | mgp_map_size(struct mgp_map * map, size_t * result) Get the number of items stored in mgp_map. |
enum mgp_error | mgp_map_at(struct mgp_map * map, const char * key, struct mgp_value ** result) Get the mapped mgp_value to the given character string. |
enum mgp_error | mgp_map_item_key(struct mgp_map_item * item, const char ** result) Get the key of the mapped item. |
enum mgp_error | mgp_map_item_value(struct mgp_map_item * item, struct mgp_value ** result) Get the value of the mapped item. |
enum mgp_error | mgp_map_iter_items(struct mgp_map * map, struct mgp_memory * memory, struct mgp_map_items_iterator ** result) Start iterating over items contained in the given map. |
void | mgp_map_items_iterator_destroy(struct mgp_map_items_iterator * it) Deallocate memory used by mgp_map_items_iterator. |
enum mgp_error | mgp_map_items_iterator_get(struct mgp_map_items_iterator * it, struct mgp_map_item ** result) Get the current item pointed to by the iterator. |
enum mgp_error | mgp_map_items_iterator_next(struct mgp_map_items_iterator * it, struct mgp_map_item ** result) Advance the iterator to the next item stored in map and return it. |
enum mgp_error | mgp_path_make_with_start(struct mgp_vertex * vertex, struct mgp_memory * memory, struct mgp_path ** result) Create a path with the copy of the given starting vertex. |
enum mgp_error | mgp_path_copy(struct mgp_path * path, struct mgp_memory * memory, struct mgp_path ** result) Copy a mgp_path. |
void | mgp_path_destroy(struct mgp_path * path) Free the memory used by the given mgp_path and contained vertices and edges. |
enum mgp_error | mgp_path_contains_deleted(struct mgp_path * path, int * result) Result is non-zero if the given path contains any deleted vertices or edges, otherwise 0. |
enum mgp_error | mgp_path_expand(struct mgp_path * path, struct mgp_edge * edge) Append an edge continuing from the last vertex on the path. |
enum mgp_error | mgp_path_pop(struct mgp_path * path) Remove the last node and the last relationship from the path. |
enum mgp_error | mgp_path_size(struct mgp_path * path, size_t * result) Get the number of edges in a mgp_path. |
enum mgp_error | mgp_path_vertex_at(struct mgp_path * path, size_t index, struct mgp_vertex ** result) Get the vertex from a path at given index. |
enum mgp_error | mgp_path_edge_at(struct mgp_path * path, size_t index, struct mgp_edge ** result) Get the edge from a path at given index. |
enum mgp_error | mgp_path_equal(struct mgp_path * p1, struct mgp_path * p2, int * result) Result is non-zero if given paths are equal, otherwise 0. |
enum mgp_error | mgp_result_set_error_msg(struct mgp_result * res, const char * error_msg) Set the error as the result of the procedure. |
enum mgp_error | mgp_result_new_record(struct mgp_result * res, struct mgp_result_record ** result) Create a new record for results. |
enum mgp_error | mgp_result_record_insert(struct mgp_result_record * record, const char * field_name, struct mgp_value * val) Assign a value to a field in the given record. |
void | mgp_properties_iterator_destroy(struct mgp_properties_iterator * it) Free the memory used by a mgp_properties_iterator. |
enum mgp_error | mgp_properties_iterator_get(struct mgp_properties_iterator * it, struct mgp_property ** result) Get the current property pointed to by the iterator. |
enum mgp_error | mgp_properties_iterator_next(struct mgp_properties_iterator * it, struct mgp_property ** result) Advance the iterator to the next property and return it. |
void | mgp_edges_iterator_destroy(struct mgp_edges_iterator * it) Free the memory used by a mgp_edges_iterator. |
enum mgp_error | mgp_vertex_get_id(struct mgp_vertex * v, struct mgp_vertex_id * result) Get the ID of given vertex. |
enum mgp_error | mgp_vertex_get_in_degree(struct mgp_vertex * v, size_t * result) Get the in degree of the given vertex. |
enum mgp_error | mgp_vertex_get_out_degree(struct mgp_vertex * v, size_t * result) Get the out degree of the given vertex. |
enum mgp_error | mgp_vertex_underlying_graph_is_mutable(struct mgp_vertex * v, int * result) Result is non-zero if the vertex can be modified. |
enum mgp_error | mgp_vertex_set_property(struct mgp_vertex * v, const char * property_name, struct mgp_value * property_value) Set the value of a property on a vertex. |
enum mgp_error | mgp_vertex_set_properties(struct mgp_vertex *v, struct mgp_map *properties) Set the properties of the given vertex. |
enum mgp_error | mgp_vertex_add_label(struct mgp_vertex * v, struct mgp_label label) Add the label to the vertex. |
enum mgp_error | mgp_vertex_remove_label(struct mgp_vertex * v, struct mgp_label label) Remove the label from the vertex. |
enum mgp_error | mgp_vertex_copy(struct mgp_vertex * v, struct mgp_memory * memory, struct mgp_vertex ** result) Copy a mgp_vertex. |
void | mgp_vertex_destroy(struct mgp_vertex * v) Free the memory used by a mgp_vertex. |
enum mgp_error | mgp_vertex_equal(struct mgp_vertex * v1, struct mgp_vertex * v2, int * result) Result is non-zero if given vertices are equal, otherwise 0. |
enum mgp_error | mgp_vertex_is_deleted(struct mgp_vertex *v, int *result) Result is non-zero if the given vertex is deleted, otherwise 0. |
enum mgp_error | mgp_vertex_labels_count(struct mgp_vertex * v, size_t * result) Get the number of labels a given vertex has. |
enum mgp_error | mgp_vertex_label_at(struct mgp_vertex * v, size_t index, struct mgp_label * result) Get mgp_label in mgp_vertex at given index. |
enum mgp_error | mgp_vertex_has_label(struct mgp_vertex * v, struct mgp_label label, int * result) Result is non-zero if the given vertex has the given label. |
enum mgp_error | mgp_vertex_has_label_named(struct mgp_vertex * v, const char * label_name, int * result) Result is non-zero if the given vertex has a label with given name. |
enum mgp_error | mgp_vertex_get_property(struct mgp_vertex * v, const char * property_name, struct mgp_memory * memory, struct mgp_value ** result) Get a copy of a vertex property mapped to a given name. |
enum mgp_error | mgp_vertex_iter_properties(struct mgp_vertex * v, struct mgp_memory * memory, struct mgp_properties_iterator ** result) Start iterating over properties stored in the given vertex. |
enum mgp_error | mgp_vertex_iter_in_edges(struct mgp_vertex * v, struct mgp_memory * memory, struct mgp_edges_iterator ** result) Start iterating over inbound edges of the given vertex. |
enum mgp_error | mgp_vertex_iter_out_edges(struct mgp_vertex * v, struct mgp_memory * memory, struct mgp_edges_iterator ** result) Start iterating over outbound edges of the given vertex. |
enum mgp_error | mgp_edges_iterator_underlying_graph_is_mutable(struct mgp_edges_iterator * it, int * result) Result is non-zero if the edges returned by this iterator can be modified. |
enum mgp_error | mgp_edges_iterator_get(struct mgp_edges_iterator * it, struct mgp_edge ** result) Get the current edge pointed to by the iterator. |
enum mgp_error | mgp_edges_iterator_next(struct mgp_edges_iterator * it, struct mgp_edge ** result) Advance the iterator to the next edge and return it. |
enum mgp_error | mgp_edge_get_id(struct mgp_edge * e, struct mgp_edge_id * result) Get the ID of given edge. |
enum mgp_error | mgp_edge_underlying_graph_is_mutable(struct mgp_edge * e, int * result) Result is non-zero if the edge can be modified. |
enum mgp_error | mgp_edge_copy(struct mgp_edge * e, struct mgp_memory * memory, struct mgp_edge ** result) Copy a mgp_edge. |
void | mgp_edge_destroy(struct mgp_edge * e) Free the memory used by a mgp_edge. |
enum mgp_error | mgp_edge_is_deleted(struct mgp_edge *e, int *result) Result is non-zero if the given edge is deleted, otherwise 0. |
enum mgp_error | mgp_edge_equal(struct mgp_edge * e1, struct mgp_edge * e2, int * result) Result is non-zero if given edges are equal, otherwise 0. |
enum mgp_error | mgp_edge_get_type(struct mgp_edge * e, struct mgp_edge_type * result) Get the type of the given edge. |
enum mgp_error | mgp_edge_get_from(struct mgp_edge * e, struct mgp_vertex ** result) Get the source vertex of the given edge. |
enum mgp_error | mgp_edge_get_to(struct mgp_edge * e, struct mgp_vertex ** result) Get the destination vertex of the given edge. |
enum mgp_error | mgp_edge_get_property(struct mgp_edge * e, const char * property_name, struct mgp_memory * memory, struct mgp_value ** result) Get a copy of a edge property mapped to a given name. |
enum mgp_error | mgp_edge_set_property(struct mgp_edge * e, const char * property_name, struct mgp_value * property_value) Set the value of a property on an edge. |
enum mgp_error | mgp_edge_set_properties(struct mgp_edge *e, struct mgp_map *properties) Set the properties of the given edge. |
enum mgp_error | mgp_edge_iter_properties(struct mgp_edge * e, struct mgp_memory * memory, struct mgp_properties_iterator ** result) Start iterating over properties stored in the given edge. |
enum mgp_error | mgp_graph_get_vertex_by_id(struct mgp_graph * g, struct mgp_vertex_id id, struct mgp_memory * memory, struct mgp_vertex ** result) Get the vertex corresponding to given ID, or NULL if no such vertex exists. |
enum mgp_error | mgp_graph_is_transactional(struct mgp_graph * graph, int * result) Result is non-zero if the graph is in transactional storage mode. |
enum mgp_error | mgp_graph_has_text_index(struct mgp_graph * graph, const char * index_name, int * result) (Experimental) Result is non-zero if there exists a text index with the given name. |
enum mgp_error | mgp_graph_search_text_index(struct mgp_graph * graph, const char * index_name, const char * search_query, enum text_search_mode search_mode, struct mgp_memory * memory, struct mgp_map ** result) (Experimental) Search over the given text index. The result contains a list of all vertices matching the search query. |
enum mgp_error | mgp_graph_aggregate_over_text_index(struct mgp_graph * graph, const char * index_name, const char * search_query, const char * aggregation_query, struct mgp_memory * memory, struct mgp_map ** result) (Experimental) Aggregate over the results of a search over the named text index. |
enum mgp_error | mgp_graph_is_mutable(struct mgp_graph * graph, int * result) Result is non-zero if the graph can be modified. |
enum mgp_error | mgp_graph_create_vertex(struct mgp_graph * graph, struct mgp_memory * memory, struct mgp_vertex ** result) Add a new vertex to the graph. |
enum mgp_error | mgp_graph_delete_vertex(struct mgp_graph * graph, struct mgp_vertex * vertex) Delete a vertex from the graph. |
enum mgp_error | mgp_graph_detach_delete_vertex(struct mgp_graph * graph, struct mgp_vertex * vertex) Delete a vertex and all of its edges from the graph. |
enum mgp_error | mgp_graph_create_edge(struct mgp_graph * graph, struct mgp_vertex * from, struct mgp_vertex * to, struct mgp_edge_type type, struct mgp_memory * memory, struct mgp_edge ** result) Add a new directed edge between the two vertices with the specified label. |
enum mgp_error | mgp_graph_edge_set_from(struct mgp_graph * graph, struct mgp_edge * e, struct mgp_vertex * new_from, struct mgp_memory * memory, struct mgp_edge ** result) Change edge from (start) vertex. |
enum mgp_error | mgp_graph_edge_set_to(struct mgp_graph * graph, struct mgp_edge * e, struct mgp_vertex * new_to, struct mgp_memory * memory, struct mgp_edge ** result) Change edge to (end) vertex. |
enum mgp_error | mgp_graph_edge_change_type(struct mgp_graph * graph, struct mgp_edge * e, struct mgp_edge_type new_type, struct mgp_memory * memory, struct mgp_edge ** result) Change edge type. |
enum mgp_error | mgp_graph_delete_edge(struct mgp_graph * graph, struct mgp_edge * edge) Delete an edge from the graph. |
void | mgp_vertices_iterator_destroy(struct mgp_vertices_iterator * it) Free the memory used by a mgp_vertices_iterator. |
enum mgp_error | mgp_graph_iter_vertices(struct mgp_graph * g, struct mgp_memory * memory, struct mgp_vertices_iterator ** result) Start iterating over vertices of the given graph. |
enum mgp_error | mgp_vertices_iterator_underlying_graph_is_mutable(struct mgp_vertices_iterator * it, int * result) Result is non-zero if the vertices returned by this iterator can be modified. |
enum mgp_error | mgp_vertices_iterator_get(struct mgp_vertices_iterator * it, struct mgp_vertex ** result) Get the current vertex pointed to by the iterator. |
enum mgp_error | mgp_date_from_string(const char * string, struct mgp_memory * memory, struct mgp_date ** date) Create a date from a string following the ISO 8601 format. |
enum mgp_error | mgp_date_from_parameters(struct mgp_date_parameters * parameters, struct mgp_memory * memory, struct mgp_date ** date) Create a date from mgp_date_parameter. |
enum mgp_error | mgp_date_copy(struct mgp_date * date, struct mgp_memory * memory, struct mgp_date ** result) Copy a mgp_date. |
void | mgp_date_destroy(struct mgp_date * date) Free the memory used by a mgp_date. |
enum mgp_error | mgp_date_equal(struct mgp_date * first, struct mgp_date * second, int * result) Result is non-zero if given dates are equal, otherwise 0. |
enum mgp_error | mgp_date_get_year(struct mgp_date * date, int * year) Get the year property of the date. |
enum mgp_error | mgp_date_get_month(struct mgp_date * date, int * month) Get the month property of the date. |
enum mgp_error | mgp_date_get_day(struct mgp_date * date, int * day) Get the day property of the date. |
enum mgp_error | mgp_date_timestamp(struct mgp_date * date, int64_t * timestamp) Get the date as microseconds from Unix epoch. |
enum mgp_error | mgp_date_now(struct mgp_memory * memory, struct mgp_date ** date) Get the date representing current date. |
enum mgp_error | mgp_date_add_duration(struct mgp_date * date, struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_date ** result) Add a duration to the date. |
enum mgp_error | mgp_date_sub_duration(struct mgp_date * date, struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_date ** result) Subtract a duration from the date. |
enum mgp_error | mgp_date_diff(struct mgp_date * first, struct mgp_date * second, struct mgp_memory * memory, struct mgp_duration ** result) Get a duration between two dates. |
enum mgp_error | mgp_local_time_from_string(const char * string, struct mgp_memory * memory, struct mgp_local_time ** local_time) Create a local time from a string following the ISO 8601 format. |
enum mgp_error | mgp_local_time_from_parameters(struct mgp_local_time_parameters * parameters, struct mgp_memory * memory, struct mgp_local_time ** local_time) Create a local time from mgp_local_time_parameters. |
enum mgp_error | mgp_local_time_copy(struct mgp_local_time * local_time, struct mgp_memory * memory, struct mgp_local_time ** result) Copy a mgp_local_time. |
void | mgp_local_time_destroy(struct mgp_local_time * local_time) Free the memory used by a mgp_local_time. |
enum mgp_error | mgp_local_time_equal(struct mgp_local_time * first, struct mgp_local_time * second, int * result) Result is non-zero if given local times are equal, otherwise 0. |
enum mgp_error | mgp_local_time_get_hour(struct mgp_local_time * local_time, int * hour) Get the hour property of the local time. |
enum mgp_error | mgp_local_time_get_minute(struct mgp_local_time * local_time, int * minute) Get the minute property of the local time. |
enum mgp_error | mgp_local_time_get_second(struct mgp_local_time * local_time, int * second) Get the second property of the local time. |
enum mgp_error | mgp_local_time_get_millisecond(struct mgp_local_time * local_time, int * millisecond) Get the millisecond property of the local time. |
enum mgp_error | mgp_local_time_get_microsecond(struct mgp_local_time * local_time, int * microsecond) Get the microsecond property of the local time. |
enum mgp_error | mgp_local_time_timestamp(struct mgp_local_time * local_time, int64_t * timestamp) Get the local time as microseconds from midnight. |
enum mgp_error | mgp_local_time_now(struct mgp_memory * memory, struct mgp_local_time ** local_time) Get the local time representing current time. |
enum mgp_error | mgp_local_time_add_duration(struct mgp_local_time * local_time, struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_local_time ** result) Add a duration to the local time. |
enum mgp_error | mgp_local_time_sub_duration(struct mgp_local_time * local_time, struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_local_time ** result) Subtract a duration from the local time. |
enum mgp_error | mgp_local_time_diff(struct mgp_local_time * first, struct mgp_local_time * second, struct mgp_memory * memory, struct mgp_duration ** result) Get a duration between two local times. |
enum mgp_error | mgp_local_date_time_from_string(const char * string, struct mgp_memory * memory, struct mgp_local_date_time ** local_date_time) Create a local date-time from a string following the ISO 8601 format. |
enum mgp_error | mgp_local_date_time_from_parameters(struct mgp_local_date_time_parameters * parameters, struct mgp_memory * memory, struct mgp_local_date_time ** local_date_time) Create a local date-time from mgp_local_date_time_parameters. |
enum mgp_error | mgp_local_date_time_copy(struct mgp_local_date_time * local_date_time, struct mgp_memory * memory, struct mgp_local_date_time ** result) Copy a mgp_local_date_time. |
void | mgp_local_date_time_destroy(struct mgp_local_date_time * local_date_time) Free the memory used by a mgp_local_date_time. |
enum mgp_error | mgp_local_date_time_equal(struct mgp_local_date_time * first, struct mgp_local_date_time * second, int * result) Result is non-zero if given local date-times are equal, otherwise 0. |
enum mgp_error | mgp_local_date_time_get_year(struct mgp_local_date_time * local_date_time, int * year) Get the year property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_month(struct mgp_local_date_time * local_date_time, int * month) Get the month property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_day(struct mgp_local_date_time * local_date_time, int * day) Get the day property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_hour(struct mgp_local_date_time * local_date_time, int * hour) Get the hour property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_minute(struct mgp_local_date_time * local_date_time, int * minute) Get the minute property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_second(struct mgp_local_date_time * local_date_time, int * second) Get the second property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_millisecond(struct mgp_local_date_time * local_date_time, int * millisecond) Get the milisecond property of the local date-time. |
enum mgp_error | mgp_local_date_time_get_microsecond(struct mgp_local_date_time * local_date_time, int * microsecond) Get the microsecond property of the local date-time. |
enum mgp_error | mgp_local_date_time_timestamp(struct mgp_local_date_time * local_date_time, int64_t * timestamp) Get the local date-time as microseconds from Unix epoch. |
enum mgp_error | mgp_local_date_time_now(struct mgp_memory * memory, struct mgp_local_date_time ** local_date_time) Get the local date-time representing current date and time. |
enum mgp_error | mgp_local_date_time_add_duration(struct mgp_local_date_time * local_date_time, struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_local_date_time ** result) Add a duration to the local date-time. |
enum mgp_error | mgp_local_date_time_sub_duration(struct mgp_local_date_time * local_date_time, struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_local_date_time ** result) Subtract a duration from the local date-time. |
enum mgp_error | mgp_local_date_time_diff(struct mgp_local_date_time * first, struct mgp_local_date_time * second, struct mgp_memory * memory, struct mgp_duration ** result) Get a duration between two local date-times. |
enum mgp_error | mgp_duration_from_string(const char * string, struct mgp_memory * memory, struct mgp_duration ** duration) Create a duration from a string following the ISO 8601 format. |
enum mgp_error | mgp_duration_from_parameters(struct mgp_duration_parameters * parameters, struct mgp_memory * memory, struct mgp_duration ** duration) Create a duration from mgp_duration_parameters. |
enum mgp_error | mgp_duration_from_microseconds(int64_t microseconds, struct mgp_memory * memory, struct mgp_duration ** duration) Create a duration from microseconds. |
enum mgp_error | mgp_duration_copy(struct mgp_duration * duration, struct mgp_memory * memory, struct mgp_duration ** result) Copy a mgp_duration. |
void | mgp_duration_destroy(struct mgp_duration * duration) Free the memory used by a mgp_duration. |
enum mgp_error | mgp_duration_equal(struct mgp_duration * first, struct mgp_duration * second, int * result) Result is non-zero if given durations are equal, otherwise 0. |
enum mgp_error | mgp_duration_get_microseconds(struct mgp_duration * duration, int64_t * microseconds) Get the duration as microseconds. |
enum mgp_error | mgp_duration_neg(struct mgp_duration * dur, struct mgp_memory * memory, struct mgp_duration ** result) Apply unary minus operator to the duration. |
enum mgp_error | mgp_duration_add(struct mgp_duration * first, struct mgp_duration * second, struct mgp_memory * memory, struct mgp_duration ** result) Add two durations. |
enum mgp_error | mgp_duration_sub(struct mgp_duration * first, struct mgp_duration * second, struct mgp_memory * memory, struct mgp_duration ** result) Subtract two durations. |
enum mgp_error | mgp_type_any(struct mgp_type ** result) Get the type representing any value that isn't null . |
enum mgp_error | mgp_type_bool(struct mgp_type ** result) Get the type representing boolean values. |
enum mgp_error | mgp_type_string(struct mgp_type ** result) Get the type representing character string values. |
enum mgp_error | mgp_type_int(struct mgp_type ** result) Get the type representing integer values. |
enum mgp_error | mgp_type_float(struct mgp_type ** result) Get the type representing floating-point values. |
enum mgp_error | mgp_type_number(struct mgp_type ** result) Get the type representing any number value. |
enum mgp_error | mgp_type_map(struct mgp_type ** result) Get the type representing map values. |
enum mgp_error | mgp_type_node(struct mgp_type ** result) Get the type representing graph node values. |
enum mgp_error | mgp_type_relationship(struct mgp_type ** result) Get the type representing graph relationship values. |
enum mgp_error | mgp_type_path(struct mgp_type ** result) Get the type representing a graph path (walk) from one node to another. |
enum mgp_error | mgp_type_list(struct mgp_type * element_type, struct mgp_type ** result) Build a type representing a list of values of given element_type . |
enum mgp_error | mgp_type_date(struct mgp_type ** result) Get the type representing a date. |
enum mgp_error | mgp_type_local_time(struct mgp_type ** result) Get the type representing a local time. |
enum mgp_error | mgp_type_local_date_time(struct mgp_type ** result) Get the type representing a local date-time. |
enum mgp_error | mgp_type_duration(struct mgp_type ** result) Get the type representing a duration. |
enum mgp_error | mgp_type_nullable(struct mgp_type * type, struct mgp_type ** result) Build a type representing either a null value or a value of given type . |
enum mgp_error | mgp_module_add_read_procedure(struct mgp_module * module, const char * name, mgp_proc_cb cb, struct mgp_proc ** result) Register a read-only procedure to a module. |
enum mgp_error | mgp_module_add_write_procedure(struct mgp_module * module, const char * name, mgp_proc_cb cb, struct mgp_proc ** result) Register a writeable procedure to a module. |
enum mgp_error | mgp_module_add_batch_read_procedure(struct mgp_module * module, const char * name, mgp_proc_cb cb, mgp_proc_initializer initializer, mgp_proc_cleanup cleanup, struct mgp_proc ** result) Register a read-only procedure to a module. |
enum mgp_error | mgp_module_add_batch_write_procedure(struct mgp_module * module, const char * name, mgp_proc_cb cb, mgp_proc_initializer initializer, mgp_proc_cleanup cleanup, struct mgp_proc ** result) Register a writeable procedure to a module. |
enum mgp_error | mgp_proc_add_arg(struct mgp_proc * proc, const char * name, struct mgp_type * type) Add a required argument to a procedure. |
enum mgp_error | mgp_proc_add_opt_arg(struct mgp_proc * proc, const char * name, struct mgp_type * type, struct mgp_value * default_value) Add an optional argument with a default value to a procedure. |
enum mgp_error | mgp_proc_add_result(struct mgp_proc * proc, const char * name, struct mgp_type * type) Add a result field to a procedure. |
enum mgp_error | mgp_proc_add_deprecated_result(struct mgp_proc * proc, const char * name, struct mgp_type * type) Add a result field to a procedure and mark it as deprecated. |
int | mgp_must_abort(struct mgp_graph * graph) Return non-zero if the currently executing procedure should abort as soon as possible. |
enum mgp_error | mgp_message_payload(struct mgp_message * message, const char ** result) Payload is not null terminated and not a string but rather a byte array. |
enum mgp_error | mgp_message_payload_size(struct mgp_message * message, size_t * result) Get the payload size. |
enum mgp_error | mgp_message_topic_name(struct mgp_message * message, const char ** result) Get the name of topic. |
enum mgp_error | mgp_message_key(struct mgp_message * message, const char ** result) Get the key of mgp_message as a byte array. |
enum mgp_error | mgp_message_key_size(struct mgp_message * message, size_t * result) Get the key size of mgp_message. |
enum mgp_error | mgp_message_timestamp(struct mgp_message * message, int64_t * result) Get the timestamp of mgp_message as a byte array. |
enum mgp_error | mgp_messages_size(struct mgp_messages * message, size_t * result) Get the number of messages contained in the mgp_messages list Current implementation always returns without errors. |
enum mgp_error | mgp_messages_at(struct mgp_messages * message, size_t index, struct mgp_message ** result) Get the message from a messages list at given index. |
enum mgp_error | mgp_module_add_transformation(struct mgp_module * module, const char * name, mgp_trans_cb cb) Register a transformation with a module. |
enum mgp_error | mgp_vertices_iterator_next(struct mgp_vertices_iterator * it, struct mgp_vertex ** result) Advance the iterator to the next vertex and return it. |
enum mgp_error | mgp_log(mgp_log_level log_level, const char *output) Log a message on a certain level. |
enum mgp_error | mgp_execution_headers_at(struct mgp_execution_headers * headers, size_t index, const char ** result) Returns the header/column of the query at the specific index. |
enum mgp_error | mgp_execution_headers_size(struct mgp_execution_headers * headers, size_t * result) Returns the size of headers/columns. |
enum mgp_error | mgp_execute_query(struct mgp_graph * graph, struct mgp_memory * memory, const char * query, struct mgp_map * params, struct mgp_execution_result ** result) Executes the query. |
enum mgp_error | mgp_fetch_execution_headers(struct mgp_execution_result * exec_result, struct mgp_execution_headers ** result) Returns the query headers/columns. |
enum mgp_error | mgp_pull_one(struct mgp_execution_result * exec_result, struct mgp_graph * graph, struct mgp_memory * memory, struct mgp_map ** result) Pulls one result from the executing query. |
enum mgp_error | mgp_execution_result_destroy(struct mgp_execution_result * exec_result) Performs cleanup of the object. |
Attributes
Name | |
---|---|
enum MGP_NODISCARD | mgp_error All functions return an error code that can be used to figure out whether the API call was successful or not. |
MGP_ERROR_NO_ERROR | |
MGP_ERROR_UNKNOWN_ERROR | |
MGP_ERROR_UNABLE_TO_ALLOCATE | |
MGP_ERROR_INSUFFICIENT_BUFFER | |
MGP_ERROR_OUT_OF_RANGE | |
MGP_ERROR_LOGIC_ERROR | |
MGP_ERROR_DELETED_OBJECT | |
MGP_ERROR_INVALID_ARGUMENT | |
MGP_ERROR_KEY_ALREADY_EXISTS | |
MGP_ERROR_IMMUTABLE_OBJECT | |
MGP_ERROR_VALUE_CONVERSION | |
MGP_ERROR_SERIALIZATION_ERROR |
Macros
Classes Documentation
mgp_label
Label of a vertex.
Public Attributes
Type | Name |
---|---|
const char * | name Name of the label as a NULL terminated character string. |
variable name
const char * name;
Name of the label as a NULL terminated character string.
mgp_edge_type
Type of an edge.
Public Attributes
Type | Name |
---|---|
const char * | name Name of the type as a NULL terminated character string. |
variable name
const char * name;
Name of the type as a NULL terminated character string.
mgp_property
Reference to a named property value.
Public Attributes
Type | Name |
---|---|
const char * | name Name (key) of a property as a NULL terminated string. |
struct mgp_value * | value Value of the referenced property. |
variable name
const char * name;
Name (key) of a property as a NULL terminated string.
variable value
struct mgp_value * value;
Value of the referenced property.
mgp_vertex_id
ID of a vertex valid during a single query execution.
Public Attributes
Type | Name |
---|---|
int64_t | as_int |
variable as_int
int64_t as_int;
mgp_edge_id
ID of an edge; valid during a single query execution.
Public Attributes
Type | Name |
---|---|
int64_t | as_int |
variable as_int
int64_t as_int;
mgp_date_parameters
Public Attributes
Type | Name |
---|---|
int | year |
int | month |
int | day |
variable year
int year;
variable month
int month;
variable day
int day;
mgp_local_time_parameters
Public Attributes
Type | Name |
---|---|
int | hour |
int | minute |
int | second |
int | millisecond |
int | microsecond |
variable hour
int hour;
variable minute
int minute;
variable second
int second;
variable millisecond
int millisecond;
variable microsecond
int microsecond;
mgp_local_date_time_parameters
Public Attributes
Type | Name |
---|---|
struct mgp_date_parameters * | date_parameters |
struct mgp_local_time_parameters * | local_time_parameters |
variable date_parameters
struct mgp_date_parameters * date_parameters;
variable local_time_parameters
struct mgp_local_time_parameters * local_time_parameters;
mgp_duration_parameters
Public Attributes
Name | |
---|---|
double | day |
double | hour |
double | minute |
double | second |
double | millisecond |
double | microsecond |
variable day
double day;
variable hour
double hour;
variable minute
double minute;
variable second
double second;
variable millisecond
double millisecond;
variable microsecond
double microsecond;
Types Documentation
enum mgp_value_type
All available types that can be stored in a mgp_value.
Enumerator |
---|
MGP_VALUE_TYPE_NULL |
MGP_VALUE_TYPE_BOOL |
MGP_VALUE_TYPE_INT |
MGP_VALUE_TYPE_DOUBLE |
MGP_VALUE_TYPE_STRING |
MGP_VALUE_TYPE_LIST |
MGP_VALUE_TYPE_MAP |
MGP_VALUE_TYPE_VERTEX |
MGP_VALUE_TYPE_EDGE |
MGP_VALUE_TYPE_PATH |
MGP_VALUE_TYPE_DATE |
MGP_VALUE_TYPE_LOCAL_TIME |
MGP_VALUE_TYPE_LOCAL_DATE_TIME |
MGP_VALUE_TYPE_DURATION |
typedef mgp_proc_cb
typedef void(* mgp_proc_cb) (struct mgp_list *, struct mgp_graph *, struct mgp_result *, struct mgp_memory *);
Entry-point for a query module read procedure, invoked through openCypher.
Passed in arguments will not live longer than the callback's execution. Therefore, you must not store them globally or use the passed in mgp_memory to allocate global resources.
typedef mgp_trans_cb
typedef void(* mgp_trans_cb) (struct mgp_messages *, struct mgp_graph *, struct mgp_result *, struct mgp_memory *);
Entry-point for a module transformation, invoked through a stream transformation.
Passed in arguments will not live longer than the callback's execution. Therefore, you must not store them globally or use the passed in mgp_memory to allocate global resources.
Functions Documentation
mgp_alloc
enum mgp_error mgp_alloc(
struct mgp_memory * memory,
size_t size_in_bytes,
void ** result
)
Allocate a block of memory with given size in bytes.
Unlike malloc, this function is not thread-safe. size_in_bytes
must be greater than 0. The resulting pointer must be freed with mgp_free. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to serve the requested allocation.
mgp_aligned_alloc
enum mgp_error mgp_aligned_alloc(
struct mgp_memory * memory,
size_t size_in_bytes,
size_t alignment,
void ** result
)
Allocate an aligned block of memory with given size in bytes.
Unlike malloc and aligned_alloc, this function is not thread-safe. size_in_bytes
must be greater than 0. alignment
must be a power of 2 value. The resulting pointer must be freed with mgp_free. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to serve the requested allocation.
mgp_free
void mgp_free(
struct mgp_memory * memory,
void * ptr
)
Deallocate an allocation from mgp_alloc or mgp_aligned_alloc.
Unlike free, this function is not thread-safe. If ptr
is NULL, this function does nothing. The behavior is undefined if ptr
is not a value returned from a prior mgp_alloc or mgp_aligned_alloc call with the corresponding memory
.
mgp_global_alloc
enum mgp_error mgp_global_alloc(
size_t size_in_bytes,
void ** result
)
Allocate a global block of memory with given size in bytes.
This function can be used to allocate global memory that persists beyond a single invocation of mgp_main. The resulting pointer must be freed with mgp_global_free. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to serve the requested allocation.
mgp_global_aligned_alloc
enum mgp_error mgp_global_aligned_alloc(
size_t size_in_bytes,
size_t alignment,
void ** result
)
Allocate an aligned global block of memory with given size in bytes.
This function can be used to allocate global memory that persists beyond a single invocation of mgp_main. The resulting pointer must be freed with mgp_global_free. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to serve the requested allocation.
mgp_global_free
void mgp_global_free(
void * p
)
Deallocate an allocation from mgp_global_alloc or mgp_global_aligned_alloc.
If ptr
is NULL, this function does nothing. The behavior is undefined if ptr
is not a value returned from a prior mgp_global_alloc() or mgp_global_aligned_alloc().
mgp_value_destroy
void mgp_value_destroy(
struct mgp_value * val
)
Free the memory used by the given mgp_value instance.
mgp_value_make_null
enum mgp_error mgp_value_make_null(
struct mgp_memory * memory,
struct mgp_value ** result
)
Construct a value representing null
in openCypher.
You need to free the instance through mgp_value_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_bool
enum mgp_error mgp_value_make_bool(
int val,
struct mgp_memory * memory,
struct mgp_value ** result
)
Construct a boolean value.
Non-zero values represent true
, while zero represents false
. You need to free the instance through mgp_value_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_int
enum mgp_error mgp_value_make_int(
int64_t val,
struct mgp_memory * memory,
struct mgp_value ** result
)
Construct an integer value.
You need to free the instance through mgp_value_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_double
enum mgp_error mgp_value_make_double(
double val,
struct mgp_memory * memory,
struct mgp_value ** result
)
Construct a double floating point value.
You need to free the instance through mgp_value_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_string
enum mgp_error mgp_value_make_string(
const char * val,
struct mgp_memory * memory,
struct mgp_value ** result
)
Construct a character string value from a NULL terminated string.
You need to free the instance through mgp_value_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_list
enum mgp_error mgp_value_make_list(
struct mgp_list * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_list.
You need to free the instance through mgp_value_destroy. The ownership of the list is given to the created mgp_value and destroying the mgp_value will destroy the mgp_list. Therefore, if a mgp_value is successfully created you must not call mgp_list_destroy on the given list. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_map
enum mgp_error mgp_value_make_map(
struct mgp_map * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_map.
You need to free the instance through mgp_value_destroy. The ownership of the map is given to the created mgp_value and destroying the mgp_value will destroy the mgp_map. Therefore, if a mgp_value is successfully created you must not call mgp_map_destroy on the given map. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_vertex
enum mgp_error mgp_value_make_vertex(
struct mgp_vertex * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_vertex.
You need to free the instance through mgp_value_destroy. The ownership of the vertex is given to the created mgp_value and destroying the mgp_value will destroy the mgp_vertex. Therefore, if a mgp_value is successfully created you must not call mgp_vertex_destroy on the given vertex. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_edge
enum mgp_error mgp_value_make_edge(
struct mgp_edge * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_edge.
You need to free the instance through mgp_value_destroy. The ownership of the edge is given to the created mgp_value and destroying the mgp_value will destroy the mgp_edge. Therefore, if a mgp_value is successfully created you must not call mgp_edge_destroy on the given edge. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_path
enum mgp_error mgp_value_make_path(
struct mgp_path * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_path.
You need to free the instance through mgp_value_destroy. The ownership of the path is given to the created mgp_value and destroying the mgp_value will destroy the mgp_path. Therefore, if a mgp_value is successfully created you must not call mgp_path_destroy on the given path. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_date
enum mgp_error mgp_value_make_date(
struct mgp_date * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_date.
You need to free the instance through mgp_value_destroy. The ownership of the date is transferred to the created mgp_value and destroying the mgp_value will destroy the mgp_date. Therefore, if a mgp_value is successfully created you must not call mgp_date_destroy on the given date. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_local_time
enum mgp_error mgp_value_make_local_time(
struct mgp_local_time * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_local_time.
You need to free the instance through mgp_value_destroy. The ownership of the local time is transferred to the created mgp_value and destroying the mgp_value will destroy the mgp_local_time. Therefore, if a mgp_value is successfully created you must not call mgp_local_time_destroy on the given local time. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_local_date_time
enum mgp_error mgp_value_make_local_date_time(
struct mgp_local_date_time * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_local_date_time.
You need to free the instance through mgp_value_destroy. The ownership of the local date-time is transferred to the created mgp_value and destroying the mgp_value will destroy the mgp_local_date_time. Therefore, if a mgp_value is successfully created you must not call mgp_local_date_time_destroy on the given local date-time. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_make_duration
enum mgp_error mgp_value_make_duration(
struct mgp_duration * val,
struct mgp_value ** result
)
Create a mgp_value storing a mgp_duration.
You need to free the instance through mgp_value_destroy. The ownership of the duration is transferred to the created mgp_value and destroying the mgp_value will destroy the mgp_duration. Therefore, if a mgp_value is successfully created you must not call mgp_duration_destroy on the given duration. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_value.
mgp_value_get_type
enum mgp_error mgp_value_get_type(
struct mgp_value * val,
enum mgp_value_type * result
)
Get the type of the value contained in mgp_value.
Current implementation always returns without errors.
mgp_value_is_null
enum mgp_error mgp_value_is_null(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value represents null
.
Current implementation always returns without errors.
mgp_value_is_bool
enum mgp_error mgp_value_is_bool(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a boolean.
Current implementation always returns without errors.
mgp_value_is_int
enum mgp_error mgp_value_is_int(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores an integer.
Current implementation always returns without errors.
mgp_value_is_double
enum mgp_error mgp_value_is_double(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a double floating-point.
Current implementation always returns without errors.
mgp_value_is_string
enum mgp_error mgp_value_is_string(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a character string.
Current implementation always returns without errors.
mgp_value_is_list
enum mgp_error mgp_value_is_list(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a list of values.
Current implementation always returns without errors.
mgp_value_is_map
enum mgp_error mgp_value_is_map(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a map of values.
Current implementation always returns without errors.
mgp_value_is_vertex
enum mgp_error mgp_value_is_vertex(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a vertex.
Current implementation always returns without errors.
mgp_value_is_edge
enum mgp_error mgp_value_is_edge(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores an edge.
Current implementation always returns without errors.
mgp_value_is_path
enum mgp_error mgp_value_is_path(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a path.
Current implementation always returns without errors.
mgp_value_is_date
enum mgp_error mgp_value_is_date(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a date.
Current implementation always returns without errors.
mgp_value_is_local_time
enum mgp_error mgp_value_is_local_time(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a local time.
Current implementation always returns without errors.
mgp_value_is_local_date_time
enum mgp_error mgp_value_is_local_date_time(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a local date-time.
Current implementation always returns without errors.
mgp_value_is_duration
enum mgp_error mgp_value_is_duration(
struct mgp_value * val,
int * result
)
Result is non-zero if the given mgp_value stores a duration.
Current implementation always returns without errors.
mgp_value_get_bool
enum mgp_error mgp_value_get_bool(
struct mgp_value * val,
int * result
)
Get the contained boolean value.
Non-zero values represent true
, while zero represents false
. Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_int
enum mgp_error mgp_value_get_int(
struct mgp_value * val,
int64_t * result
)
Get the contained integer.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_double
enum mgp_error mgp_value_get_double(
struct mgp_value * val,
double * result
)
Get the contained double floating-point.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_string
enum mgp_error mgp_value_get_string(
struct mgp_value * val,
const char ** result
)
Get the contained character string.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_list
enum mgp_error mgp_value_get_list(
struct mgp_value * val,
struct mgp_list ** result
)
Get the contained list of values.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_map
enum mgp_error mgp_value_get_map(
struct mgp_value * val,
struct mgp_map ** result
)
Get the contained map of values.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_vertex
enum mgp_error mgp_value_get_vertex(
struct mgp_value * val,
struct mgp_vertex ** result
)
Get the contained vertex.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_edge
enum mgp_error mgp_value_get_edge(
struct mgp_value * val,
struct mgp_edge ** result
)
Get the contained edge.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_path
enum mgp_error mgp_value_get_path(
struct mgp_value * val,
struct mgp_path ** result
)
Get the contained path.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_date
enum mgp_error mgp_value_get_date(
struct mgp_value * val,
struct mgp_date ** result
)
Get the contained date.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_local_time
enum mgp_error mgp_value_get_local_time(
struct mgp_value * val,
struct mgp_local_time ** result
)
Get the contained local time.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_local_date_time
enum mgp_error mgp_value_get_local_date_time(
struct mgp_value * val,
struct mgp_local_date_time ** result
)
Get the contained local date-time.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_value_get_duration
enum mgp_error mgp_value_get_duration(
struct mgp_value * val,
struct mgp_duration ** result
)
Get the contained duration.
Result is undefined if mgp_value does not contain the expected type. Current implementation always returns without errors.
mgp_list_make_empty
enum mgp_error mgp_list_make_empty(
size_t capacity,
struct mgp_memory * memory,
struct mgp_list ** result
)
Create an empty list with given capacity.
You need to free the created instance with mgp_list_destroy. The created list will have allocated enough memory for capacity
elements of mgp_value, but it will not contain any elements. Therefore, mgp_list_size will return 0. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_list.
mgp_list_destroy
void mgp_list_destroy(
struct mgp_list * list
)
Free the memory used by the given mgp_list and contained elements.
mgp_list_contains_deleted
enum mgp_error mgp_list_contains_deleted(
struct mgp_list * list,
int * result
)
Result is non-zero if the given list contains any deleted values (mgp_vertex
, mgp_edge
, or container types holding them), otherwise 0.
mgp_list_append
enum mgp_error mgp_list_append(
struct mgp_list * list,
struct mgp_value * val
)
Append a copy of mgp_value to mgp_list if capacity allows.
The list copies the given value and therefore does not take ownership of the original value. You still need to call mgp_value_destroy to free the original value. Return MGP_ERROR_INSUFFICIENT_BUFFER if there's no capacity. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_value.
mgp_list_append_extend
enum mgp_error mgp_list_append_extend(
struct mgp_list * list,
struct mgp_value * val
)
Append a copy of mgp_value to mgp_list increasing capacity if needed.
The list copies the given value and therefore does not take ownership of the original value. You still need to call mgp_value_destroy to free the original value. In case of a capacity change, the previously contained elements will move in memory and any references to them will be invalid. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_value.
mgp_list_size
enum mgp_error mgp_list_size(
struct mgp_list * list,
size_t * result
)
Get the number of elements stored in mgp_list.
Current implementation always returns without errors.
mgp_list_capacity
enum mgp_error mgp_list_capacity(
struct mgp_list * list,
size_t * result
)
Get the total number of elements for which there's already allocated memory in mgp_list.
Current implementation always returns without errors.
mgp_list_at
enum mgp_error mgp_list_at(
struct mgp_list * list,
size_t index,
struct mgp_value ** result
)
Get the element in mgp_list at given position.
MGP_ERROR_OUT_OF_RANGE is returned if the index is not within mgp_list_size.
mgp_map_make_empty
enum mgp_error mgp_map_make_empty(
struct mgp_memory * memory,
struct mgp_map ** result
)
Create an empty map of character strings to mgp_value instances.
You need to free the created instance with mgp_map_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_map.
mgp_map_destroy
void mgp_map_destroy(
struct mgp_map * map
)
Free the memory used by the given mgp_map and contained items.
mgp_map_contains_deleted
enum mgp_error mgp_map_contains_deleted(
struct mgp_map * map,
int * result
)
Result is non-zero if the given map contains any deleted values (mgp_vertex
, mgp_edge
, or container types holding them), otherwise 0.
mgp_map_insert
enum mgp_error mgp_map_insert(
struct mgp_map * map,
const char * key,
struct mgp_value * value
)
Insert a new mapping from a NULL terminated character string to a value.
If a mapping with the same key already exists, it is not replaced. In case of insertion, both the string and the value are copied into the map. Therefore, the map does not take ownership of the original key or value, so you still need to free their memory explicitly. Return MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate for insertion. Return MGP_ERROR_KEY_ALREADY_EXISTS if a previous mapping already exists.
mgp_map_update
enum mgp_error mgp_map_update(
struct mgp_map * map,
const char * key,
struct mgp_value * value
)
Insert a mapping from a NULL terminated character string to a value.
If a mapping with the same key already exists, it is replaced. In case of an update, both the string and the value are copied into the map. Therefore, the map does not take ownership of the original key or value, so you still need to free their memory explicitly. Return mgp_error::MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate memory for insertion.
mgp_map_erase
enum mgp_error mgp_map_erase(
struct mgp_map * map,
const char * key,
)
Erase a mapping by key.
If the key doesn't exist in the map nothing happens.
mgp_map_size
enum mgp_error mgp_map_size(
struct mgp_map * map,
size_t * result
)
Get the number of items stored in mgp_map.
Current implementation always returns without errors.
mgp_map_at
enum mgp_error mgp_map_at(
struct mgp_map * map,
const char * key,
struct mgp_value ** result
)
Get the mapped mgp_value to the given character string.
Result is NULL if no mapping exists.
mgp_map_item_key
enum mgp_error mgp_map_item_key(
struct mgp_map_item * item,
const char ** result
)
Get the key of the mapped item.
mgp_map_item_value
enum mgp_error mgp_map_item_value(
struct mgp_map_item * item,
struct mgp_value ** result
)
Get the value of the mapped item.
mgp_map_iter_items
enum mgp_error mgp_map_iter_items(
struct mgp_map * map,
struct mgp_memory * memory,
struct mgp_map_items_iterator ** result
)
Start iterating over items contained in the given map.
The resulting mgp_map_items_iterator needs to be deallocated with mgp_map_items_iterator_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_map_items_iterator.
mgp_map_items_iterator_destroy
void mgp_map_items_iterator_destroy(
struct mgp_map_items_iterator * it
)
Deallocate memory used by mgp_map_items_iterator.
mgp_map_items_iterator_get
enum mgp_error mgp_map_items_iterator_get(
struct mgp_map_items_iterator * it,
struct mgp_map_item ** result
)
Get the current item pointed to by the iterator.
When the mgp_map_items_iterator_next is invoked, the returned pointer to mgp_map_item becomes invalid. On the other hand, pointers obtained with mgp_map_item_key and mgp_map_item_value remain valid throughout the lifetime of a map. Therefore, you can store the key as well as the value before, and use them after invoking mgp_map_items_iterator_next. Result is NULL if the end of the iteration has been reached.
mgp_map_items_iterator_next
enum mgp_error mgp_map_items_iterator_next(
struct mgp_map_items_iterator * it,
struct mgp_map_item ** result
)
Advance the iterator to the next item stored in map and return it.
The previous pointer obtained through mgp_map_items_iterator_get will be invalidated, but the pointers to key and value will remain valid. Result is NULL if the end of the iteration has been reached.
mgp_path_make_with_start
enum mgp_error mgp_path_make_with_start(
struct mgp_vertex * vertex,
struct mgp_memory * memory,
struct mgp_path ** result
)
Create a path with the copy of the given starting vertex.
You need to free the created instance with mgp_path_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_path.
mgp_path_copy
enum mgp_error mgp_path_copy(
struct mgp_path * path,
struct mgp_memory * memory,
struct mgp_path ** result
)
Copy a mgp_path.
Returned pointer must be freed with mgp_path_destroy. MGP_ERROR_UNABLE_TO_ALLOCATE is returned if unable to allocate a mgp_path.
mgp_path_destroy
void mgp_path_destroy(
struct mgp_path * path
)
Free the memory used by the given mgp_path and contained vertices and edges.
mgp_path_contains_deleted
enum mgp_error mgp_path_contains_deleted(
struct mgp_path * path,
int * result
)
Result is non-zero if the given path contains any deleted values (mgp_vertex
or mgp_edge
), otherwise 0.
mgp_path_expand
enum mgp_error mgp_path_expand(
struct mgp_path * path,
struct mgp_edge * edge
)
Append an edge continuing from the last vertex on the path.
The edge is copied into the path. Therefore, the path does not take ownership of the original edge, so you still need to free the edge memory explicitly. The last vertex on the path will become the other endpoint of the given edge, as continued from the current last vertex. Return MGP_ERROR_LOGIC_ERROR if the current last vertex in the path is not part of the given edge. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate memory for path extension.
mgp_path_pop
enum mgp_error mgp_path_pop(
struct mgp_path * path
)
Remove the last node and the last relationship from the path.
Return mgp_error::MGP_ERROR_OUT_OF_RANGE if the path contains no relationships.
mgp_path_size
enum mgp_error mgp_path_size(
struct mgp_path * path,
size_t * result
)
Get the number of edges in a mgp_path.
Current implementation always returns without errors.
mgp_path_vertex_at
enum mgp_error mgp_path_vertex_at(
struct mgp_path * path,
size_t index,
struct mgp_vertex ** result
)
Get the vertex from a path at given index.
The valid index range is [0, mgp_path_size]. MGP_ERROR_OUT_OF_RANGE is returned if index is out of range.
mgp_path_edge_at
enum mgp_error mgp_path_edge_at(
struct mgp_path * path,
size_t index,
struct mgp_edge ** result
)
Get the edge from a path at given index.
The valid index range is [0, mgp_path_size - 1]. MGP_ERROR_OUT_OF_RANGE is returned if index is out of range.
mgp_path_equal
enum mgp_error mgp_path_equal(
struct mgp_path * p1,
struct mgp_path * p2,
int * result
)
Result is non-zero if given paths are equal, otherwise 0.
mgp_result_set_error_msg
enum mgp_error mgp_result_set_error_msg(
struct mgp_result * res,
const char * error_msg
)
Set the error as the result of the procedure.
Return MGP_ERROR_UNABLE_TO_ALLOCATE ff there's no memory for copying the error message.
mgp_result_new_record
enum mgp_error mgp_result_new_record(
struct mgp_result * res,
struct mgp_result_record ** result
)
Create a new record for results.
The previously obtained mgp_result_record pointer is no longer valid, and you must not use it. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_result_record.
mgp_result_record_insert
enum mgp_error mgp_result_record_insert(
struct mgp_result_record * record,
const char * field_name,
struct mgp_value * val
)
Assign a value to a field in the given record.
Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate memory to copy the mgp_value to mgp_result_record. Return MGP_ERROR_OUT_OF_RANGE if there is no field named field_name
. Return MGP_ERROR_LOGIC_ERROR val
does not satisfy the type of the field name field_name
.
mgp_properties_iterator_destroy
void mgp_properties_iterator_destroy(
struct mgp_properties_iterator * it
)
Free the memory used by a mgp_properties_iterator.
mgp_properties_iterator_get
enum mgp_error mgp_properties_iterator_get(
struct mgp_properties_iterator * it,
struct mgp_property ** result
)
Get the current property pointed to by the iterator.
When the mgp_properties_iterator_next is invoked, the previous mgp_property is invalidated and its value must not be used. Result is NULL if the end of the iteration has been reached.
mgp_properties_iterator_next
enum mgp_error mgp_properties_iterator_next(
struct mgp_properties_iterator * it,
struct mgp_property ** result
)
Advance the iterator to the next property and return it.
The previous mgp_property obtained through mgp_properties_iterator_get will be invalidated, and you must not use its value. Result is NULL if the end of the iteration has been reached. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_property.
mgp_edges_iterator_destroy
void mgp_edges_iterator_destroy(
struct mgp_edges_iterator * it
)
Free the memory used by a mgp_edges_iterator.
mgp_vertex_get_id
enum mgp_error mgp_vertex_get_id(
struct mgp_vertex * v,
struct mgp_vertex_id * result
)
Get the ID of given vertex.
mgp_vertex_get_in_degree
enum mgp_error mgp_vertex_get_in_degree(
struct mgp_vertex * v,
size_t * result
)
Get the in degree of the given vertex.
mgp_vertex_get_out_degree
enum mgp_error mgp_vertex_get_out_degree(
struct mgp_vertex * v,
size_t * result
)
Get the out degree of the given vertex.
mgp_vertex_underlying_graph_is_mutable
enum mgp_error mgp_vertex_underlying_graph_is_mutable(
struct mgp_vertex * v,
int * result
)
Result is non-zero if the vertex can be modified.
The mutability of the vertex is the same as the graph which it is part of. If a vertex is immutable, then edges cannot be created or deleted, properties and labels cannot be set or removed and all of the returned edges will be immutable also. Current implementation always returns without errors.
mgp_vertex_set_property
enum mgp_error mgp_vertex_set_property(
struct mgp_vertex * v,
const char * property_name,
struct mgp_value * property_value
)
Set the value of a property on a vertex.
When the value is null
, the property is removed from the vertex. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate memory for storing the property. Return MGP_ERROR_IMMUTABLE_OBJECT if v
is immutable. Return MGP_ERROR_DELETED_OBJECT if v
has been deleted. Return MGP_ERROR_SERIALIZATION_ERROR if v
has been modified by another transaction. Return MGP_ERROR_VALUE_CONVERSION if property_value
is vertex, edge or path.
mgp_vertex_set_properties
enum mgp_error mgp_vertex_set_properties(
struct mgp_vertex * v,
struct mgp_map * properties
)
Update the properties of the given vertex.
Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate memory for storing the property. Return MGP_ERROR_IMMUTABLE_OBJECT if v
is immutable. Return MGP_ERROR_DELETED_OBJECT if v
has been deleted. Return MGP_ERROR_SERIALIZATION_ERROR if v
has been modified by another transaction.
mgp_vertex_add_label
enum mgp_error mgp_vertex_add_label(
struct mgp_vertex * v,
struct mgp_label label
)
Add the label to the vertex.
If the vertex already has the label, this function does nothing. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate memory for storing the label. Return MGP_ERROR_IMMUTABLE_OBJECT if v
is immutable. Return MGP_ERROR_DELETED_OBJECT if v
has been deleted. Return MGP_ERROR_SERIALIZATION_ERROR if v
has been modified by another transaction.
mgp_vertex_remove_label
enum mgp_error mgp_vertex_remove_label(
struct mgp_vertex * v,
struct mgp_label label
)
Remove the label from the vertex.
If the vertex doesn't have the label, this function does nothing. Return MGP_ERROR_IMMUTABLE_OBJECT if v
is immutable. Return MGP_ERROR_DELETED_OBJECT if v
has been deleted. Return MGP_ERROR_SERIALIZATION_ERROR if v
has been modified by another transaction.
mgp_vertex_copy
enum mgp_error mgp_vertex_copy(
struct mgp_vertex * v,
struct mgp_memory * memory,
struct mgp_vertex ** result
)
Copy a mgp_vertex.
Resulting pointer must be freed with mgp_vertex_destroy. Return MGP_ERROR_UNABLE_TO_ALLOCATE if unable to allocate a mgp_vertex.
mgp_vertex_destroy