Skip to content

Commit 4abf55f

Browse files
knutwalkerjjaderberg
authored andcommitted
Move CallableProcudure behind compat layer
1 parent 31e5a6b commit 4abf55f

File tree

11 files changed

+272
-0
lines changed

11 files changed

+272
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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._43;
21+
22+
import org.neo4j.collection.RawIterator;
23+
import org.neo4j.gds.compat.CompatCallableProcedure;
24+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
25+
import org.neo4j.internal.kernel.api.procs.ProcedureSignature;
26+
import org.neo4j.kernel.api.ResourceTracker;
27+
import org.neo4j.kernel.api.procedure.CallableProcedure;
28+
import org.neo4j.kernel.api.procedure.Context;
29+
import org.neo4j.values.AnyValue;
30+
31+
public final class CallableProcedureImpl implements CallableProcedure {
32+
private final CompatCallableProcedure procedure;
33+
34+
CallableProcedureImpl(CompatCallableProcedure procedure) {
35+
this.procedure = procedure;
36+
}
37+
38+
@Override
39+
public ProcedureSignature signature() {
40+
return this.procedure.signature();
41+
}
42+
43+
@Override
44+
public RawIterator<AnyValue[], ProcedureException> apply(
45+
Context ctx,
46+
AnyValue[] input,
47+
ResourceTracker resourceTracker
48+
) throws ProcedureException {
49+
return this.procedure.apply(ctx, input);
50+
}
51+
}

compatibility/4.3/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_43/Neo4jProxyImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.neo4j.exceptions.KernelException;
3232
import org.neo4j.gds.annotation.SuppressForbidden;
3333
import org.neo4j.gds.compat.BoltTransactionRunner;
34+
import org.neo4j.gds.compat.CompatCallableProcedure;
3435
import org.neo4j.gds.compat.CompatExecutionMonitor;
3536
import org.neo4j.gds.compat.CompatIndexQuery;
3637
import org.neo4j.gds.compat.CompatInput;
@@ -100,6 +101,7 @@
100101
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
101102
import org.neo4j.kernel.api.KernelTransaction;
102103
import org.neo4j.kernel.api.KernelTransactionHandle;
104+
import org.neo4j.kernel.api.procedure.CallableProcedure;
103105
import org.neo4j.kernel.database.NamedDatabaseId;
104106
import org.neo4j.kernel.database.TestDatabaseIdRepository;
105107
import org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl;
@@ -749,6 +751,11 @@ public UserFunctionSignature userFunctionSignature(
749751
);
750752
}
751753

754+
@Override
755+
public CallableProcedure callableProcedure(CompatCallableProcedure procedure) {
756+
return new CallableProcedureImpl(procedure);
757+
}
758+
752759
@Override
753760
public long transactionId(KernelTransactionHandle kernelTransactionHandle) {
754761
return kernelTransactionHandle.lastTransactionTimestampWhenStarted();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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._44;
21+
22+
import org.neo4j.collection.RawIterator;
23+
import org.neo4j.gds.compat.CompatCallableProcedure;
24+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
25+
import org.neo4j.internal.kernel.api.procs.ProcedureSignature;
26+
import org.neo4j.kernel.api.ResourceTracker;
27+
import org.neo4j.kernel.api.procedure.CallableProcedure;
28+
import org.neo4j.kernel.api.procedure.Context;
29+
import org.neo4j.values.AnyValue;
30+
31+
public final class CallableProcedureImpl implements CallableProcedure {
32+
private final CompatCallableProcedure procedure;
33+
34+
CallableProcedureImpl(CompatCallableProcedure procedure) {
35+
this.procedure = procedure;
36+
}
37+
38+
@Override
39+
public ProcedureSignature signature() {
40+
return this.procedure.signature();
41+
}
42+
43+
@Override
44+
public RawIterator<AnyValue[], ProcedureException> apply(
45+
Context ctx,
46+
AnyValue[] input,
47+
ResourceTracker resourceTracker
48+
) throws ProcedureException {
49+
return this.procedure.apply(ctx, input);
50+
}
51+
}

compatibility/4.4/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_44/Neo4jProxyImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.neo4j.exceptions.KernelException;
3131
import org.neo4j.gds.annotation.SuppressForbidden;
3232
import org.neo4j.gds.compat.BoltTransactionRunner;
33+
import org.neo4j.gds.compat.CompatCallableProcedure;
3334
import org.neo4j.gds.compat.CompatExecutionMonitor;
3435
import org.neo4j.gds.compat.CompatIndexQuery;
3536
import org.neo4j.gds.compat.CompatInput;
@@ -101,6 +102,7 @@
101102
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
102103
import org.neo4j.kernel.api.KernelTransaction;
103104
import org.neo4j.kernel.api.KernelTransactionHandle;
105+
import org.neo4j.kernel.api.procedure.CallableProcedure;
104106
import org.neo4j.kernel.database.NamedDatabaseId;
105107
import org.neo4j.kernel.database.NormalizedDatabaseName;
106108
import org.neo4j.kernel.database.TestDatabaseIdRepository;
@@ -752,6 +754,11 @@ public UserFunctionSignature userFunctionSignature(
752754
);
753755
}
754756

