Skip to content

Commit 42f5ffc

Browse files
committed
Publish compat layer for DB V5.11
1 parent ca26e08 commit 42f5ffc

File tree

51 files changed

+5372
-2
lines changed

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

+5372
-2
lines changed
Lines changed: 65 additions & 0 deletions
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.11'
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.11'
22+
23+
compileOnly project(':annotations')
24+
compileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: ver.'spotbugsToolVersion'
25+
compileOnly group: 'org.immutables', name: 'value-annotations', version: ver.'immutables'
26+
compileOnly group: 'org.neo4j', name: 'annotations', version: neos.'5.11'
27+
compileOnly group: 'org.neo4j', name: 'neo4j', version: neos.'5.11'
28+
compileOnly group: 'org.neo4j', name: 'neo4j-record-storage-engine', version: neos.'5.11'
29+
compileOnly group: 'org.neo4j.community', name: 'it-test-support', version: neos.'5.11'
30+
31+
implementation project(':neo4j-kernel-adapter-api')
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.11'
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.11'
59+
java17CompileOnly group: 'org.neo4j', name: 'neo4j-record-storage-engine', version: neos.'5.11'
60+
java17CompileOnly group: 'org.neo4j.community', name: 'it-test-support', version: neos.'5.11'
61+
java17CompileOnly group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: ver.'spotbugsToolVersion'
62+
63+
java17Implementation project(':neo4j-kernel-adapter-api')
64+
}
65+
}
Lines changed: 44 additions & 0 deletions
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._511;
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.11 compatibility requires JDK17");
38+
}
39+
40+
@Override
41+
public String description() {
42+
return "Neo4j 5.11 (placeholder)";
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
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._511;
21+
22+
import org.neo4j.annotations.service.ServiceProvider;
23+
import org.neo4j.gds.compat.Neo4jVersion;
24+
import org.neo4j.gds.compat.SettingProxyApi;
25+
import org.neo4j.gds.compat.SettingProxyFactory;
26+
27+
@ServiceProvider
28+
public final class SettingProxyFactoryImpl implements SettingProxyFactory {
29+
30+
@Override
31+
public boolean canLoad(Neo4jVersion version) {
32+
return false;
33+
}
34+
35+
@Override
36+
public SettingProxyApi load() {
37+
throw new UnsupportedOperationException("5.11 compatibility requires JDK17");
38+
}
39+
40+
@Override
41+
public String description() {
42+
return "Neo4j Settings 5.11 (placeholder)";
43+
}
44+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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._511;
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+
boltTransaction.executeQuery(query, parameters, true, querySubscriber);
73+
}
74+
75+
@Override
76+
protected BoltTransaction beginBoltWriteTransaction(
77+
BoltGraphDatabaseServiceSPI fabricDb,
78+
LoginContext loginContext,
79+
KernelTransaction.Type kernelTransactionType,
80+
ClientConnectionInfo clientConnectionInfo,
81+
List<String> bookmarks,
82+
Duration txTimeout,
83+
Map<String, Object> txMetadata
84+
) {
85+
return fabricDb.beginTransaction(
86+
kernelTransactionType,
87+
loginContext,
88+
clientConnectionInfo,
89+
bookmarks,
90+
txTimeout,
91+
AccessMode.WRITE,
92+
txMetadata,
93+
new RoutingContext(true, Map.of()),
94+
QueryExecutionConfiguration.DEFAULT_CONFIG
95+
);
96+
}
97+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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._511;
21+
22+
import org.neo4j.collection.RawIterator;
23+
import org.neo4j.gds.annotation.SuppressForbidden;
24+
import org.neo4j.gds.compat.CompatCallableProcedure;
25+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
26+
import org.neo4j.internal.kernel.api.procs.ProcedureSignature;
27+
import org.neo4j.kernel.api.ResourceMonitor;
28+
import org.neo4j.kernel.api.procedure.CallableProcedure;
29+
import org.neo4j.kernel.api.procedure.Context;
30+
import org.neo4j.values.AnyValue;
31+
32+
@SuppressForbidden(reason = "This is the compat API")
33+
public final class CallableProcedureImpl implements CallableProcedure {
34+
private final CompatCallableProcedure procedure;
35+
36+
CallableProcedureImpl(CompatCallableProcedure procedure) {
37+
this.procedure = procedure;
38+
}
39+
40+
@Override
41+
public ProcedureSignature signature() {
42+
return this.procedure.signature();
43+
}
44+
45+
@Override
46+
public RawIterator<AnyValue[], ProcedureException> apply(
47+
Context ctx,
48+
AnyValue[] input,
49+
ResourceMonitor resourceMonitor
50+
) throws ProcedureException {
51+
return this.procedure.apply(ctx, input);
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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._511;
21+
22+
import org.neo4j.gds.annotation.SuppressForbidden;
23+
import org.neo4j.gds.compat.CompatUserAggregationFunction;
24+
import org.neo4j.gds.compat.CompatUserAggregator;
25+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
26+
import org.neo4j.internal.kernel.api.procs.UserAggregationReducer;
27+
import org.neo4j.internal.kernel.api.procs.UserAggregationUpdater;
28+
import org.neo4j.internal.kernel.api.procs.UserFunctionSignature;
29+
import org.neo4j.kernel.api.procedure.CallableUserAggregationFunction;
30+
import org.neo4j.kernel.api.procedure.Context;
31+
import org.neo4j.values.AnyValue;
32+
33+
@SuppressForbidden(reason = "This is the compat API")
34+
public final class CallableUserAggregationFunctionImpl implements CallableUserAggregationFunction {
35+
private final CompatUserAggregationFunction function;
36+
37+
CallableUserAggregationFunctionImpl(CompatUserAggregationFunction function) {
38+
this.function = function;
39+
}
40+
41+
@Override
42+
public UserFunctionSignature signature() {
43+
return this.function.signature();
44+
}
45+
46+
@Override
47+
public UserAggregationReducer createReducer(Context ctx) throws ProcedureException {
48+
return new UserAggregatorImpl(this.function.create(ctx));
49+
}
50+
51+
private static final class UserAggregatorImpl implements UserAggregationReducer, UserAggregationUpdater {
52+
private final CompatUserAggregator aggregator;
53+
54+
private UserAggregatorImpl(CompatUserAggregator aggregator) {
55+
this.aggregator = aggregator;
56+
}
57+
58+
@Override
59+
public UserAggregationUpdater newUpdater() {
60+
return this;
61+
}
62+
63+
@Override
64+
public void update(AnyValue[] input) throws ProcedureException {
65+
this.aggregator.update(input);
66+
}
67+
68+
@Override
69+
public void applyUpdates() {
70+
}
71+
72+
@Override
73+
public AnyValue result() throws ProcedureException {
74+
return this.aggregator.result();
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)