Skip to content

Commit 2dda3ac

Browse files
authored
Merge pull request #75 from graphfoundation/3.5-int
3.5 - Integrating latest from neo4j/3.5
2 parents b9cc131 + 4168a60 commit 2dda3ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1840
-268
lines changed

CONTRIBUTING.adoc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ If there are multiple commits, and the PR is fine to merge online, use *Squash a
5353

5454
Using the issue id in the summary line will allow us to keep track of commits belonging together.
5555

56+
=== Branching Policy
57+
58+
We do have a branch for each major version of Neo4j, e.g. `3.5`, `4.0` and `4.1`.
59+
As a contributor you're asked to use newest possible branch for you PR.
60+
61+
When your PR is accepted and merged it's the responsibility of the maintainers who merged it to cherry-pick that changes to any newer branch.
62+
Once cherry-picking is done, the maintainers should mark that PR with the `cherry-picked` label.
63+
64+
Please indicate in your PR message text if your PR needs a different behaviour - e.g. if the feature you're fixing has been removed in a newer branch or APIs have changed too much and you have a separate PR for the newer branch.
65+
66+
EXAMPLE:
67+
68+
1. You're fixing a bug being reported for 3.5.x.x.
69+
2. You're choosing the 3.5 branch as base for your PR branch.
70+
3. Once you're done you send a PR.
71+
4. When a maintainer merges that PR, they also take care to cherry-pick it to 4.0 and any more recent branches.
72+
5673
=== Handling pull requests
5774

5875
Be polite.
@@ -84,4 +101,4 @@ curl $PULL_REQUEST_URL.patch | git am --ignore-whitespace
84101
Make sure to push changes to a PR to the original remote branch.
85102
This will cause the pull request UI in GitHub show and link those commits.
86103

