Skip to content

Commit fc89d2c

Browse files
renetapopovarecrwplay
authored andcommitted
editorial review
1 parent 0d99e28 commit fc89d2c

34 files changed

+358
-415
lines changed

modules/ROOT/pages/extending-neo4j/aggregation-functions.adoc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
:description: How to write, test and deploy a user-defined aggregation function for Neo4j.
1+
:description: How to write, test, and deploy a user-defined aggregation function for Neo4j.
22

33
:org-neo4j-procedure-UserAggregationFunction: {neo4j-javadocs-base-uri}/org/neo4j/procedure/UserAggregationFunction.html
44

55

66
[[extending-neo4j-aggregation-functions]]
77
= User-defined aggregation functions
88

9-
This describes how to write, test and deploy a user-defined aggregation function for Neo4j.
10-
119
_User-defined aggregation functions_ are functions that aggregate data and return a single result.
12-
For a comparison between user-defined procedures, functions, and aggregation functions see xref:extending-neo4j/customized-code.adoc[].
10+
For a comparison between user-defined procedures, functions, and aggregation functions, see xref:extending-neo4j/customized-code.adoc[].
1311

1412

1513
[[call-user-defined-aggregation-function]]
16-
== Call a aggregation function
14+
== Call an aggregation function
1715

1816
User-defined aggregation functions are called in the same way as any other Cypher aggregation function.
1917
The function name must be fully qualified, so a function named `longestString` defined in the package `org.neo4j.examples` could be called using:
@@ -32,15 +30,15 @@ User-defined aggregation functions are annotated with `@UserAggregationFunction`
3230
The annotated function must return an instance of an aggregator class.
3331
An aggregator class contains one method annotated with `@UserAggregationUpdate` and one method annotated with `@UserAggregationResult`.
3432
The method annotated with `@UserAggregationUpdate` will be called multiple times and enables the class to aggregate data.
35-
When the aggregation is done the method annotated with `@UserAggregationResult` is called once and the result of the aggregation will be returned.
33+
When the aggregation is done, the method annotated with `@UserAggregationResult` will be called once and the result of the aggregation will be returned.
3634

3735
See xref:extending-neo4j/values-and-types.adoc[] for details on values and types.
3836

3937
For more details, see the Neo4j Javadocs for link:{org-neo4j-procedure-UserAggregationFunction}[`org.neo4j.procedure.UserAggregationFunction`^].
4038

4139
[NOTE]
4240
====
43-
The correct way to signal an error from within an aggregation function is to throw a `RuntimeException`.
41+
The correct way to signal an error from within an aggregation function is to throw `RuntimeException`.
4442
====
4543

4644
[source, java]
@@ -92,8 +90,8 @@ public class LongestString
9290

9391
Tests for user-defined aggregation functions are created in the same way as those for normal user-defined functions.
9492

95-
Below is a template for testing a user-defined aggregation function that finds the longest string.
9693

94+
.A template for testing a user-defined aggregation function that finds the longest string.
9795
[source, java]
9896
----
9997
package example;

modules/ROOT/pages/extending-neo4j/best-practices.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
[[best-practices]]
55
= Best practices
66

7-
It is also important to consider any security implications of deploying customized code.
7+
It is important to consider any security implications of deploying customized code.
88
Refer to the link:{neo4j-docs-base-uri}/operations-manual/{page-version}/security/securing-extensions[Operations Manual -> Securing Extensions] for details on best practices for securing user-defined procedures and functions.
99

10-
Since you will be running customized-built code and Neo4j in the same JVM, there are a few things you should keep in mind:
10+
Since you will be running custom-built code and Neo4j in the same JVM, there are a few things you should keep in mind:
1111

