Skip to content

Commit eee6473

Browse files
committed
Add 5.16 compatibility
1 parent 1445d48 commit eee6473

33 files changed

+3668
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apply plugin: 'java-library'
2+
apply plugin: 'me.champeau.mrjar'
3+
4+
description = 'Neo4j Graph Data Science :: Neo4j Kernel Adapter 5.16'
5+
6+
group = 'org.neo4j.gds'
7+
8+
// for all 5.x versions
9+
if (ver.'neo4j'.startsWith('5.')) {
10+
sourceSets {
11+
main {
12+
java {
13+
srcDirs = ['src/main/java17']
14+
}
15+
}
16+
}
17+
18+
dependencies {
19+
annotationProcessor project(':annotations')
20+
annotationProcessor group: 'org.immutables', name: 'value', version: ver.'immutables'
21+
annotationProcessor group: 'org.neo4j', name: 'annotations', version: neos.'5.16'
22+
23+
compileOnly project(':annotations')
24+
compileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
25+
compileOnly group: 'org.neo4j', name: 'annotations', version: neos.'5.16'
26+
compileOnly group: 'org.neo4j', name: 'neo4j', version: neos.'5.16'
27+
compileOnly group: 'org.neo4j', name: 'neo4j-record-storage-engine', version: neos.'5.16'
28+
compileOnly group: 'org.neo4j.community', name: 'it-test-support', version: neos.'5.16'
29+
30+
implementation project(':neo4j-kernel-adapter-api')
31+
implementation project(':neo4j-kernel-adapter-5-common')
32+
}
33+
} else {
34+
multiRelease {
35+
targetVersions 11, 17
36+
}
37+
38+
if (!project.hasProperty('no-forbidden-apis')) {
39+
forbiddenApisJava17 {
40+
exclude('**')
41+
}
42+
}
43+
44+
dependencies {
45+
annotationProcessor group: 'org.neo4j', name: 'annotations', version: ver.'neo4j'
46+
47+
compileOnly project(':annotations')
48+
compileOnly group: 'org.neo4j', name: 'annotations', version: ver.'neo4j'
49+
50+
implementation project(':neo4j-kernel-adapter-api')
51+
52+
java17AnnotationProcessor project(':annotations')
53+
java17AnnotationProcessor group: 'org.immutables', name: 'value', version: ver.'immutables'
54+
java17AnnotationProcessor group: 'org.neo4j', name: 'annotations', version: neos.'5.16'
55+
56+
java17CompileOnly project(':annotations')
57+
java17CompileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
58+
java17CompileOnly group: 'org.neo4j', name: 'neo4j', version: neos.'5.16'
59+
java17CompileOnly group: 'org.neo4j', name: 'neo4j-record-storage-engine', version: neos.'5.16'
60+
java17CompileOnly group: 'org.neo4j.community', name: 'it-test-support', version: neos.'5.16'
61+
62+
java17Implementation project(':neo4j-kernel-adapter-api')
63+
java17Implementation project(':neo4j-kernel-adapter-5-common')
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.compat._516;
21+
22+
import org.neo4j.annotations.service.ServiceProvider;
23+
import org.neo4j.gds.compat.Neo4jProxyApi;
24+
import org.neo4j.gds.compat.Neo4jProxyFactory;
25+
import org.neo4j.gds.compat.Neo4jVersion;
26+
27+
@ServiceProvider
28+
public final class Neo4jProxyFactoryImpl implements Neo4jProxyFactory {
29+
30+
@Override
31+
public boolean canLoad(Neo4jVersion version) {
32+
return false;
33+
}
34+
35+
@Override
36+
public Neo4jProxyApi load() {
37+
throw new UnsupportedOperationException("5.16 compatibility requires JDK17");
38+
}
39+
40+
@Override
41+
public String description() {
42+
return "Neo4j 5.16 (placeholder)";
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.compat._516;
21+
22+
import org.neo4j.bolt.dbapi.BoltGraphDatabaseServiceSPI;
23+
import org.neo4j.bolt.dbapi.BoltTransaction;
24+
import org.neo4j.bolt.protocol.common.message.AccessMode;
25+
import org.neo4j.bolt.protocol.common.message.request.connection.RoutingContext;
26+
import org.neo4j.bolt.tx.statement.StatementQuerySubscriber;
27+
import org.neo4j.exceptions.KernelException;
28+
import org.neo4j.gds.compat.BoltQuerySubscriber;
29+
import org.neo4j.gds.compat.BoltTransactionRunner;
30+
import org.neo4j.graphdb.QueryStatistics;
31+
import org.neo4j.internal.kernel.api.connectioninfo.ClientConnectionInfo;
32+
import org.neo4j.internal.kernel.api.security.LoginContext;
33+
import org.neo4j.kernel.api.KernelTransaction;
34+
import org.neo4j.kernel.impl.query.QueryExecutionConfiguration;
35+
import org.neo4j.kernel.impl.query.QueryExecutionKernelException;
36+
import org.neo4j.values.virtual.MapValue;
37+
38+
import java.time.Duration;
39+
import java.util.List;
40+
import java.util.Map;
41+
42+
public class BoltTransactionRunnerImpl extends BoltTransactionRunner<StatementQuerySubscriber, String> {
43+
44+
@Override
45+
protected BoltQuerySubscriber<StatementQuerySubscriber> boltQuerySubscriber() {
46+
var subscriber = new StatementQuerySubscriber();
47+
return new BoltQuerySubscriber<>() {
48+
@Override
49+
public void assertSucceeded() throws KernelException {
50+
subscriber.assertSuccess();
51+
}
52+
53+
@Override
54+
public QueryStatistics queryStatistics() {
55+
return subscriber.getStatistics();
56+
}
57+
58+
@Override
59+
public StatementQuerySubscriber innerSubscriber() {
60+
return subscriber;
61+
}
62+
};
63+
}
64+
65+
@Override
66+
protected void executeQuery(
67+
BoltTransaction boltTransaction,
68+
String query,
69+
MapValue parameters,
70+
StatementQuerySubscriber querySubscriber
71+
) throws QueryExecutionKernelException {
72+
try {
73+
boltTransaction.executeQuery(query, parameters, true, querySubscriber)
74+
.queryExecution() // This fella here is quite lazy
75+
.consumeAll(); // We need to do this in order to trigger the query execution.
76+
} catch (Exception e) {
77+
throw new RuntimeException(e);
78+
}
79+
}
80+
81+
@Override
82+
protected BoltTransaction beginBoltWriteTransaction(
83+
BoltGraphDatabaseServiceSPI fabricDb,
84+
LoginContext loginContext,
85+
KernelTransaction.Type kernelTransactionType,
86+
ClientConnectionInfo clientConnectionInfo,
87+
List<String> bookmarks,
88+
Duration txTimeout,
89+
Map<String, Object> txMetadata
90+
) {
91+
return fabricDb.beginTransaction(
92+
kernelTransactionType,
93+
loginContext,
94+
clientConnectionInfo,
95+
bookmarks,
96+
txTimeout,
97+
AccessMode.WRITE,
98+
txMetadata,
99+
new RoutingContext(true, Map.of()),
100+
QueryExecutionConfiguration.DEFAULT_CONFIG
101+
);
102+
}
103+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.compat._516;
21+
22+
import org.neo4j.annotations.service.ServiceProvider;
23+
import org.neo4j.gds.compat.Neo4jProxyApi;
24+
import org.neo4j.gds.compat.Neo4jProxyFactory;
25+
import org.neo4j.gds.compat.Neo4jVersion;
26+
27+
@ServiceProvider
28+
public final class Neo4jProxyFactoryImpl implements Neo4jProxyFactory {
29+
30+
@Override
31+
public boolean canLoad(Neo4jVersion version) {
32+
return version == Neo4jVersion.V_5_16;
33+
}
34+
35+
@Override
36+
public Neo4jProxyApi load() {
37+
return new Neo4jProxyImpl();
38+
}
39+
40+
@Override
41+
public String description() {
42+
return "Neo4j 5.16";
43+
}
44+
}

0 commit comments

Comments
 (0)