Skip to content

Commit a0689e3

Browse files
Introduce memory facade
1 parent 15452c9 commit a0689e3

File tree

6 files changed

+112
-1
lines changed

6 files changed

+112
-1
lines changed

proc/misc/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ dependencies {
1111
implementation project(':procedures-facade-api')
1212
implementation project(':proc-common')
1313
implementation project(':progress-tracking')
14+
implementation project(':memory-facade')
15+
1416

1517
compileOnly openGds.jetbrains.annotations
1618

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.memory;
21+
22+
import org.neo4j.gds.procedures.operations.ProgressResult;
23+
import org.neo4j.procedure.Context;
24+
import org.neo4j.procedure.Description;
25+
import org.neo4j.procedure.Procedure;
26+
27+
import java.util.stream.Stream;
28+
29+
public class MemoryProc {
30+
private static final String DESCRIPTION = "List memory for currently running tasks or stored graphs.";
31+
32+
@Context
33+
public MemoryFacade facade;
34+
35+
@Procedure("gds.listMemory")
36+
@Description(DESCRIPTION)
37+
public Stream<ProgressResult> listMemory() {
38+
return facade.operations().listProgress(jobId);
39+
}
40+
}

procedures/integration/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ dependencies {
2727
implementation project(':legacy-cypher-projection')
2828
implementation project(':logging')
2929
implementation project(':memory-estimation')
30+
implementation project(':memory-facade')
31+
3032
implementation project(':memory-usage')
3133
implementation project(':metrics-api')
3234
implementation project(':model-catalog-api')

procedures/integration/src/main/java/org/neo4j/gds/procedures/integration/OpenGraphDataScienceExtensionBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory;
3737
import org.neo4j.gds.logging.Log;
3838
import org.neo4j.gds.mem.MemoryTracker;
39+
import org.neo4j.gds.memory.MemoryFacade;
3940
import org.neo4j.gds.metrics.Metrics;
4041
import org.neo4j.gds.procedures.ExporterBuildersProviderService;
4142
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
@@ -155,7 +156,9 @@ public static Triple<OpenGraphDataScienceExtensionBuilder, TaskRegistryFactorySe
155156

156157
var componentRegistration = new ComponentRegistration(log, globalProcedures);
157158

158-
componentRegistration.registerComponent("GDS Memory Tracker", MemoryTracker.class, __ -> memoryTracker);
159+
var memoryFacade = new MemoryFacade(memoryTracker);
160+
161+
componentRegistration.registerComponent("GDS Memory Facade", MemoryFacade.class, __ -> memoryFacade);
159162

160163
var graphDataScienceProviderFactory = new GraphDataScienceProceduresProviderFactory(
161164
log,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apply plugin: 'java-library'
2+
3+
description = 'Neo4j Graph Data Science :: Memory Procedure Facade API'
4+
5+
group = 'org.neo4j.gds'
6+
7+
dependencies {
8+
9+
implementation project(':progress-tracking')
10+
11+
}
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.memory;
21+
22+
import org.neo4j.gds.mem.MemoryTracker;
23+
import org.neo4j.gds.mem.UserEntityMemory;
24+
import org.neo4j.gds.mem.UserMemorySummary;
25+
26+
import java.util.stream.Stream;
27+
28+
public class MemoryFacade {
29+
30+
private final MemoryTracker memoryTracker;
31+
32+
public MemoryFacade(MemoryTracker memoryTracker){
33+
this.memoryTracker = memoryTracker;
34+
}
35+
36+
public Stream<UserEntityMemory> listUser(String user){
37+
return memoryTracker.listUser(user);
38+
}
39+
40+
public Stream<UserEntityMemory> listAll(){
41+
return memoryTracker.listAll();
42+
}
43+
44+
public UserMemorySummary memorySummary(String user){
45+
return memoryTracker.memorySummary(user);
46+
47+
}
48+
49+
public Stream<UserMemorySummary> memorySummary() {
50+
return memoryTracker.memorySummary();
51+
}
52+
53+
}

0 commit comments

Comments
 (0)