Skip to content

Commit b3b85eb

Browse files
committed
Introduce GdsDatabaseLayout as Proxy for DatabaseLayout
1 parent 8029f97 commit b3b85eb

File tree

11 files changed

+209
-45
lines changed

11 files changed

+209
-45
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.gds.compat.GdsDatabaseLayout;
23+
import org.neo4j.io.layout.DatabaseLayout;
24+
25+
import java.nio.file.Path;
26+
27+
public class GdsDatabaseLayoutImpl implements GdsDatabaseLayout {
28+
private final DatabaseLayout databaseLayout;
29+
30+
public GdsDatabaseLayoutImpl(DatabaseLayout databaseLayout) {this.databaseLayout = databaseLayout;}
31+
32+
@Override
33+
public Path databaseDirectory() {
34+
return databaseLayout.databaseDirectory();
35+
}
36+
37+
@Override
38+
public Path getTransactionLogsDirectory() {
39+
return databaseLayout.getTransactionLogsDirectory();
40+
}
41+
42+
@Override
43+
public Path metadataStore() {
44+
return databaseLayout.metadataStore();
45+
}
46+
47+
public DatabaseLayout databaseLayout() {
48+
return databaseLayout;
49+
}
50+
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.neo4j.gds.compat.CompatInput;
3737
import org.neo4j.gds.compat.CompositeNodeCursor;
3838
import org.neo4j.gds.compat.CustomAccessMode;
39+
import org.neo4j.gds.compat.GdsDatabaseLayout;
3940
import org.neo4j.gds.compat.GdsDatabaseManagementServiceBuilder;
4041
import org.neo4j.gds.compat.GdsGraphDatabaseAPI;
4142
import org.neo4j.gds.compat.InputEntityIdVisitor;
@@ -365,7 +366,7 @@ public int writeConcurrency(Configuration batchImportConfiguration) {
365366
@Override
366367
public BatchImporter instantiateBatchImporter(
367368
BatchImporterFactory factory,
368-
DatabaseLayout directoryStructure,
369+
GdsDatabaseLayout directoryStructure,
369370
FileSystemAbstraction fileSystem,
370371
PageCacheTracer pageCacheTracer,
371372
Configuration configuration,
@@ -377,8 +378,9 @@ public BatchImporter instantiateBatchImporter(
377378
JobScheduler jobScheduler,
378379
Collector badCollector
379380
) {
381+
DatabaseLayout databaseLayout = ((GdsDatabaseLayoutImpl) directoryStructure).databaseLayout();
380382
return factory.instantiate(
381-
directoryStructure,
383+
databaseLayout,
382384
fileSystem,
383385
pageCacheTracer,
384386
configuration,
@@ -642,8 +644,8 @@ public void configureRecordFormat(Config.Builder configBuilder, String recordFor
642644
}
643645

644646
@Override
645-
public DatabaseLayout databaseLayout(Config config, String databaseName) {
646-
return Neo4jLayout.of(config).databaseLayout(databaseName);
647+
public GdsDatabaseLayout databaseLayout(Config config, String databaseName) {
648+
return new GdsDatabaseLayoutImpl(Neo4jLayout.of(config).databaseLayout(databaseName));
647649
}
648650

649651
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.gds.compat.GdsDatabaseLayout;
23+
import org.neo4j.io.layout.DatabaseLayout;
24+
25+
import java.nio.file.Path;
26+
27+
public class GdsDatabaseLayoutImpl implements GdsDatabaseLayout {
28+
private final DatabaseLayout databaseLayout;
29+
30+
public GdsDatabaseLayoutImpl(DatabaseLayout databaseLayout) {this.databaseLayout = databaseLayout;}
31+
32+
@Override
33+
public Path databaseDirectory() {
34+
return databaseLayout.databaseDirectory();
35+
}
36+
37+
@Override
38+
public Path getTransactionLogsDirectory() {
39+
return databaseLayout.getTransactionLogsDirectory();
40+
}
41+
42+
@Override
43+
public Path metadataStore() {
44+
return databaseLayout.metadataStore();
45+
}
46+
47+
public DatabaseLayout databaseLayout() {
48+
return databaseLayout;
49+
}
50+
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.neo4j.gds.compat.CompatInput;
3636
import org.neo4j.gds.compat.CompositeNodeCursor;
3737
import org.neo4j.gds.compat.CustomAccessMode;
38+
import org.neo4j.gds.compat.GdsDatabaseLayout;
3839
import org.neo4j.gds.compat.GdsDatabaseManagementServiceBuilder;
3940
import org.neo4j.gds.compat.GdsGraphDatabaseAPI;
4041
import org.neo4j.gds.compat.InputEntityIdVisitor;
@@ -371,7 +372,7 @@ public int writeConcurrency(Configuration batchImportConfiguration) {
371372
@Override
372373
public BatchImporter instantiateBatchImporter(
373374
BatchImporterFactory factory,
374-
DatabaseLayout directoryStructure,
375+
GdsDatabaseLayout directoryStructure,
375376
FileSystemAbstraction fileSystem,
376377
PageCacheTracer pageCacheTracer,
377378
Configuration configuration,
@@ -383,8 +384,9 @@ public BatchImporter instantiateBatchImporter(
383384
JobScheduler jobScheduler,
384385
Collector badCollector
385386
) {
387+
DatabaseLayout databaseLayout = ((GdsDatabaseLayoutImpl) directoryStructure).databaseLayout();
386388
return factory.instantiate(
387-
directoryStructure,
389+
databaseLayout,
388390
fileSystem,
389391
pageCacheTracer,
390392
configuration,
@@ -645,8 +647,8 @@ public void configureRecordFormat(Config.Builder configBuilder, String recordFor
645647
}
646648

647649
@Override
648-
public DatabaseLayout databaseLayout(Config config, String databaseName) {
649-
return Neo4jLayout.of(config).databaseLayout(databaseName);
650+
public GdsDatabaseLayout databaseLayout(Config config, String databaseName) {
651+
return new GdsDatabaseLayoutImpl(Neo4jLayout.of(config).databaseLayout(databaseName));
650652
}
651653

652654
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.gds.compat.GdsDatabaseLayout;
23+
import org.neo4j.io.layout.DatabaseLayout;
24+
25+
import java.nio.file.Path;
26+
27+
public class GdsDatabaseLayoutImpl implements GdsDatabaseLayout {
28+
private final DatabaseLayout databaseLayout;
29+
30+
public GdsDatabaseLayoutImpl(DatabaseLayout databaseLayout) {this.databaseLayout = databaseLayout;}
31+
32+
@Override
33+
public Path databaseDirectory() {
34+
return databaseLayout.databaseDirectory();
35+
}
36+
37+
@Override
38+
public Path getTransactionLogsDirectory() {
39+
return databaseLayout.getTransactionLogsDirectory();
40+
}
41+
42+
@Override
43+
public Path metadataStore() {
44+
return databaseLayout.metadataStore();
45+
}
46+
47+
public DatabaseLayout databaseLayout() {
48+
return databaseLayout;
49+
}
50+
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.neo4j.gds.compat.CompatInput;
3939
import org.neo4j.gds.compat.CompositeNodeCursor;
4040
import org.neo4j.gds.compat.CustomAccessMode;
41+
import org.neo4j.gds.compat.GdsDatabaseLayout;
4142
import org.neo4j.gds.compat.GdsDatabaseManagementServiceBuilder;
4243
import org.neo4j.gds.compat.GdsGraphDatabaseAPI;
4344
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
@@ -462,7 +463,7 @@ public int writeConcurrency(Configuration batchImportConfiguration) {
462463
@Override
463464
public BatchImporter instantiateBatchImporter(
464465
BatchImporterFactory factory,
465-
DatabaseLayout directoryStructure,
466+
GdsDatabaseLayout directoryStructure,
466467
FileSystemAbstraction fileSystem,
467468
PageCacheTracer pageCacheTracer,
468469
Configuration configuration,
@@ -476,8 +477,10 @@ public BatchImporter instantiateBatchImporter(
476477
) {
477478
dbConfig.set(GraphDatabaseSettings.db_format, recordFormats.name());
478479

480+
DatabaseLayout databaseLayout = ((GdsDatabaseLayoutImpl) directoryStructure).databaseLayout();
481+
479482
return factory.instantiate(
480-
directoryStructure,
483+
databaseLayout,
481484
fileSystem,
482485
pageCacheTracer,
483486
configuration,
@@ -756,9 +759,10 @@ public void configureRecordFormat(Config.Builder configBuilder, String recordFor
756759
}
757760

758761
@Override
759-
public DatabaseLayout databaseLayout(Config config, String databaseName) {
762+
public GdsDatabaseLayout databaseLayout(Config config, String databaseName) {
760763
var storageEngineFactory = StorageEngineFactory.selectStorageEngine(config);
761-
return storageEngineFactory.formatSpecificDatabaseLayout(Neo4jLayout.of(config).databaseLayout(databaseName));
764+
var databaseLayout = storageEngineFactory.formatSpecificDatabaseLayout(Neo4jLayout.of(config).databaseLayout(databaseName));
765+
return new GdsDatabaseLayoutImpl(databaseLayout);
762766
}
763767

764768
@Override
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 java.nio.file.Path;
23+
24+
public interface GdsDatabaseLayout {
25+
Path databaseDirectory();
26+
Path getTransactionLogsDirectory();
27+
28+
Path metadataStore();
29+
30+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Configuration batchImporterConfig(
185185

186186
BatchImporter instantiateBatchImporter(
187187
BatchImporterFactory factory,
188-
DatabaseLayout directoryStructure,
188+
GdsDatabaseLayout directoryStructure,
189189
FileSystemAbstraction fileSystem,
190190
PageCacheTracer pageCacheTracer,
191191
Configuration configuration,
@@ -260,7 +260,7 @@ RecordFormats selectRecordFormatForStore(
260260

261261
void configureRecordFormat(Config.Builder configBuilder, String recordFormat);
262262

263-
DatabaseLayout databaseLayout(Config config, String databaseName);
263+
GdsDatabaseLayout databaseLayout(Config config, String databaseName);
264264

265265
BoltTransactionRunner<?, ?> boltTransactionRunner();
266266

compatibility/common/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static int writeConcurrency(Configuration batchImporterConfiguration) {
244244

245245
public static BatchImporter instantiateBatchImporter(
246246
BatchImporterFactory factory,
247-
DatabaseLayout directoryStructure,
247+
GdsDatabaseLayout directoryStructure,
248248
FileSystemAbstraction fileSystem,
249249
PageCacheTracer pageCacheTracer,
250250
Configuration configuration,
@@ -392,7 +392,7 @@ public static void configureRecordFormat(Config.Builder configBuilder, String re
392392
IMPL.configureRecordFormat(configBuilder, recordFormat);
393393
}
394394

395-
public static DatabaseLayout databaseLayout(Config config, String databaseName) {
395+
public static GdsDatabaseLayout databaseLayout(Config config, String databaseName) {
396396
return IMPL.databaseLayout(config, databaseName);
397397
}
398398

cypher/5.1/storage-engine-adapter/src/main/java17/org/neo4j/gds/compat/_51/InMemoryStorageEngineFactory.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
import org.neo4j.consistency.report.ConsistencySummaryStatistics;
2828
import org.neo4j.dbms.database.readonly.DatabaseReadOnlyChecker;
2929
import org.neo4j.gds.annotation.SuppressForbidden;
30-
import org.neo4j.gds.compat.Neo4jProxy;
3130
import org.neo4j.gds.storageengine.InMemoryTransactionStateVisitor;
3231
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector;
3332
import org.neo4j.internal.batchimport.AdditionalInitialIds;
3433
import org.neo4j.internal.batchimport.BatchImporter;
35-
import org.neo4j.internal.batchimport.BatchImporterFactory;
3634
import org.neo4j.internal.batchimport.Configuration;
3735
import org.neo4j.internal.batchimport.IncrementalBatchImporter;
3836
import org.neo4j.internal.batchimport.IndexImporterFactory;
@@ -67,7 +65,6 @@
6765
import org.neo4j.kernel.impl.store.StoreFactory;
6866
import org.neo4j.kernel.impl.store.StoreType;
6967
import org.neo4j.kernel.impl.store.cursor.CachedStoreCursors;
70-
import org.neo4j.kernel.impl.store.format.RecordFormatSelector;
7168
import org.neo4j.kernel.impl.transaction.log.LogTailMetadata;
7269
import org.neo4j.lock.LockService;
7370
import org.neo4j.logging.InternalLog;
@@ -240,28 +237,7 @@ public BatchImporter batchImporter(
240237
MemoryTracker memoryTracker,
241238
CursorContextFactory cursorContextFactory
242239
) {
243-
var recordFormats = RecordFormatSelector.selectForStoreOrConfigForNewDbs(
244-
config,
245-
RecordDatabaseLayout.of(config),
246-
fileSystemAbstraction,
247-
pageCache,
248-
logService.getInternalLogProvider(),
249-
cursorContextFactory
250-
);
251-
return Neo4jProxy.instantiateBatchImporter(
252-
BatchImporterFactory.withHighestPriority(),
253-
databaseLayout,
254-
fileSystemAbstraction,
255-
pageCacheTracer,
256-
configuration,
257-
logService,
258-
Neo4jProxy.invisibleExecutionMonitor(),
259-
AdditionalInitialIds.EMPTY,
260-
config,
261-
recordFormats,
262-
jobScheduler,
263-
Collector.EMPTY
264-
);
240+
throw new UnsupportedOperationException("Batch Import into GDS is not supported");
265241
}
266242

267243
@Override

0 commit comments

Comments
 (0)