Skip to content

Commit 70f0128

Browse files
katarinasupeDavIvekas51340imilinovicmatea16
authored
Memgraph 3.2 (#1194)
* init * change threads default value (#1224) * HA MT failover (#1234) * Add mgp_result_reserve to C-API (#1236) * docs * docs * Add a section about manual failover in HA (#1231) * Describe manual failover * Clarify data loss on committed data --------- Co-authored-by: Matea Pesic <[email protected]> * Add HA monitoring (#1196) * Added HA metrics part * Update monitoring * Update HA metrics * Update pages/clustering/high-availability.mdx --------- Co-authored-by: Matea Pesic <[email protected]> * Add docs for headless svc (#1241) Co-authored-by: Matea Pesic <[email protected]> * Add docs for OR label expressions (#1240) * add docs for OR label expressions * update dataset --------- Co-authored-by: matea16 <[email protected]> Co-authored-by: Matea Pesic <[email protected]> * Add composite indices (#1232) * wip: Added stub for what will be composite index docs * doc: Remove composite indices from unsupported * doc: Update mentions of old label+property operators with combined op * doc: Add preliminary composite indices docs * doc: Elaborate on composite indices * doc: Apply grammarly's grammar suggestions * fix: Fix missing apostrophe * Apply suggestions from code review * doc: Update `schema.assert` docs with indices which aren't dropped * doc: Replace `ScanAllByLabelPropertyValue` with `...Properties` --------- Co-authored-by: Matea Pesic <[email protected]> * Create snapshot parallelization (#1243) * touch * parallel flags and info * Apply suggestions from code review --------- Co-authored-by: Matea Pesic <[email protected]> * Add support for annotations on HA services (#1248) Co-authored-by: Matea Pesic <[email protected]> * Add labels support for services (#1249) Co-authored-by: Matea Pesic <[email protected]> * Add migration module with Arrow Flight (#1204) * init * Add migration from Neo4 * Add migration using Arrow Flight * Merge * Add migration module with DuckDB (#1205) * Add migration with DuckDB * Clarify duckdb startup * Merge * Update pages/advanced-algorithms/available-algorithms/migrate.mdx * Add migration from another Memgraph instance (#1206) * Add migration from another Memgraph instance * Update pages/advanced-algorithms/available-algorithms/migrate.mdx * Add migration from ServiceNow (#1207) * Add migration from servicenow * Apply suggestions from code review * add callout --------- Co-authored-by: Matea Pesic <[email protected]> Co-authored-by: matea16 <[email protected]> --------- Co-authored-by: Matea Pesic <[email protected]> Co-authored-by: matea16 <[email protected]> --------- Co-authored-by: Matea Pesic <[email protected]> Co-authored-by: matea16 <[email protected]> * Apply suggestions from code review --------- Co-authored-by: katarinasupe <[email protected]> Co-authored-by: Matea Pesic <[email protected]> Co-authored-by: matea16 <[email protected]> * Add support for starting HA chart without external network configuration (#1250) * Specify default empty string * unify format --------- Co-authored-by: Matea Pesic <[email protected]> * Add a first few changelog items * Add all memgraph changelog items until 2025-04-18 8pm * Add all memgraph and mage changelog items by the end of day 2025-04-18 * Expand TTL to edges (#1244) * touch * Edge TTL * PR comments --------- Co-authored-by: Matea Pesic <[email protected]> * update MAGE tag info (#1242) Co-authored-by: Matea Pesic <[email protected]> * Update storage access types (#1237) * Expanding docs regardin the storage access New file: storage-access.mdx Modified python docs and transacctiona docs * PR comments * Update pages/help-center/errors/transactions.mdx --------- Co-authored-by: Matea Pesic <[email protected]> * Global edge index documentation (#1253) * Add global edge index documentation * Add dropping of global edge index * Apply suggestions from code review * update --------- Co-authored-by: Matea Pesic <[email protected]> Co-authored-by: matea16 <[email protected]> --------- Co-authored-by: David Ivekovic <[email protected]> Co-authored-by: Andi Skrgat <[email protected]> Co-authored-by: Ivan Milinović <[email protected]> Co-authored-by: Matea Pesic <[email protected]> Co-authored-by: matea16 <[email protected]> Co-authored-by: colinbarry <[email protected]> Co-authored-by: andrejtonev <[email protected]> Co-authored-by: Josipmrden <[email protected]> Co-authored-by: Marko Budiselic <[email protected]> Co-authored-by: Dr Matt James <[email protected]>
1 parent 28740ff commit 70f0128

File tree

25 files changed

+1155
-344
lines changed

25 files changed

+1155
-344
lines changed

pages/advanced-algorithms/available-algorithms/betweenness_centrality.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ If subgraph is not specified, the algorithm is computed on the entire graph by d
5959
- `normalized: boolean (default=True)` ➡ If `True` the betweenness values are normalized by
6060
`2/((n-1)(n-2))` for graphs, and `1/((n-1)(n-2))` for directed graphs where
6161
`n` is the number of nodes.
62-
- `threads: integer (default=number of concurrent threads supported by the
63-
implementation)` ➡ The number of threads used to calculate betweenness
62+
- `threads: integer (default=half of the system’s available hardware threads)` ➡ The number of threads used to calculate betweenness
6463
centrality.
6564

6665

pages/advanced-algorithms/available-algorithms/community_detection.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ the procedure.
7878
gain in modularity goes below this threshold, a final iteration is performed using the
7979
`community_alg_threshold` value.
8080
Valid values are between 0 and 1 (exclusive). This parameter's value should be higher than `community_alg_threshold`.
81-
- `num_of_threads: integer (default=Half of the system's maximum thread count)` ➡ Specifies the number of threads used for parallel execution in the algorithm's parallelized parts.
81+
- `num_of_threads: integer (default=half of the system’s available hardware threads)` ➡ Specifies the number of threads used for parallel execution in the algorithm's parallelized parts.
8282
**Note**: OpenMP (omp) is used for parallelization, so the actual thread usage may depend on system settings and OpenMP configurations.
8383

8484
{<h4 className="custom-header"> Output: </h4>}

pages/advanced-algorithms/available-algorithms/migrate.mdx

+219
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: Discover the migration capabilities of Memgraph for efficient trans
66
import { Cards } from 'nextra/components'
77
import GitHub from '/components/icons/GitHub'
88
import { Steps } from 'nextra/components'
9+
import { Callout } from 'nextra/components';
910

1011
# migrate
1112

@@ -35,6 +36,181 @@ filter, and convert relational data into a graph format.
3536

3637
## Procedures
3738

39+
### `arrow_flight()`
40+
41+
With the `arrow_flight()` procedure, users can access data sources which support the [Arrow Flight RPC protocol](https://arrow.apache.org/docs/format/Flight.html) for transfer
42+
of large data records to achieve high performance. Underlying implementation is using the `pyarrow` Python library to stream rows to
43+
Memgraph. [Dremio](https://www.dremio.com/) is a confirmed data source that works with the `arrow_flight()` procedure. Other sources may also be compatible, but Dremio is based on previous experience.
44+
45+
{<h4 className="custom-header"> Input: </h4>}
46+
47+
- `query: str` ➡ Query used to query the data source.
48+
- `config: mgp.Map` ➡ Connection parameters (as in `pyarrow.flight.connect`). Useful parameters for connecting are `host`, `port`, `username` and `password`.
49+
- `config_path` ➡ Path to a JSON file containing configuration parameters.
50+
51+
{<h4 className="custom-header"> Output: </h4>}
52+
53+
- `row: mgp.Map` ➡ The result table as a stream of rows.
54+
55+
#### Retrieve and inspect data
56+
```cypher
57+
CALL migrate.arrow_flight('SELECT * FROM users', {username: 'memgraph',
58+
password: 'password',
59+
host: 'localhost',
60+
port: '12345'} )
61+
YIELD row
62+
RETURN row
63+
LIMIT 5000;
64+
```
65+
66+
#### Filter specific data
67+
```cypher
68+
CALL migrate.arrow_flight('SELECT * FROM users', {username: 'memgraph',
69+
password: 'password',
70+
host: 'localhost',
71+
port: '12345'} )
72+
YIELD row
73+
WHERE row.age >= 30
74+
RETURN row;
75+
```
76+
77+
#### Create nodes from migrated data
78+
```cypher
79+
CALL migrate.arrow_flight('SELECT id, name, age FROM users', {username: 'memgraph',
80+
password: 'password',
81+
host: 'localhost',
82+
port: '12345'} )
83+
YIELD row
84+
CREATE (u:User {id: row.id, name: row.name, age: row.age});
85+
```
86+
87+
#### Create relationships between users
88+
```cypher
89+
CALL migrate.arrow_flight('SELECT user1_id, user2_id FROM friendships', {username: 'memgraph',
90+
password: 'password',
91+
host: 'localhost',
92+
port: '12345'} )
93+
YIELD row
94+
MATCH (u1:User {id: row.user1_id}), (u2:User {id: row.user2_id})
95+
CREATE (u1)-[:FRIENDS_WITH]->(u2);
96+
```
97+
98+
### `duckdb()`
99+
With the `migrate.duckdb()` procedure, users can connect to the ** DuckDB** database and query various data sources.
100+
List of data sources that are supported by DuckDB can be found on their [official documentation page](https://duckdb.org/docs/stable/data/data_sources.html).
101+
The underlying implementation streams results from DuckDB to Memgraph using the `duckdb` Python Library. DuckDB is started with the in-memory mode, without any
102+
persistence and is used just to proxy to the underlying data sources.
103+
104+
{<h4 className="custom-header"> Input: </h4>}
105+
106+
- `query: str` ➡ Table name or an SQL query.
107+
- `setup_queries: mgp.Nullable[List[str]]` ➡ List of queries that will be executed prior to the query provided as the initial argument.
108+
Used for setting up the connection to additional data sources.
109+
110+
{<h4 className="custom-header"> Output: </h4>}
111+
112+
- `row: mgp.Map` ➡ The result table as a stream of rows.
113+
114+
{<h4 className="custom-header"> Usage: </h4>}
115+
116+
#### Retrieve and inspect data
117+
```cypher
118+
CALL migrate.duckdb("SELECT * FROM 'test.parquet';")
119+
YIELD row
120+
RETURN row
121+
LIMIT 5000;
122+
```
123+
124+
#### Filter specific data
125+
```cypher
126+
CALL migrate.duckdb("SELECT * FROM 'test.parquet';")
127+
YIELD row
128+
WHERE row.age >= 30
129+
RETURN row;
130+
```
131+
132+
#### Create nodes from migrated data
133+
```cypher
134+
CALL migrate.duckdb("SELECT * FROM 'test.parquet';")
135+
YIELD row
136+
CREATE (u:User {id: row.id, name: row.name, age: row.age});
137+
```
138+
139+
#### Create relationships between users
140+
```cypher
141+
CALL migrate.duckdb("SELECT * FROM 'test.parquet';")
142+
YIELD row
143+
MATCH (u1:User {id: row.user1_id}), (u2:User {id: row.user2_id})
144+
CREATE (u1)-[:FRIENDS_WITH]->(u2);
145+
```
146+
147+
#### Setup connection to query additional data sources
148+
```cypher
149+
CALL migrate.duckdb("SELECT * FROM 's3://your_bucket/your_file.parquet';", ["CREATE SECRET secret1 (TYPE s3, KEY_ID 'key', SECRET 'secret', REGION 'region');"])
150+
YIELD row
151+
MATCH (u1:User {id: row.user1_id}), (u2:User {id: row.user2_id})
152+
CREATE (u1)-[:FRIENDS_WITH]->(u2);
153+
```
154+
155+
---
156+
157+
### `memgraph()`
158+
159+
With the `migrate.memgraph()` procedure, you can access another Memgraph instance and migrate your data to a new Memgraph instance.
160+
The resulting nodes and edges are converted into a stream of rows which can include labels, properties, and primitives.
161+
162+
<Callout type="info">
163+
Streaming of raw node and relationship objects is not supported and users are advised to migrate all the necessary identifiers in order to recreate the same graph in Memgraph.
164+
</Callout>
165+
166+
{<h4 className="custom-header"> Input: </h4>}
167+
168+
- `label_or_rel_or_query: str` ➡ Label name (written in format `(:Label)`), relationship name (written in format `[:rel_type]`) or a plain cypher query.
169+
- `config: mgp.Map` ➡ Connection parameters (as in `gqlalchemy.Memgraph`). Notable parameters are `host[String]`, and `port[Integer]`
170+
- `config_path` ➡ Path to a JSON file containing configuration parameters.
171+
- `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Query parameters (if applicable).
172+
173+
{<h4 className="custom-header"> Output: </h4>}
174+
175+
- `row: mgp.Map` ➡ The result table as a stream of rows.
176+
- when retrieving nodes using the `(:Label)` syntax, row will have the following keys: `labels`, and `properties`
177+
- when retrieving relationships using the `[:REL_TYPE]` syntax, row will have the following keys: `from_labels`, `to_labels`, `from_properties`, `to_properties`, and `edge_properties`
178+
- when retrieving results using a plain Cypher query, row will have keys identical to the returned column names from the Cypher query
179+
180+
{<h4 className="custom-header"> Usage: </h4>}
181+
182+
#### Retrieve nodes of certain label and create them in a new Memgraph instance
183+
```cypher
184+
CALL migrate.memgraph('(:Person)', {host: 'localhost', port: 7687})
185+
YIELD row
186+
WITH row.labels AS labels, row.properties as props
187+
CREATE (n:labels) SET n += row.props
188+
```
189+
190+
#### Retrieve relationships of certain type and create them in a new Memgraph instance
191+
```cypher
192+
CALL migrate.memgraph('[:KNOWS]', {host: 'localhost', port: 7687})
193+
YIELD row
194+
WITH row.from_labels AS from_labels,
195+
row.to_labels AS to_labels,
196+
row.from_properties AS from_properties,
197+
row.to_properties AS to_properties,
198+
row.edge_properties AS edge_properties
199+
MATCH (p1:Person {id: row.from_properties.id})
200+
MATCH (p2:Person {id: row.to_properties.id})
201+
CREATE (p1)-[r:KNOWS]->(p2)
202+
SET r += edge_properties;
203+
```
204+
205+
#### Retrieve information from Memgraph using an arbitrary Cypher query
206+
```cypher
207+
CALL migrate.memgraph('MATCH (n) RETURN count(n) as cnt', {host: 'localhost', port: 7687})
208+
YIELD row
209+
RETURN row.cnt as cnt;
210+
```
211+
212+
---
213+
38214
### `mysql()`
39215

40216
With the `migrate.mysql()` procedure, you can access MySQL and migrate your data to Memgraph.
@@ -334,3 +510,46 @@ CALL migrate.s3('s3://my-bucket/employees.csv', {aws_access_key_id: 'your-key',
334510
YIELD row
335511
CREATE (e:Employee {id: row.id, name: row.name, position: row.position});
336512
```
513+
514+
---
515+
516+
### `servicenow()`
517+
518+
With the `migrate.servicenow()` procedure, you can access [ServiceNow REST API](https://developer.servicenow.com/dev.do#!/reference/api/xanadu/rest/) and transfer your data to Memgraph.
519+
The underlying implementation is using the [`requests` Python library] to migrate results to Memgraph. The REST API from
520+
ServiceNow must provide results in the format `{results: []}` in order for Memgraph to stream it into result rows.
521+
522+
{<h4 className="custom-header"> Input: </h4>}
523+
524+
- `endpoint: str` ➡ ServiceNow endpoint. Users can optionally include their own query parameters to filter results.
525+
- `config: mgp.Map` ➡ Connection parameters. Notable connection parameters are `username` and `password`, per `requests.get()` method.
526+
- `config_path: str` ➡ Path to a JSON file containing configuration parameters.
527+
528+
{<h4 className="custom-header"> Output: </h4>}
529+
530+
- `row: mgp.Map` ➡ Each row from the CSV file as a structured dictionary.
531+
532+
{<h4 className="custom-header"> Usage: </h4>}
533+
534+
#### Retrieve and inspect CSV data from ServiceNow
535+
```cypher
536+
CALL migrate.servicenow('http://my_endpoint/api/data', {})
537+
YIELD row
538+
RETURN row
539+
LIMIT 100;
540+
```
541+
542+
#### Filter specific rows from the CSV
543+
```cypher
544+
CALL migrate.servicenow('http://my_endpoint/api/data', {})
545+
YIELD row
546+
WHERE row.age >= 30
547+
RETURN row;
548+
```
549+
550+
#### Create nodes dynamically from CSV data
551+
```cypher
552+
CALL migrate.servicenow('http://my_endpoint/api/data', {})
553+
YIELD row
554+
CREATE (e:Employee {id: row.id, name: row.name, position: row.position});
555+
```

pages/advanced-algorithms/install-mage.mdx

+16-1
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,28 @@ data.
2222

2323
You can download a specific version of MAGE
2424

25-
For example, if you want to download version `3.1.1`, you should run the following
25+
For example, if you want to download version `3.2`, you should run the following
2626
command:
2727

28+
```shell
29+
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.2
30+
```
31+
32+
The following tags are available on Docker Hub:
33+
- `x.y` - production MAGE image
34+
- `x.y-relwithdebinfo` - contains debugging symbols and `gdb`
35+
- `x.y-malloc` - Memgraph compiled with `malloc`instead of `jemalloc` (x86_64 only)
36+
37+
For versions prior to `3.2`, MAGE image tags included both MAGE and Memgraph versions, e.g.
38+
2839
```shell
2940
docker run -p 7687:7687 --name memgraph memgraph/memgraph-mage:3.1.1-memgraph-3.1.1
3041
```
3142

43+
A `no-ml` image (e.g. `3.1.1-memgraph-3.1.1-no-ml`) was also provided, but this has now been
44+
discontinued as of `3.2` onwards.
45+
46+
3247
</Callout>
3348

3449
## Linux

pages/client-libraries/python.mdx

+18-2
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ for record in records:
435435
print(path.end_node)
436436
```
437437

438-
Path will contain [Nodes](#process-the-node-result) and [Relationships[#process-the-relationship-result], that can be accessed in the same way as in the previous examples.
438+
Path will contain [Nodes](#process-the-node-result) and [Relationships](#process-the-relationship-result), that can be accessed in the same way as in the previous examples.
439439

440440
### Transaction management
441441

@@ -546,6 +546,11 @@ With sessions, you can run:
546546

547547
To create a managed transaction, use `Session.execute_read()` procedure for read queries and `Session.execute_write()` procedure for write queries.
548548

549+
<Callout type="info">
550+
As of Memgraph version 3.2, queries are categorized as **read** or **write** and the corresponding storage access is taken. This allows for better query parallelization and higher throughput.
551+
An exception will be thrown if the user tries to execute a write query inside a read transaction. For more details, see [transaction accessor misalignment](/fundamentals/transactions#transaction-accessor-misalignment).
552+
</Callout>
553+
549554
```python
550555
def match_user(tx, name):
551556
result = tx.run(
@@ -581,6 +586,12 @@ To maintain multiple concurrent transactions, use [multiple concurrent sessions]
581586
With explicit transactions, you can get **complete control over transactions**. To begin a transaction, run `Session.begin_transaction()` procedure and to run a transaction, use `Transaction.run()` procedure.
582587
Explicit transactions offer the possibility of explicitly controlling the end of a transaction with `Transaction.commit()`, `Transaction.rollback()` or `Transaction.close()` methods.
583588

589+
<Callout type="info">
590+
As of Memgraph version 3.2, queries are categorized as **read** or **write** and the corresponding storage access is taken. This allows for better query parallelization and higher throughput.
591+
Explicit transactions can cover a number of individual queries, but storage access is given at the start. For best performance, the user needs to declare whether the transaction should use read or write access.
592+
This can be done by setting the session's `default_access_mode` to `"r"` or `"w"`. This will, in turn, set the access mode of a transaction created via the `begin_transaction` function. Note that `execute_read` and `execute_write` will override the session's default access.
593+
</Callout>
594+
584595
Use explicit transaction if you need to **distribute Cypher execution across multiple functions for the same transaction** or if you need to **run multiple queries within a single transactions without automatic retries**.
585596

586597
The following example shows how to explicitly control the transaction of changing account balances based on a token transfer:
@@ -610,7 +621,7 @@ def create_users(client, sender, receiver):
610621

611622

612623
def transfer_tokens(client, sender_id, receiver_id, num_of_tokens):
613-
with client.session(database="memgraph") as session:
624+
with client.session(database="memgraph", default_access_mode="w") as session:
614625
tx = session.begin_transaction()
615626

616627
try:
@@ -676,6 +687,11 @@ In the above example, if John's account balance is changed to a number less than
676687
Implicit or auto-commit transactions are the simplest way to run a Cypher query since they won't be automatically retried as with `execute_query()` procedure or managed transactions.
677688
With implicit transactions, you don't have the same control of transaction as with explicit transactions, so they are mostly used for quick prototyping.
678689

690+
<Callout type="info">
691+
As of Memgraph version 3.2, queries are categorized as **read** or **write** and the corresponding storage access is taken. This allows for better query parallelization and higher throughput.
692+
Access mode is automatically determined when executing single queries through implicit transactions.
693+
</Callout>
694+
679695
To run an implicit transaction, use the `Session.run()` method:
680696

681697
```python

0 commit comments

Comments
 (0)