757+
@Override
758+
public CallableProcedure callableProcedure(CompatCallableProcedure procedure) {
759+
return new CallableProcedureImpl(procedure);
760+
}
761+
755762
@Override
756763
public long transactionId(KernelTransactionHandle kernelTransactionHandle) {
757764
return kernelTransactionHandle.lastTransactionTimestampWhenStarted();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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._51;
21+
22+
import org.neo4j.collection.RawIterator;
23+
import org.neo4j.gds.compat.CompatCallableProcedure;
24+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
25+
import org.neo4j.internal.kernel.api.procs.ProcedureSignature;
26+
import org.neo4j.kernel.api.ResourceTracker;
27+
import org.neo4j.kernel.api.procedure.CallableProcedure;
28+
import org.neo4j.kernel.api.procedure.Context;
29+
import org.neo4j.values.AnyValue;
30+
31+
public final class CallableProcedureImpl implements CallableProcedure {
32+
private final CompatCallableProcedure procedure;
33+
34+
CallableProcedureImpl(CompatCallableProcedure procedure) {
35+
this.procedure = procedure;
36+
}
37+
38+
@Override
39+
public ProcedureSignature signature() {
40+
return this.procedure.signature();
41+
}
42+
43+
@Override
44+
public RawIterator<AnyValue[], ProcedureException> apply(
45+
Context ctx,
46+
AnyValue[] input,
47+
ResourceTracker resourceTracker
48+
) throws ProcedureException {
49+
return this.procedure.apply(ctx, input);
50+
}
51+
}

compatibility/5.1/neo4j-kernel-adapter/src/main/java17/org/neo4j/gds/compat/_51/Neo4jProxyImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.neo4j.exceptions.KernelException;
3434
import org.neo4j.gds.annotation.SuppressForbidden;
3535
import org.neo4j.gds.compat.BoltTransactionRunner;
36+
import org.neo4j.gds.compat.CompatCallableProcedure;
3637
import org.neo4j.gds.compat.CompatExecutionMonitor;
3738
import org.neo4j.gds.compat.CompatIndexQuery;
3839
import org.neo4j.gds.compat.CompatInput;
@@ -109,6 +110,7 @@
109110
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
110111
import org.neo4j.kernel.api.KernelTransaction;
111112
import org.neo4j.kernel.api.KernelTransactionHandle;
113+
import org.neo4j.kernel.api.procedure.CallableProcedure;
112114
import org.neo4j.kernel.database.NamedDatabaseId;
113115
import org.neo4j.kernel.database.NormalizedDatabaseName;
114116
import org.neo4j.kernel.database.TestDatabaseIdRepository;
@@ -879,6 +881,11 @@ public long transactionId(KernelTransactionHandle kernelTransactionHandle) {
879881
return kernelTransactionHandle.getTransactionSequenceNumber();
880882
}
881883

884+
@Override
885+
public CallableProcedure callableProcedure(CompatCallableProcedure procedure) {
886+
return new CallableProcedureImpl(procedure);
887+
}
888+
882889
@Override
883890
public void reserveNeo4jIds(IdGeneratorFactory generatorFactory, int size, CursorContext cursorContext) {
884891
IdGenerator idGenerator = generatorFactory.get(RecordIdType.NODE);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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._52;
21+
22+
import org.neo4j.collection.RawIterator;
23+
import org.neo4j.gds.compat.CompatCallableProcedure;
24+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
25+
import org.neo4j.internal.kernel.api.procs.ProcedureSignature;
26+
import org.neo4j.kernel.api.ResourceTracker;
27+
import org.neo4j.kernel.api.procedure.CallableProcedure;
28+
import org.neo4j.kernel.api.procedure.Context;
29+
import org.neo4j.values.AnyValue;
30+
31+
public final class CallableProcedureImpl implements CallableProcedure {
32+
private final CompatCallableProcedure procedure;
33+
34+
CallableProcedureImpl(CompatCallableProcedure procedure) {
35+
this.procedure = procedure;
36+
}
37+
38+
@Override
39+
public ProcedureSignature signature() {
40+
return this.procedure.signature();
41+
}
42+
43+
@Override
44+
public RawIterator<AnyValue[], ProcedureException> apply(
45+
Context ctx,
46+
AnyValue[] input,
47+
ResourceTracker resourceTracker
48+
) throws ProcedureException {
49+
return this.procedure.apply(ctx, input);
50+
}
51+
}

compatibility/5.2/neo4j-kernel-adapter/src/main/java17/org/neo4j/gds/compat/_52/Neo4jProxyImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.neo4j.exceptions.KernelException;
3434
import org.neo4j.gds.annotation.SuppressForbidden;
3535
import org.neo4j.gds.compat.BoltTransactionRunner;
36+
import org.neo4j.gds.compat.CompatCallableProcedure;
3637
import org.neo4j.gds.compat.CompatExecutionMonitor;
3738
import org.neo4j.gds.compat.CompatIndexQuery;
3839
import org.neo4j.gds.compat.CompatInput;
@@ -109,6 +110,7 @@
109110
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
110111
import org.neo4j.kernel.api.KernelTransaction;
111112
import org.neo4j.kernel.api.KernelTransactionHandle;
113+
import org.neo4j.kernel.api.procedure.CallableProcedure;
112114
import org.neo4j.kernel.database.NamedDatabaseId;
113115
import org.neo4j.kernel.database.NormalizedDatabaseName;
114116
import org.neo4j.kernel.database.TestDatabaseIdRepository;
@@ -872,6 +874,11 @@ public UserFunctionSignature userFunctionSignature(
872874
);
873875
}
874876

877+
@Override
878+
public CallableProcedure callableProcedure(CompatCallableProcedure procedure) {
879+
return new CallableProcedureImpl(procedure);
880+
}
881+
875882
@Override
876883
public long transactionId(KernelTransactionHandle kernelTransactionHandle) {
877884
return kernelTransactionHandle.getTransactionSequenceNumber();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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;
21+
22+
import org.neo4j.collection.RawIterator;
23+
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
24+
import org.neo4j.internal.kernel.api.procs.ProcedureSignature;
25+
import org.neo4j.kernel.api.procedure.Context;
26+
import org.neo4j.values.AnyValue;
27+
28+
public interface CompatCallableProcedure {
29+
ProcedureSignature signature();
30+
31+
RawIterator<AnyValue[], ProcedureException> apply(Context ctx, AnyValue[] input) throws ProcedureException;
32+
}

compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxyApi.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
6868
import org.neo4j.kernel.api.KernelTransaction;
6969
import org.neo4j.kernel.api.KernelTransactionHandle;
70+
import org.neo4j.kernel.api.procedure.CallableProcedure;
7071
import org.neo4j.kernel.database.NamedDatabaseId;
7172
import org.neo4j.kernel.impl.store.RecordStore;
7273
import org.neo4j.kernel.impl.store.format.RecordFormats;
@@ -293,6 +294,8 @@ UserFunctionSignature userFunctionSignature(
293294
boolean threadSafe
294295
);
295296

297+
CallableProcedure callableProcedure(CompatCallableProcedure procedure);
298+
296299
long transactionId(KernelTransactionHandle kernelTransactionHandle);
297300

298301
void reserveNeo4jIds(IdGeneratorFactory generatorFactory, int size, CursorContext cursorContext);

0 commit comments

Comments
 (0)