From ab30229309df0b52718c05cdfe9fbdf0ab774b15 Mon Sep 17 00:00:00 2001 From: Matija Date: Tue, 29 Aug 2023 21:27:44 +0200 Subject: [PATCH 1/7] Write docs for util module --- mage/query-modules/cpp/util_module.md | 69 +++++++++++++++++++++++++++ mage/templates/_mage_spells.mdx | 1 + sidebars/sidebarsMAGE.js | 1 + 3 files changed, 71 insertions(+) create mode 100644 mage/query-modules/cpp/util_module.md diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md new file mode 100644 index 00000000000..c7217071b11 --- /dev/null +++ b/mage/query-modules/cpp/util_module.md @@ -0,0 +1,69 @@ +--- +id: util_module +title: util_module +sidebar_label: util_module +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import RunOnSubgraph from '../../templates/_run_on_subgraph.mdx'; + +export const Highlight = ({children, color}) => ( + +{children} + +); + +The util module provides a set of handy functions for tasks like validation and generating cryptographic hash values. It's a valuable toolkit for simplifying various database-related operations. + +[![docs-source](https://img.shields.io/badge/source-util_module-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/util_module) + +| Trait | Value | +| ------------------- | ----------------------------------------------------- | +| **Module type** | **algorithm** | +| **Implementation** | **C++** | +| **Graph direction** | **directed**/**undirected** | +| **Edge weights** | **weighted**/**unweighted** | +| **Parallelism** | **sequential** | + +### Procedures + + +### `md5(values)` + +Gets the string representation of every element in the input list, concatenates it into a single string, and returns the md5 hash of that string. +NOTE: The format of string representations can be seen by checking ToString in CPP API documentation for desired type or Value. +QUESTION FOR REVIEWER: Can the sentence above be phrased better, or the link for this cpp api function be provided? +#### Input: + +- `values: List[Any]` ➡ input list containing elements which can be any of Memgraph's data types. + + + +#### Output: + +- `result: string` ➡ resulting md5 hash returned as string. + +#### Usage: + +NOTE: Hash provided in this documentation will be different from user's hash for same input, unless the node has the same ID, because `Node.ToString()` uses node's id in string formation, so different ID's equal different strings, hence, different hashes. + +```cypher +CREATE (d:Dog); +MATCH (d:Dog) +CALL util_module.md5([d, "string", 50]) YIELD result RETURN result; +``` + +```plaintext ++-----------------------------------+ +| result | ++-----------------------------------+ +| 47e656a5f446fc21316e97df90e8ae33 | ++-----------------------------------+ +``` diff --git a/mage/templates/_mage_spells.mdx b/mage/templates/_mage_spells.mdx index 83634d4a33b..391959befff 100644 --- a/mage/templates/_mage_spells.mdx +++ b/mage/templates/_mage_spells.mdx @@ -21,6 +21,7 @@ | [set_cover](/mage/query-modules/python/set-cover) | Python | An algorithm for finding the minimum cost subcollection of sets that covers all elements of a universe. | | [tsp](/mage/query-modules/python/tsp) | Python | An algorithm for finding the shortest possible route that visits each vertex exactly once. | | [union_find](/mage/query-modules/python/union-find) | Python | A module with an algorithm that enables the user to check whether the given nodes belong to the same connected component. | +| [util_module](/mage/query-modules/cpp/util_module) | C++ | The util module provides a set of handy functions for tasks like validation and generating cryptographic hash values. It's a valuable toolkit for simplifying various database-related operations. | | [vrp](/mage/query-modules/python/vrp) | Python | Algorithm for finding the shortest route possible between the central depot and places to be visited. The algorithm can be solved with multiple vehicles that represent a visiting fleet. | | [weakly_connected_components](/mage/query-modules/cpp/weakly-connected-components) | C++ | A module that finds weakly connected components in a graph. | diff --git a/sidebars/sidebarsMAGE.js b/sidebars/sidebarsMAGE.js index 3d940c7c061..957190613f2 100644 --- a/sidebars/sidebarsMAGE.js +++ b/sidebars/sidebarsMAGE.js @@ -64,6 +64,7 @@ module.exports = { "query-modules/python/temporal-graph-networks", "query-modules/python/tsp", "query-modules/python/union-find", + "query-modules/cpp/util_module", "query-modules/cpp/uuid-generator", "query-modules/python/vrp", "query-modules/cpp/weakly-connected-components" From 711da311febcf82955e1b781326c75598778aa51 Mon Sep 17 00:00:00 2001 From: Matija Date: Wed, 30 Aug 2023 13:32:25 +0200 Subject: [PATCH 2/7] Add link --- mage/query-modules/cpp/util_module.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md index c7217071b11..c27fcf5eab3 100644 --- a/mage/query-modules/cpp/util_module.md +++ b/mage/query-modules/cpp/util_module.md @@ -38,8 +38,7 @@ The util module provides a set of handy functions for tasks like validation and ### `md5(values)` Gets the string representation of every element in the input list, concatenates it into a single string, and returns the md5 hash of that string. -NOTE: The format of string representations can be seen by checking ToString in CPP API documentation for desired type or Value. -QUESTION FOR REVIEWER: Can the sentence above be phrased better, or the link for this cpp api function be provided? +NOTE: The format of string representations can be seen by checking ToString in CPP API documentation([cpp-api](/memgraph/reference-guide/query-modules/api/cpp-api)) for desired type or Value. #### Input: - `values: List[Any]` ➡ input list containing elements which can be any of Memgraph's data types. From 880ecadea15f7dd55fcf76b404240737e9ab69ed Mon Sep 17 00:00:00 2001 From: Vlasta <95473291+vpavicic@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:52:04 +0200 Subject: [PATCH 3/7] Apply suggestions from code review --- mage/query-modules/cpp/util_module.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md index c27fcf5eab3..42dc7a1f155 100644 --- a/mage/query-modules/cpp/util_module.md +++ b/mage/query-modules/cpp/util_module.md @@ -38,20 +38,19 @@ The util module provides a set of handy functions for tasks like validation and ### `md5(values)` Gets the string representation of every element in the input list, concatenates it into a single string, and returns the md5 hash of that string. -NOTE: The format of string representations can be seen by checking ToString in CPP API documentation([cpp-api](/memgraph/reference-guide/query-modules/api/cpp-api)) for desired type or Value. +NOTE: The format of string representations can be seen by checking ToString in [CPP API](/memgraph/reference-guide/query-modules/api/cpp-api) documentation for desired type or Value. + #### Input: - `values: List[Any]` ➡ input list containing elements which can be any of Memgraph's data types. - - #### Output: - `result: string` ➡ resulting md5 hash returned as string. #### Usage: -NOTE: Hash provided in this documentation will be different from user's hash for same input, unless the node has the same ID, because `Node.ToString()` uses node's id in string formation, so different ID's equal different strings, hence, different hashes. +NOTE: The hash provided in this documentation will be different from the user's hash for the same input unless the node has the same ID because `Node.ToString()` uses the node's ID in string formation, so different IDs equal different strings, hence, different hashes. ```cypher CREATE (d:Dog); From 94c2e7126dacc8d171995916e786e5d358848dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Pintari=C4=87?= <99442742+mpintaric55334@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:16:35 +0200 Subject: [PATCH 4/7] Update util_module.md --- mage/query-modules/cpp/util_module.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md index 42dc7a1f155..a6d7590e0ed 100644 --- a/mage/query-modules/cpp/util_module.md +++ b/mage/query-modules/cpp/util_module.md @@ -20,7 +20,7 @@ style={{ ); -The util module provides a set of handy functions for tasks like validation and generating cryptographic hash values. It's a valuable toolkit for simplifying various database-related operations. +The util module offers a range of convenient functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. [![docs-source](https://img.shields.io/badge/source-util_module-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/util_module) From fb5af10c7032c931b1cca3825a69652e39e4a336 Mon Sep 17 00:00:00 2001 From: Matija Date: Thu, 31 Aug 2023 14:19:27 +0200 Subject: [PATCH 5/7] Minor fixes --- mage/query-modules/cpp/util_module.md | 2 +- mage/templates/_mage_spells.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md index a6d7590e0ed..6cf11fb4de5 100644 --- a/mage/query-modules/cpp/util_module.md +++ b/mage/query-modules/cpp/util_module.md @@ -20,7 +20,7 @@ style={{ ); -The util module offers a range of convenient functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. +A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. [![docs-source](https://img.shields.io/badge/source-util_module-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/util_module) diff --git a/mage/templates/_mage_spells.mdx b/mage/templates/_mage_spells.mdx index 391959befff..e151b5f7ffa 100644 --- a/mage/templates/_mage_spells.mdx +++ b/mage/templates/_mage_spells.mdx @@ -21,7 +21,7 @@ | [set_cover](/mage/query-modules/python/set-cover) | Python | An algorithm for finding the minimum cost subcollection of sets that covers all elements of a universe. | | [tsp](/mage/query-modules/python/tsp) | Python | An algorithm for finding the shortest possible route that visits each vertex exactly once. | | [union_find](/mage/query-modules/python/union-find) | Python | A module with an algorithm that enables the user to check whether the given nodes belong to the same connected component. | -| [util_module](/mage/query-modules/cpp/util_module) | C++ | The util module provides a set of handy functions for tasks like validation and generating cryptographic hash values. It's a valuable toolkit for simplifying various database-related operations. | +| [util_module](/mage/query-modules/cpp/util_module) | C++ | A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. | | [vrp](/mage/query-modules/python/vrp) | Python | Algorithm for finding the shortest route possible between the central depot and places to be visited. The algorithm can be solved with multiple vehicles that represent a visiting fleet. | | [weakly_connected_components](/mage/query-modules/cpp/weakly-connected-components) | C++ | A module that finds weakly connected components in a graph. | From a53e099aaacf57fa09beb1824883b4a49df15c45 Mon Sep 17 00:00:00 2001 From: Matija Date: Thu, 31 Aug 2023 14:20:28 +0200 Subject: [PATCH 6/7] Minor fixes --- mage/query-modules/cpp/util_module.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md index 6cf11fb4de5..a99bbd17675 100644 --- a/mage/query-modules/cpp/util_module.md +++ b/mage/query-modules/cpp/util_module.md @@ -20,7 +20,7 @@ style={{ ); -A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. +The util module offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. [![docs-source](https://img.shields.io/badge/source-util_module-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/util_module) From af083b03a7aa5270057fe9e918ead2612d871ddc Mon Sep 17 00:00:00 2001 From: Vlasta Date: Tue, 12 Sep 2023 13:58:16 +0200 Subject: [PATCH 7/7] change-to-utli --- mage/templates/_mage_spells.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mage/templates/_mage_spells.mdx b/mage/templates/_mage_spells.mdx index e151b5f7ffa..1dc423a90d2 100644 --- a/mage/templates/_mage_spells.mdx +++ b/mage/templates/_mage_spells.mdx @@ -21,7 +21,6 @@ | [set_cover](/mage/query-modules/python/set-cover) | Python | An algorithm for finding the minimum cost subcollection of sets that covers all elements of a universe. | | [tsp](/mage/query-modules/python/tsp) | Python | An algorithm for finding the shortest possible route that visits each vertex exactly once. | | [union_find](/mage/query-modules/python/union-find) | Python | A module with an algorithm that enables the user to check whether the given nodes belong to the same connected component. | -| [util_module](/mage/query-modules/cpp/util_module) | C++ | A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. | | [vrp](/mage/query-modules/python/vrp) | Python | Algorithm for finding the shortest route possible between the central depot and places to be visited. The algorithm can be solved with multiple vehicles that represent a visiting fleet. | | [weakly_connected_components](/mage/query-modules/cpp/weakly-connected-components) | C++ | A module that finds weakly connected components in a graph. | @@ -62,6 +61,7 @@ | [migrate](/mage/query-modules/python/migrate) | Python | A module that can access data from a MySQL, SQL Server or Oracle database. | | [periodic](/mage/query-modules/cpp/periodic) | C++ | A module containing procedures for periodically running difficult and/or memory/time consuming queries. | | rust_example | Rust | Example of a basic module with input parameters forwarding, made in Rust. | +| [util_module](/mage/query-modules/cpp/util_module) | C++ | A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. | | [uuid_generator](/mage/query-modules/cpp/uuid-generator) | C++ | A module that generates a new universally unique identifier (UUID). |