1212
* Do not create or retain more objects than you strictly need to.
1313
Large caches in particular tend to promote more objects to the old generation, thus increasing the need for expensive full garbage collections.
1414
* Do not use internal Neo4j APIs.
1515
They are internal to Neo4j and subject to change without notice, which may break or change the behavior of your code.
1616
* If possible, avoid using Java object serialization or reflection in your code or in any runtime dependency that you use.
17-
Otherwise, if you cannot avoid using Java object serialization and reflection, then ensure that the `-XX:+TrustFinalNonStaticFields` JVM flag is disabled in `neo4j.conf`.
17+
If you cannot avoid using Java object serialization and reflection, ensure that the `-XX:+TrustFinalNonStaticFields` JVM flag is disabled in `neo4j.conf`.
1818

modules/ROOT/pages/extending-neo4j/customized-code.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ This is the preferred means for extending Neo4j.
1010
Examples of use cases for procedures and functions are:
1111

1212
* To provide access to functionality that is not available in Cypher.
13-
* To provide access to third party systems.
13+
* To provide access to third-party systems.
1414
* To perform graph-global operations, such as counting connected components or finding dense nodes.
1515
* To express a procedural operation that is difficult to express declaratively with Cypher.
1616

17-
Procedures and functions are written in Java and compiled into _jar_ files.
18-
They are deployed to the database by dropping that _jar_ file into the _plugins_ directory on each standalone or clustered server.
19-
For the location of the _plugins_ directory, refer to link:{neo4j-docs-base-uri}/operations-manual/{page-version}/configuration/file-locations[Operations Manual -> File locations].
20-
The database must be re-started on each server to pick up new procedures and functions.
17+
Procedures and functions are written in Java and compiled into JAR files.
18+
They are deployed to the database by dropping that JAR file into the _plugins_ directory on each standalone or clustered server.
19+
For the location of the _plugins_ directory, refer to link:{neo4j-docs-base-uri}/operations-manual/{page-version}/configuration/file-locations[Operations Manual -> Default file locations].
20+
The database must be restarted on each server to pick up new procedures and functions.
2121

2222
Procedures and functions can take arguments and return results.
2323
In addition, procedures can perform write operations on the database.
@@ -32,13 +32,13 @@ In addition, procedures can perform write operations on the database.
3232
| Cardinality
3333

3434
| `Procedure`
35-
| For each row the procedure takes parameters and returns multiple results.
35+
| For each row, the procedure takes parameters and returns multiple results.
3636
| `+CALL abc(...)+`
3737
| Update allowed.
3838
| Changes cardinality similarly to a `MATCH` clause (0, 1, or many).
3939

4040
| `Scalar function`
41-
| For each row the function takes parameters and returns a single result.
41+
| For each row, the function takes parameters and returns a single result.
4242
| `+abc(...)+`
4343
| Read-only.
4444
| Maintains cardinality, one for one.
@@ -53,9 +53,9 @@ In addition, procedures can perform write operations on the database.
5353

5454
Neo4j also comes bundled with a number of _built-in_ procedures and functions.
5555

56-
The available built-in procedures varies depending edition and mode, as described in link:{neo4j-docs-base-uri}/operations-manual/{page-version}/reference/procedures[Operations Manual -> Procedures].
57-
Running `SHOW PROCEDURES` will display the full list of procedures available in a particular database instance, including user-defined procedures.
56+
The available built-in procedures vary depending on edition and mode, as described in link:{neo4j-docs-base-uri}/operations-manual/{page-version}/reference/procedures[Operations Manual -> Procedures].
57+
Running `SHOW PROCEDURES` displays the full list of procedures available in your Neo4j DBMS, including user-defined procedures.
5858

5959
The built-in functions are described in link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/functions[Cypher Manual -> Functions].
60-
Running `SHOW FUNCTIONS` will display the full list of all the functions available in a particular database instance, including user-defined functions.
60+
Running `SHOW FUNCTIONS` displays the full list of all the functions available in your Neo4j DBMS, including user-defined functions.
6161

modules/ROOT/pages/extending-neo4j/full-text-analyzer-provider.adoc

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
[[extending-neo4j-analyzer-provider]]
55
= Full-text index analyzer providers
66

7-
This describes how to extend full-text index analyzers provided in Neo4j.
8-
97
Full-text indexes always have an analyzer, which describes how text is analyzed for indexing and querying.
10-
The analyzer breaks the text up into smaller tokens, and processes these tokens with a number of filters.
11-
These filters can do many different things.
12-
For example, some remove stop-words, such as "the" and "is", while others transform the tokens by stemming them, or turn them into lower-case.
8+
The analyzer breaks the text up into smaller tokens and processes these tokens using filters.
9+
The filters can do different things, such as removing stop-words (e.g., _the_ and _is_), stemming the tokens, or turning them into lower-case.
1310

14-
Which analyzer you should use depends on what you want to use the index for.
15-
For example, if the text being indexed belong to a special domain, such as email addresses, you would want an analyzer specific to that domain.
11+
Which analyzer to use, depends on what you want to use the index for.
12+
For example, if the text being indexed belongs to a special domain, such as email addresses, you would want an analyzer specific to that domain.
1613
Or if the text is always in a particular language, such as Russian, you could use an analyzer specific to that language.
1714

1815
Neo4j comes with a number of built-in analyzers.
@@ -24,7 +21,7 @@ This default can be changed with the `dbms.index.fulltext.default_analyzer` sett
2421
This setting only takes effect when a full-text index is created.
2522
Once a full-text index has been created, it remembers the analyzer in its index-specific settings.
2623

27-
It is possible to extend the available analyzers in Neo4j, by implementing an `AnalyzerProvider`.
24+
It is possible to extend the available analyzers in Neo4j by implementing `AnalyzerProvider`.
2825
The `AnalyzerProvider` acts as a factory, which builds the concrete Lucene `Analyzer` instance used by the index.
2926
The following example creates a customized analyzer:
3027

@@ -61,21 +58,21 @@ public class CustomAnalyzerProvider extends AnalyzerProvider // <1>
6158
<1> The `CustomAnalyzerProvider` class must be `public`, and it must extend the `org.neo4j.graphdb.schema.AnalyzerProvider` class.
6259
<2> The `CustomAnalyzerProvider` class must additionally have a `public` constructor that takes no arguments.
6360
Without this constructor, the new analyzer provider will not be loaded by Neo4j.
64-
There will be no warnings logged when an analyzer provider is ignored for this reason, so take care.
61+
There will be no warnings logged when an analyzer provider is ignored because of this reason, so take care.
6562
<3> The constructor must then call its super-constructor, and give the name of the `custom-analyzer` provider as an argument.
66-
This is the name that will be used to refer to this analyzer provider, when configuring indexes.
63+
This is the name that will be used to refer to this analyzer provider when configuring indexes.
6764
<4> Lastly, the `createAnalyzer` method must be implemented.
6865
This method creates and returns the concrete `Analyzer` instance, that the indexes will use.
69-
If this method returns `null` or throws an exception, then the index will be marked as FAILED.
70-
<5> In this example, we are creating instances of Lucene's `CustomAnalyzer`.
71-
We can, however, create and return anything that extends the `org.apache.lucene.analysis.Analyzer` class.
66+
If this method returns `null` or throws an exception, the index will be marked as FAILED.
67+
<5> This example creates instances of Lucene's `CustomAnalyzer`.
68+
You can, however, create and return anything that extends the `org.apache.lucene.analysis.Analyzer` class.
7269

7370
Follow the guide in xref:extending-neo4j/project-setup.adoc[], to learn how to package the customized `AnalyzerProvider` in a JAR file that can be integrated into Neo4j.
7471

7572
The analyzer providers are picked up by Neo4j via service loading.
76-
This means that in addition to having implemented the class above, we must also add the fully qualified class name to a service file, and put that file on the class path.
73+
This means that in addition to having implemented the class, you must also add the fully qualified class name to a service file, and put that file on the classpath.
7774
These service files are usually included in the JAR file that contains the Neo4j extensions.
78-
In a typical Maven project, such as the one created by the guide above, the directory structure would look like this:
75+
In a typical Maven project, such as the one created by xref:extending-neo4j/project-setup.adoc[], the directory structure would look like this:
7976

8077
[source]
8178
----
@@ -92,11 +89,11 @@ project/
9289
----
9390
<1> This is the `CustomAnalyzerProvider` from our previous code example.
9491
<2> This is the service loader file.
95-
It is a plain-text file that contains a line, with the fully qualified name, for each `AnalyzerProvider` we implement in our project.
92+
It is a plain-text file that contains a line, with the fully qualified name, for each `AnalyzerProvider` implemented in our project.
9693
In this case, it contains a single line: `my_package.CustomAnalyzerProvider`.
9794

9895

99-
In order for the `META-INF/services` resources to be handled correctly by the `maven-shade-plugin`, it may be necessary to include a service resource transformation to the plug-in configuration.
96+
For the `META-INF/services` resources to be handled correctly by the `maven-shade-plugin`, it may be necessary to include a service resource transformation to the plug-in configuration.
10097
This is an example of what that may look like:
10198

10299
[source, xml]

modules/ROOT/pages/extending-neo4j/functions.adoc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
[[extending-neo4j-functions]]
77
= User-defined functions
88

9-
This describes how to write, test and deploy a user-defined function for Neo4j.
10-
11-
_User-defined functions_ are a simpler form of procedures that are read-only and always return a single value.
12-
Although they are not as powerful in capability, they are often easier to use and more efficient than procedures for many common tasks.
9+
_User-defined functions_ are simpler forms of procedures that return a single value and are read-only.
10+
Although they are less powerful in capability, they are often easier to use and more efficient than procedures for many common tasks.
1311
For a comparison between user-defined procedures, functions, and aggregation functions see xref:extending-neo4j/customized-code.adoc[].
1412

1513

@@ -29,15 +27,16 @@ RETURN org.neo4j.examples.join(collect(p.names))
2927
[[writing-udf]]
3028
== Create a function
3129

32-
User-defined functions are created similarly to how procedures are created, but are instead annotated with `@UserFunction` and instead of returning a stream of values it returns a single value.
30+
User-defined functions are created similarly to how procedures are created.
31+
But unlike procedures, they are annotated with `@UserFunction` and return a single value instead of a stream of values.
3332

3433
See xref:extending-neo4j/values-and-types.adoc[] for details on values and types.
3534

3635
For more details, see the link:{org-neo4j-procedure-UserFunction}[Neo4j Javadocs for `org.neo4j.procedure.UserFunction`^].
3736

3837
[NOTE]
3938
====
40-
The correct way to signal an error from within a function is to throw a `RuntimeException`.
39+
The correct way to signal an error from within a function is to throw `RuntimeException`.
4140
====
4241

4342
[source, java]
@@ -68,8 +67,7 @@ public class Join
6867

6968
Tests for user-defined functions are created in the same way as those for procedures.
7069

71-
Below is a template for testing a user-defined function that joins a list of strings.
72-
70+
.A template for testing a user-defined function that joins a list of strings.
7371
[source, java]
7472
----
7573
package example;

modules/ROOT/pages/extending-neo4j/index.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
= Extending Neo4j
66

77
This section describes how to extend Neo4j and Cypher using procedures, functions, and plugins.
8-
This section introduces different methods to extend the standard Neo4j functionality.
9-
How to set up remote debugging is also explained.
8+
It introduces different methods to extend the standard Neo4j functionality and explains how to set up remote debugging.
109

1110
Neo4j provides the following methods to extend the standard functionality:
1211

@@ -19,7 +18,7 @@ Writing extensions requires the user to be familiar with Java or other JVM progr
1918
//The following topics are:
2019
//
2120
//How to develop and deploy user-defined procedures and functions.
22-
//How to develop and deploy a customized authentication and authorization plugins.
21+
//How to develop and deploy customized authentication and authorization plugins.
2322
//How to customize the analyzer used in a full-text index.
2423
//How to build extensions for the Neo4j HTTP server.
2524
//How to configure the Neo4j server for remote debugging sessions.

0 commit comments

Comments
 (0)