Skip to content

Commit

Permalink
Do it different in different database versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaderberg committed Dec 18, 2023
1 parent 9c7d6eb commit d401f4c
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@
import org.neo4j.kernel.api.KernelTransactionHandle;
import org.neo4j.kernel.api.procedure.CallableProcedure;
import org.neo4j.kernel.api.procedure.CallableUserAggregationFunction;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.database.NormalizedDatabaseName;
import org.neo4j.kernel.impl.coreapi.InternalTransaction;
import org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl;
Expand Down Expand Up @@ -807,15 +805,6 @@ public TransactionalContext newQueryContext(
return contextFactory.newContext(tx, queryText, queryParameters, QueryExecutionConfiguration.DEFAULT_CONFIG);
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}

public abstract CursorContextFactory cursorContextFactory(Optional<PageCacheTracer> pageCacheTracer);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
Expand All @@ -40,6 +41,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -178,4 +181,13 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
Expand All @@ -40,6 +41,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -178,4 +181,13 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
Expand All @@ -40,6 +41,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -178,4 +181,13 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.gds.compat._5x.CompatAccessModeImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.TokenSet;
Expand All @@ -44,6 +45,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -197,4 +200,13 @@ public boolean allowsReadNodeProperty(
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.gds.compat._5x.CompatAccessModeImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.TokenSet;
Expand All @@ -44,6 +45,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -197,4 +200,13 @@ public boolean allowsReadNodeProperty(
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.gds.compat._5x.CompatAccessModeImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.TokenSet;
Expand All @@ -44,6 +45,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReferenceImpl;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -202,4 +205,13 @@ public boolean allowsReadNodeProperty(
public String metricsManagerClass() {
return "com.neo4j.metrics.MetricsManager";
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReferenceImpl.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
package org.neo4j.gds.compat._56;

import org.neo4j.common.DependencyResolver;
import org.neo4j.fabric.FabricDatabaseManager;
import org.neo4j.gds.compat.BoltTransactionRunner;
import org.neo4j.gds.compat.CompatExecutionContext;
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat.StoreScan;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.NodeCursor;
import org.neo4j.internal.kernel.api.NodeLabelIndexCursor;
Expand Down Expand Up @@ -227,4 +229,10 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseManager = GraphDatabaseApiProxy.resolveDependency(databaseService, FabricDatabaseManager.class);
return databaseManager.isFabricDatabase(GraphDatabaseApiProxy.databaseId(databaseService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
package org.neo4j.gds.compat._57;

import org.neo4j.common.DependencyResolver;
import org.neo4j.fabric.FabricDatabaseManager;
import org.neo4j.gds.compat.BoltTransactionRunner;
import org.neo4j.gds.compat.CompatExecutionContext;
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat.StoreScan;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.NodeCursor;
import org.neo4j.internal.kernel.api.NodeLabelIndexCursor;
Expand Down Expand Up @@ -232,4 +234,10 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseManager = GraphDatabaseApiProxy.resolveDependency(databaseService, FabricDatabaseManager.class);
return databaseManager.isFabricDatabase(GraphDatabaseApiProxy.databaseId(databaseService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
package org.neo4j.gds.compat._58;

import org.neo4j.common.DependencyResolver;
import org.neo4j.fabric.FabricDatabaseManager;
import org.neo4j.gds.compat.BoltTransactionRunner;
import org.neo4j.gds.compat.CompatExecutionContext;
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
Expand Down Expand Up @@ -177,4 +179,10 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseManager = GraphDatabaseApiProxy.resolveDependency(databaseService, FabricDatabaseManager.class);
return databaseManager.isFabricDatabase(GraphDatabaseApiProxy.databaseId(databaseService));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.neo4j.gds.compat.GlobalProcedureRegistry;
import org.neo4j.gds.compat.GraphDatabaseApiProxy;
import org.neo4j.gds.compat._5x.CommonNeo4jProxyImpl;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.internal.kernel.api.Cursor;
import org.neo4j.internal.kernel.api.PartitionedScan;
import org.neo4j.internal.kernel.api.exceptions.ProcedureException;
Expand All @@ -40,6 +41,8 @@
import org.neo4j.kernel.api.KernelTransaction;
import org.neo4j.kernel.api.procedure.Context;
import org.neo4j.kernel.api.procedure.GlobalProcedures;
import org.neo4j.kernel.database.DatabaseReference;
import org.neo4j.kernel.database.DatabaseReferenceRepository;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.procedure.Mode;
Expand Down Expand Up @@ -177,4 +180,13 @@ public void close() {
}
};
}

@Override
public boolean isCompositeDatabase(GraphDatabaseService databaseService) {
var databaseId = GraphDatabaseApiProxy.databaseId(databaseService);
var repo = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseReferenceRepository.class);
return repo.getCompositeDatabaseReferences().stream()
.map(DatabaseReference.Internal::databaseId)
.anyMatch(databaseId::equals);
}
}

0 comments on commit d401f4c

Please sign in to comment.