Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[master < E-util-docs] Write docs for util module #1012

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions mage/query-modules/cpp/util_module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
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}) => (
<span
style={{
backgroundColor: color,
borderRadius: '2px',
color: '#fff',
padding: '0.2rem',
}}>
{children}
</span>
);

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would be worthy to give an example of when this is valuable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly have no idea for what purpose the people who requested the function use it, could be password hashing, hash tables etc., so I will rephrase it differently


[![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** | <Highlight color="#FB6E00">**algorithm**</Highlight> |
| **Implementation** | <Highlight color="#FB6E00">**C++**</Highlight> |
| **Graph direction** | <Highlight color="#FB6E00">**directed**</Highlight>/<Highlight color="#FB6E00">**undirected**</Highlight> |
| **Edge weights** | <Highlight color="#FB6E00">**weighted**</Highlight>/<Highlight color="#FB6E00">**unweighted**</Highlight> |
| **Parallelism** | <Highlight color="#FB6E00">**sequential**</Highlight> |

### 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([cpp-api](/memgraph/reference-guide/query-modules/api/cpp-api)) for desired type or Value.
vpavicic marked this conversation as resolved.
Show resolved Hide resolved
#### Input:
vpavicic marked this conversation as resolved.
Show resolved Hide resolved

- `values: List[Any]` ➡ input list containing elements which can be any of Memgraph's data types.


vpavicic marked this conversation as resolved.
Show resolved Hide resolved

#### 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.
vpavicic marked this conversation as resolved.
Show resolved Hide resolved

```cypher
CREATE (d:Dog);
MATCH (d:Dog)
CALL util_module.md5([d, "string", 50]) YIELD result RETURN result;
```

```plaintext
+-----------------------------------+
| result |
+-----------------------------------+
| 47e656a5f446fc21316e97df90e8ae33 |
+-----------------------------------+
```
1 change: 1 addition & 0 deletions mage/templates/_mage_spells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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. |

Expand Down
1 change: 1 addition & 0 deletions sidebars/sidebarsMAGE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading