Coordinate parallel transactions
A bookmark is a marker representing a state of the database. Bookmarks are useful when subsequent transactions in a cluster need to be coordinated, for example when you need to read data right after writing it.
When using the GDS client, any query following a call to gds.set_bookmarks()
is not executed until the bookmarked transactions are propagated across the cluster.
Example of using bookmarks with GDS
# Use the `bookmarks` parameter to set any existing bookmarks, for example
# after running a query through the Neo4j driver. The default value is `None`.
gds = GraphDataScience(NEO4J_URI, auth=(NEO4J_USER, NEO4J_PASSWORD), bookmarks=None)
gds.run_cypher("""
CREATE (:Person {name: "Alice"})-[:KNOWS]->(:Person {name: "Bob"})
""")
# Make sure the next queries will be executed after the CREATE query is fully propagated through the cluster
gds.set_bookmarks(gds.last_bookmarks())
G, _ = gds.graph.project("myGraph", "Person", "KNOWS")
gds.pageRank.write(G, writeProperty="pagerank")
# Make sure the next queries will be executed after the pageRank scores were written back to the cluster
gds.set_bookmarks(gds.last_bookmarks())
result = gds.run_cypher("MATCH (p:Person) RETURN p.name, p.pagerank")
G.drop()
For more details about bookmarks, see the Neo4j Python driver.