public class Neo4jIO
extends java.lang.Object
To read from or write to Neo4j you have to provide a Neo4jIO.DriverConfiguration
using
Neo4jIO.DriverConfiguration.create()
or Neo4jIO.DriverConfiguration.create(String, String,
String)
(URL, username and password). Note that subclasses of DriverConfiguration must also be
Serializable
).
At the level of the Neo4j driver configuration you can specify a Neo4j Config
object with
Neo4jIO.DriverConfiguration.withConfig(Config)
. This way you can configure the Neo4j driver
characteristics. Likewise, you can control the characteristics of Neo4j sessions by optionally
passing a SessionConfig
object to Neo4jIO.ReadAll
or Neo4jIO.WriteUnwind
. For example,
the session configuration will allow you to target a specific database or set a fetch size.
Finally, in even rarer cases you might need to configure the various aspects of Neo4j
transactions, for example their timeout. You can do this with a Neo4j TransactionConfig
object.
If you have trouble connecting to a Neo4j Aura database please try to disable a few security algorithms in your JVM. This makes sure that the right one is picked to connect:
Security.setProperty(
"jdk.tls.disabledAlgorithms",
"SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL");
To execute this code on GCP Dataflow you can create a class which extends JvmInitializer
and implement the JvmInitializer.onStartup()
method. You need to annotate
this new class with AutoService
{@code
Modifier and Type | Class and Description |
---|---|
static class |
Neo4jIO.DriverConfiguration
This describes all the information needed to create a Neo4j
Session . |
static class |
Neo4jIO.DriverProviderFromDriverConfiguration
Wraps a
Neo4jIO.DriverConfiguration to provide a Driver . |
static class |
Neo4jIO.ReadAll<ParameterT,OutputT>
This is the class which handles the work behind the
readAll() method. |
static interface |
Neo4jIO.RowMapper<T>
An interface used by
Neo4jIO.ReadAll for converting each row of a Neo4j Result record
Record into an element of the resulting PCollection . |
static class |
Neo4jIO.WriteUnwind<ParameterT>
This is the class which handles the work behind the
writeUnwind() method. |
Constructor and Description |
---|
Neo4jIO() |
Modifier and Type | Method and Description |
---|---|
static <ParameterT,OutputT> |
readAll()
Read all rows using a Neo4j Cypher query.
|
static <ParameterT> |
writeUnwind()
Write all rows using a Neo4j Cypher UNWIND cypher statement.
|
public static <ParameterT,OutputT> Neo4jIO.ReadAll<ParameterT,OutputT> readAll()
ParameterT
- Type of the data representing query parameters.OutputT
- Type of the data to be read.public static <ParameterT> Neo4jIO.WriteUnwind<ParameterT> writeUnwind()
ParameterT
- Type of the data representing query parameters.