Skip to content

Commit dd77e7e

Browse files
committed
Update 54 compat
1 parent cb0d7c5 commit dd77e7e

File tree

3 files changed

+90
-11
lines changed

3 files changed

+90
-11
lines changed
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._54;
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+
}

compatibility/5.4/neo4j-kernel-adapter/src/main/java17/org/neo4j/gds/compat/_54/Neo4jProxyImpl.java

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.neo4j.gds.compat.CompatExecutionMonitor;
3838
import org.neo4j.gds.compat.CompatIndexQuery;
3939
import org.neo4j.gds.compat.CompatInput;
40+
import org.neo4j.gds.compat.CompatUserAggregationFunction;
4041
import org.neo4j.gds.compat.CompositeNodeCursor;
4142
import org.neo4j.gds.compat.CustomAccessMode;
4243
import org.neo4j.gds.compat.GdsDatabaseLayout;
@@ -111,6 +112,7 @@
111112
import org.neo4j.kernel.api.KernelTransaction;
112113
import org.neo4j.kernel.api.KernelTransactionHandle;
113114
import org.neo4j.kernel.api.procedure.CallableProcedure;
115+
import org.neo4j.kernel.api.procedure.CallableUserAggregationFunction;
114116
import org.neo4j.kernel.database.NamedDatabaseId;
115117
import org.neo4j.kernel.database.NormalizedDatabaseName;
116118
import org.neo4j.kernel.database.TestDatabaseIdRepository;
@@ -891,6 +893,12 @@ public CallableProcedure callableProcedure(CompatCallableProcedure procedure) {
891893
return new CallableProcedureImpl(procedure);
892894
}
893895

896+
@Override
897+
@SuppressForbidden(reason = "This is the compat API")
898+
public CallableUserAggregationFunction callableUserAggregationFunction(CompatUserAggregationFunction function) {
899+
return new CallableUserAggregationFunctionImpl(function);
900+
}
901+
894902
@Override
895903
public long transactionId(KernelTransactionHandle kernelTransactionHandle) {
896904
return kernelTransactionHandle.getTransactionSequenceNumber();

cypher/5.4/storage-engine-adapter/src/main/java17/org/neo4j/internal/recordstorage/InMemoryStorageReader54.java

+5-11
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,19 @@ public int propertyKeyCount() {
281281
int nodePropertyCount = graphStore
282282
.schema()
283283
.nodeSchema()
284-
.properties()
285-
.values()
286-
.stream()
287-
.mapToInt(map -> map.keySet().size())
288-
.sum();
284+
.allProperties()
285+
.size();
289286
int relPropertyCount = graphStore
290287
.schema()
291288
.relationshipSchema()
292-
.properties()
293-
.values()
294-
.stream()
295-
.mapToInt(map -> map.keySet().size())
296-
.sum();
289+
.allProperties()
290+
.size();
297291
return nodePropertyCount + relPropertyCount;
298292
}
299293

300294
@Override
301295
public int relationshipTypeCount() {
302-
return graphStore.schema().relationshipSchema().properties().keySet().size();
296+
return graphStore.schema().relationshipSchema().availableTypes().size();
303297
}
304298

305299
@Override

0 commit comments

Comments
 (0)