87-
This guideline document is based on the https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc[spring-data guidelines], thanks @olivergierke.
104+
This guideline document is based on the https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.adoc[spring-data guidelines], thanks @olivergierke.

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ plugins {
88
id "io.codearte.nexus-staging" version "0.20.0"
99
id 'maven-publish'
1010
id 'antlr'
11+
id "org.sonarqube" version "2.7"
1112
}
1213
asciidoctorj {
1314
version = '1.6.1'
@@ -39,7 +40,7 @@ description = """neo4j-apoc-procedures"""
3940

4041
ext {
4142
// NB: due to version.json generation by parsing this file, the next line must not have any if/then/else logic
42-
neo4jVersion = "3.5.16"
43+
neo4jVersion = "3.5.17"
4344
// instead we apply the override logic here
4445
neo4jVersionEffective = project.hasProperty("neo4jVersionOverride") ? project.getProperty("neo4jVersionOverride") : neo4jVersion
4546
testContainersVersion = '1.11.0'
@@ -157,7 +158,7 @@ dependencies {
157158
testCompile group: 'com.couchbase.client', name: 'java-client', version: '2.7.2'
158159

159160
compileOnly group: 'org.neo4j', name: 'neo4j', version: neo4jVersionEffective
160-
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.3'
161+
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.10.4'
161162
compile group: 'com.opencsv', name: 'opencsv', version: '4.2'
162163
compileOnly group: 'org.ow2.asm', name: 'asm', version: '5.0.2'
163164
compile group: 'com.github.javafaker', name: 'javafaker', version: '0.10'

docs/asciidoc/graph-updates/ttl.adoc

Lines changed: 137 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,179 @@
33

44
[abstract]
55
--
6-
This section describes procedures that can be used to remove nodes from the database once a time limit has been reached.
6+
This section describes procedures that can be used to remove nodes from the database once a time or time limit has been reached.
77
--
88

99
Some nodes are not meant to live forever.
1010
That's why with APOC you can specify a time by when they are removed from the database, by utilizing a schema index and an additional label.
11-
A few convenience procedures help with that.
11+
A few procedures help with that.
1212

13-
ifdef::backend-html5[]
14-
++++
15-
<iframe width="560" height="315" src="https://www.youtube.com/embed/e9aoQ9xOmoU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
16-
++++
17-
endif::[]
13+
This section includes:
1814

19-
Enable TTL with setting in `neo4j.conf` : `apoc.ttl.enabled=true`
15+
* <<ttl-available-procedures, Available Procedures>>
16+
* <<ttl-config-parameters, Configuration and Parameters>>
17+
//* <<ttl-handson-video, Time-To-Live Hands-On>>
18+
* <<ttl-examples, Examples>>
19+
** <<ttl-expireAt, Expire at Specified Time>>
20+
** <<ttl-expireIn, Expire after Amount of Time>>
21+
* <<ttl-process, Manual Process: How TTL Works>>
2022

21-
There are some convenience procedures to expire nodes.
23+
[[ttl-available-procedures]]
24+
== Available Procedures
2225

23-
You can also do it yourself by running
26+
The table below describes the available procedures:
27+
28+
[separator=¦,opts=header,cols="1,1m,1m,5"]
29+
|===
30+
include::../../../build/generated-documentation/apoc.ttl.csv[]
31+
|===
32+
33+
[[ttl-config-parameters]]
34+
== Configuration and Parameters
35+
36+
For configuration, you will need to enable time-to-live functionality with the following settings in `neo4j.conf`:
37+
38+
.neo4j.conf
39+
[source,properties]
40+
----
41+
apoc.ttl.enabled=true
42+
43+
# Optional: controls the repeat frequency
44+
# apoc.ttl.schedule=5
45+
----
46+
47+
In the available procedures listed above, there are several parameters with specific values.
48+
The table below outlines values and formats for the valid parameters.
49+
50+
[options="header"]
51+
|===
52+
| Parameter | Description | Possible Values | Examples
53+
| `node` | The entity or entities to add the label and property of time-to-live (previous selection statement needed) | Any node or group of nodes fitting desired criteria | `n`, `person`, `group`
54+
| `epochTime` | The datetime value of when the node(s) should expire | Any value in epoch seconds or millisecond format | `1540944000`, `1582209630000`
55+
| `time-unit` | Measurement of units for input value | `ms, s, m, h, d` (long forms: `millis, milliseconds, seconds, minutes, hours, days`) | `milliseconds`, `h`
56+
|===
57+
58+
//[[ttl-handson-video]]
59+
//== Time-To-Live Hands-On
60+
//
61+
//ifdef::backend-html5[]
62+
//++++
63+
//<iframe width="560" height="315" src="https://www.youtube.com/embed/e9aoQ9xOmoU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
64+
//++++
65+
//endif::[]
66+
67+
[[ttl-examples]]
68+
== Examples: Time-To-Live
69+
70+
This section includes examples showing how to use the time-to-live procedures.
71+
These examples are based on a movies dataset, which can be imported by running the following Cypher query:
72+
73+
include::../export/createExportGraph.adoc[]
74+
75+
The Neo4j Browser visualization below shows the imported graph:
76+
77+
image::play-movies.png[title="Movies Graph Visualization"]
78+
79+
[[ttl-expireAt]]
80+
=== Expire node(s) at specified time
81+
82+
The `apoc.ttl.expireAtInstant` procedure deletes a node or group of nodes after the datetime specified.
83+
84+
To remove a single node or set of nodes, we can use a selection query prior to calling the procedure that defines which nodes we want to apply the time-to-live label and property.
85+
We then call the procedure and pass in the selected node(s), the future datetime at which we want the nodes to be removed, and the specificity of the datetime (seconds, milliseconds, etc).
2486
2587
[source,cypher]
2688
----
27-
SET n:TTL
28-
SET n.ttl = timestamp() + 3600
89+
MATCH (movie:Movie)<-[produced:PRODUCED]-(person:Person)
90+
CALL apoc.ttl.expireAtInstant(person,1585176720,'s')
91+
RETURN movie, produced, person
2992
----
3093
31-
[cols="1m,5"]
94+
.Results
95+
[opts="header"]
3296
|===
33-
| CALL apoc.date.expire.in(node,time,'time-unit') | expire node in given time-delta by setting :TTL label and `ttl` property
34-
| CALL apoc.date.expire(node,time,'time-unit') | expire node at given time by setting :TTL label and `ttl` property
97+
| "movie" | "produced" | "person"
98+
| {"title":"The Matrix","tagline":"Welcome to the Real World","released":1999} | {} | {"name":"Joel Silver","ttl":1585176720000,"born":1952}
3599
|===
36100
37-
Optionally set `apoc.ttl.schedule=5` as repeat frequency.
101+
After the point in time specified (in this case, after `2020-03-25 17:52:00`), the node(s) will be expired and deleted from the graph.
102+
Running the statement below will return no results for our example graph.
103+
104+
[source,cypher]
105+
----
106+
MATCH (movie:Movie)<-[produced:PRODUCED]-(person:Person)
107+
RETURN movie, produced, person
108+
----
38109
39-
== Process
110+
[[ttl-expireIn]]
111+
=== Expire node(s) after specified time period
40112
41-
30s after startup an index is created:
113+
The `apoc.ttl.expireAfterTimeLength` procedure deletes a node or group of nodes after the length of time specified.
114+
//LEFT OFF HERE!
115+
Just as with the similar procedure above, we can use a selection query prior to calling the procedure that defines which nodes we want to apply the time-to-live label and property.
116+
We then call the procedure and pass in the selected node(s), the time delta from current time at which we want the nodes to be removed, and the specificity of the time amount (seconds, milliseconds, etc).
42117
43118
[source,cypher]
44119
----
45-
CREATE INDEX ON :TTL(ttl)
120+
MATCH (movie:Movie)<-[produced:PRODUCED]-(person:Person)
121+
CALL apoc.ttl.expireAfterTimeLength(person,1585176720,'s')
122+
RETURN movie, produced, person
46123
----
47124
48-
At startup a statement is scheduled to run every 60s (or configure in `neo4j.conf` - `apoc.ttl.schedule=120`)
125+
.Results
126+
[opts="header"]
127+
|===
128+
| "movie" | "produced" | "person"
129+
| {"title":"The Matrix","tagline":"Welcome to the Real World","released":1999} | {} | {"name":"Joel Silver","ttl":120000,"born":1952}
130+
|===
131+
132+
After the length of time specified has passed (in this case, after `120 seconds`), the node(s) will be expired and deleted from the graph.
133+
Running the statement below will return no results for our example graph.
49134
50135
[source,cypher]
51136
----
52-
MATCH (t:TTL) where t.ttl < timestamp() WITH t LIMIT 1000 DETACH DELETE t
137+
MATCH (movie:Movie)<-[produced:PRODUCED]-(person:Person)
138+
RETURN movie, produced, person
53139
----
54140
55-
The `ttl` property holds the *time when the node is expired in milliseconds since epoch*.
141+
[[ttl-process]]
142+
== Manual Process: How TTL Works
56143
57-
You can expire your nodes by setting the :TTL label and the ttl property:
144+
You can also do the time-to-live process manually by running the following steps:
58145
146+
* Set the `:TTL` label and `ttl` property on the node(s) you want to expire.
59147
60148
[source,cypher]
61149
----
62-
MATCH (n:Foo) WHERE n.bar SET n:TTL, n.ttl = timestamp() + 10000;
150+
SET n:TTL
151+
SET n.ttl = timestamp() + 3600
63152
----
64153
65-
There is also a procedure that does the same:
154+
The `ttl` property holds the *time when the node is expired in milliseconds since epoch*.
155+
156+
* Create an index on the time-to-live label and property.
66157
67158
[source,cypher]
68159
----
69-
CALL apoc.date.expire(node,time,'time-unit');
70-
CALL apoc.date.expire(n,100,'s');
160+
CREATE INDEX ON :TTL(ttl)
161+
----
162+
163+
When using the procedure, the index is created 30 seconds after startup.
164+
165+
* Remove node(s) that have passed the expiration time or length of time
166+
167+
[source,cypher]
168+
----
169+
MATCH (t:TTL) where t.ttl < timestamp() WITH t LIMIT 1000 DETACH DELETE t
170+
----
171+
172+
When using the procedure, the deletion statement to remove nodes past expiration will run every 60 seconds.
173+
You can also configure the schedule by adding the following setting in `neo4j.conf`:
174+
175+
176+
.neo4j.conf
177+
[source,properties]
71178
----
179+
# Optional: controls the repeat frequency
180+
apoc.ttl.schedule=120
181+
----

docs/asciidoc/import/loadjson.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,28 @@ You will receive the following response:
195195
"weight": 0.02548018842935562
196196
}
197197
----
198+
199+
== Import JSON
200+
201+
If you used the `apoc.export.json.all` to export the graph, we provide the `apoc.import.json` to reimport that data.
202+
203+
[source,cypher]
204+
----
205+
CALL apoc.import.json($file, $config)
206+
----
207+
208+
The `$config` parameter is a map
209+
210+
[opts=header,cols="m,m"]
211+
|===
212+
| name | default | description
213+
| unwindBatchSize | 5000 | the batch size of the unwind
214+
| txBatchSize | 5000 | the batch size of the transacttion
215+
| importIdName | neo4jImportId | the name of the "id" field into the used for the import it refers to the "id" field into the root object of the json.
216+
| nodePropertyMappings | {} | The mapping label/property name/property type for Custom Neo4j types (point date). I.e. { User: { born: 'Point', dateOfBirth: 'Datetime' } }
217+
| relPropertyMappings | {} | The mapping rel type/property name/property type for Custom Neo4j types (point date). I.e. { KNOWS: { since: 'Datetime' } }
218+
|===
219+
220+
N.b. Supported Neo4j types via config mappings are:
221+
222+
Point, Localdate, Localtime, Localdatetime, Duration, offsettime, Zoneddatetime

docs/asciidoc/path-finding/config-params.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ The procedures support the following config parameters:
66
| name | type | default | description
77
| minLevel | Long | -1 | the minimum number of hops in the traversal. Must be 0 or 1 if specified
88
| maxLevel | Long | -1 | the maximum number of hops in the traversal
9-
| relationshipFilter | String | null | the relationship types and directions to traverse. See <<expand-subgraph-relationship-filters>>.
10-
| labelFilter | String | null | the node labels to traverse. See <<expand-subgraph-label-filters>>.
9+
| relationshipFilter | String | null | the relationship types and directions to traverse.
10+
11+
See <<expand-subgraph-relationship-filters>>.
12+
| labelFilter | String | null | the node labels to traverse.
13+
14+
See <<expand-subgraph-label-filters>>.
1115
| beginSequenceAtStart | Boolean | true | starts matching sequences of node labels and/or relationship types (defined in `relationshipFilter`, `labelFilter`, or `sequences`) one node away from the start node.
1216
| bfs | Boolean | true | use Breadth First Search when traversing. Uses Depth First Search if set to `false`
1317
| filterStartNode | Boolean | false | whether the `labelFilter` and `sequence` apply to the start node of the expansion.

0 commit comments

Comments
 (0)