Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisPanagiotas committed Oct 2, 2023
2 parents 638edcb + 5591fc7 commit e538326
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 45 deletions.
2 changes: 2 additions & 0 deletions algo/src/main/java/org/neo4j/gds/leiden/LeidenBaseConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
import org.neo4j.gds.config.ConsecutiveIdsConfig;
import org.neo4j.gds.config.RandomSeedConfig;
import org.neo4j.gds.config.RelationshipWeightConfig;
import org.neo4j.gds.config.SeedConfig;
import org.neo4j.gds.config.ToleranceConfig;

public interface LeidenBaseConfig extends
AlgoBaseConfig,
ConsecutiveIdsConfig,
RelationshipWeightConfig,
RandomSeedConfig,
SeedConfig,
ToleranceConfig {

@Value.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import org.neo4j.gds.core.utils.TerminationFlag;
import org.neo4j.gds.core.utils.progress.TaskRegistryFactory;
import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory;
import org.neo4j.gds.core.write.NodeLabelExporterBuilder;
import org.neo4j.gds.core.write.NodePropertyExporterBuilder;
import org.neo4j.gds.core.write.RelationshipExporterBuilder;
import org.neo4j.gds.core.write.RelationshipPropertiesExporterBuilder;
import org.neo4j.gds.projection.GraphProjectNativeResult;
import org.neo4j.gds.results.MemoryEstimateResult;
import org.neo4j.gds.transaction.TransactionContext;
Expand Down Expand Up @@ -216,6 +219,7 @@ NodePropertiesWriteResult writeNodeProperties(
WriteRelationshipPropertiesResult writeRelationshipProperties(
User user,
DatabaseId databaseId,
RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder,
TerminationFlag terminationFlag,
String graphName,
String relationshipType,
Expand All @@ -226,6 +230,7 @@ WriteRelationshipPropertiesResult writeRelationshipProperties(
WriteLabelResult writeNodeLabel(
User user,
DatabaseId databaseId,
NodeLabelExporterBuilder nodeLabelExporterBuilder,
TerminationFlag terminationFlag,
String graphName,
String nodeLabel,
Expand All @@ -235,6 +240,7 @@ WriteLabelResult writeNodeLabel(
WriteRelationshipResult writeRelationships(
User user,
DatabaseId databaseId,
RelationshipExporterBuilder relationshipExporterBuilder,
TaskRegistryFactory taskRegistryFactory,
TerminationFlag terminationFlag,
UserLogRegistryFactory userLogRegistryFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
import org.neo4j.gds.core.utils.TerminationFlag;
import org.neo4j.gds.core.utils.progress.TaskRegistryFactory;
import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory;
import org.neo4j.gds.core.write.NodeLabelExporterBuilder;
import org.neo4j.gds.core.write.NodePropertyExporterBuilder;
import org.neo4j.gds.core.write.RelationshipExporterBuilder;
import org.neo4j.gds.core.write.RelationshipPropertiesExporterBuilder;
import org.neo4j.gds.graphsampling.RandomWalkBasedNodesSampler;
import org.neo4j.gds.graphsampling.config.RandomWalkWithRestartsConfig;
import org.neo4j.gds.logging.Log;
Expand Down Expand Up @@ -111,25 +114,25 @@ public DefaultCatalogBusinessFacade(
GraphNameValidationService graphNameValidationService,
GraphStoreCatalogService graphStoreCatalogService,
GraphStoreValidationService graphStoreValidationService,
DropGraphApplication dropGraphApplication,
ListGraphApplication listGraphApplication,
NativeProjectApplication nativeProjectApplication,
CypherProjectApplication cypherProjectApplication,
SubGraphProjectApplication subGraphProjectApplication,
GraphMemoryUsageApplication graphMemoryUsageApplication,
DropGraphApplication dropGraphApplication,
DropNodePropertiesApplication dropNodePropertiesApplication,
DropRelationshipsApplication dropRelationshipsApplication,
EstimateCommonNeighbourAwareRandomWalkApplication estimateCommonNeighbourAwareRandomWalkApplication,
GenerateGraphApplication generateGraphApplication,
GraphMemoryUsageApplication graphMemoryUsageApplication,
GraphSamplingApplication graphSamplingApplication,
ListGraphApplication listGraphApplication,
NativeProjectApplication nativeProjectApplication,
NodeLabelMutatorApplication nodeLabelMutatorApplication,
StreamNodePropertiesApplication streamNodePropertiesApplication,
StreamRelationshipPropertiesApplication streamRelationshipPropertiesApplication,
StreamRelationshipsApplication streamRelationshipsApplication,
SubGraphProjectApplication subGraphProjectApplication,
WriteNodePropertiesApplication writeNodePropertiesApplication,
WriteRelationshipPropertiesApplication writeRelationshipPropertiesApplication,
WriteNodeLabelApplication writeNodeLabelApplication,
WriteRelationshipsApplication writeRelationshipsApplication,
GraphSamplingApplication graphSamplingApplication,
EstimateCommonNeighbourAwareRandomWalkApplication estimateCommonNeighbourAwareRandomWalkApplication,
GenerateGraphApplication generateGraphApplication
WriteRelationshipsApplication writeRelationshipsApplication
) {
this.log = log;

Expand Down Expand Up @@ -692,6 +695,7 @@ public NodePropertiesWriteResult writeNodeProperties(
public WriteRelationshipPropertiesResult writeRelationshipProperties(
User user,
DatabaseId databaseId,
RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder,
TerminationFlag terminationFlag,
String graphNameAsString,
String relationshipType,
Expand All @@ -713,6 +717,7 @@ public WriteRelationshipPropertiesResult writeRelationshipProperties(
var configuration = catalogConfigurationService.parseWriteRelationshipPropertiesConfiguration(rawConfiguration);

return writeRelationshipPropertiesApplication.compute(
relationshipPropertiesExporterBuilder,
terminationFlag,
graphStore,
graphName,
Expand All @@ -726,6 +731,7 @@ public WriteRelationshipPropertiesResult writeRelationshipProperties(
public WriteLabelResult writeNodeLabel(
User user,
DatabaseId databaseId,
NodeLabelExporterBuilder nodeLabelExporterBuilder,
TerminationFlag terminationFlag,
String graphNameAsString,
String nodeLabel,
Expand All @@ -741,6 +747,7 @@ public WriteLabelResult writeNodeLabel(
var nodeFilter = NodeFilterParser.parseAndValidate(graphStore, configuration.nodeFilter());

return writeNodeLabelApplication.compute(
nodeLabelExporterBuilder,
terminationFlag,
graphStore,
graphName,
Expand All @@ -754,6 +761,7 @@ public WriteLabelResult writeNodeLabel(
public WriteRelationshipResult writeRelationships(
User user,
DatabaseId databaseId,
RelationshipExporterBuilder relationshipExporterBuilder,
TaskRegistryFactory taskRegistryFactory,
TerminationFlag terminationFlag,
UserLogRegistryFactory userLogRegistryFactory,
Expand All @@ -779,6 +787,7 @@ public WriteRelationshipResult writeRelationships(
);

return writeRelationshipsApplication.compute(
relationshipExporterBuilder,
taskRegistryFactory,
terminationFlag,
userLogRegistryFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@

public class WriteNodeLabelApplication {
private final Log log;
private final NodeLabelExporterBuilder nodeLabelExporterBuilder;

public WriteNodeLabelApplication(Log log, NodeLabelExporterBuilder nodeLabelExporterBuilder) {
public WriteNodeLabelApplication(Log log) {
this.log = log;
this.nodeLabelExporterBuilder = nodeLabelExporterBuilder;
}

WriteLabelResult compute(
NodeLabelExporterBuilder nodeLabelExporterBuilder,
TerminationFlag terminationFlag,
GraphStore graphStore,
GraphName graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@

public class WriteRelationshipPropertiesApplication {
private final Log log;
private final RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder;

public WriteRelationshipPropertiesApplication(
Log log,
RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder
) {
public WriteRelationshipPropertiesApplication(Log log) {
this.log = log;
this.relationshipPropertiesExporterBuilder = relationshipPropertiesExporterBuilder;
}

WriteRelationshipPropertiesResult compute(
RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder,
TerminationFlag terminationFlag,
GraphStore graphStore,
GraphName graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@

public class WriteRelationshipsApplication {
private final Log log;
private final RelationshipExporterBuilder relationshipExporterBuilder;

public WriteRelationshipsApplication(Log log, RelationshipExporterBuilder relationshipExporterBuilder) {
public WriteRelationshipsApplication(Log log) {
this.log = log;
this.relationshipExporterBuilder = relationshipExporterBuilder;
}

WriteRelationshipResult compute(
RelationshipExporterBuilder relationshipExporterBuilder,
TaskRegistryFactory taskRegistryFactory,
TerminationFlag terminationFlag,
UserLogRegistryFactory userLogRegistryFactory,
Expand Down Expand Up @@ -76,6 +75,7 @@ WriteRelationshipResult compute(
try (var ignored = ProgressTimer.start(builder::withWriteMillis)) {
try {
long relationshipsWritten = writeRelationshipType(
relationshipExporterBuilder,
terminationFlag,
progressTracker,
configuration.arrowConnectionInfo(),
Expand All @@ -96,6 +96,7 @@ WriteRelationshipResult compute(
}

private long writeRelationshipType(
RelationshipExporterBuilder relationshipExporterBuilder,
TerminationFlag terminationFlag,
ProgressTracker progressTracker,
Optional<WriteConfig.ArrowConnectionInfo> arrowConnectionInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@

import org.immutables.value.Value;

public interface ConsecutiveIdsConfig extends SeedConfig {
public interface ConsecutiveIdsConfig {
@Value.Default
default boolean consecutiveIds() {
return false;
}

@Value.Check
default void forbidSeedingAndConsecutiveIds() {
if (isIncremental() && consecutiveIds()) {
throw new IllegalArgumentException("Seeding and the `consecutiveIds` option cannot be used at the same time.");
if (this instanceof SeedConfig) {
var thisAsASeedConfig = (SeedConfig) this;
if (thisAsASeedConfig.isIncremental() && consecutiveIds()) {
throw new IllegalArgumentException(
"Seeding and the `consecutiveIds` option cannot be used at the same time.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void shouldNotFailOnValidCombinations() {


@Configuration
interface TestConsecutiveIdsConfig extends ConsecutiveIdsConfig {
interface TestConsecutiveIdsConfig extends ConsecutiveIdsConfig, SeedConfig {
static TestConsecutiveIdsConfig of(CypherMapWrapper map) {
return new TestConsecutiveIdsConfigImpl(map);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ void shouldDetermineIfGraphExists() {
null,
null,
null,
null,
null,
null,
new User("current user", false),
null,
null,
Expand Down Expand Up @@ -87,6 +90,9 @@ void shouldQueryUserLog() {
null,
null,
null,
null,
null,
null,
new User("current user", false),
null,
userLogStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
import org.neo4j.gds.core.utils.warnings.UserLogEntry;
import org.neo4j.gds.core.utils.warnings.UserLogRegistryFactory;
import org.neo4j.gds.core.utils.warnings.UserLogStore;
import org.neo4j.gds.core.write.NodeLabelExporterBuilder;
import org.neo4j.gds.core.write.NodePropertyExporterBuilder;
import org.neo4j.gds.core.write.RelationshipExporterBuilder;
import org.neo4j.gds.core.write.RelationshipPropertiesExporterBuilder;
import org.neo4j.gds.projection.GraphProjectNativeResult;
import org.neo4j.gds.results.MemoryEstimateResult;
import org.neo4j.gds.transaction.TransactionContext;
Expand Down Expand Up @@ -82,8 +85,11 @@ public class CatalogFacade {
private final DatabaseId databaseId;
private final GraphDatabaseService graphDatabaseService;
private final GraphProjectMemoryUsageService graphProjectMemoryUsageService;
private final NodeLabelExporterBuilder nodeLabelExporterBuilder;
private final NodePropertyExporterBuilder nodePropertyExporterBuilder;
private final ProcedureReturnColumns procedureReturnColumns;
private final RelationshipExporterBuilder relationshipExporterBuilder;
private final RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder;
private final TaskRegistryFactory taskRegistryFactory;
private final TerminationFlag terminationFlag;
private final TransactionContext transactionContext;
Expand All @@ -102,8 +108,11 @@ public CatalogFacade(
DatabaseId databaseId,
GraphDatabaseService graphDatabaseService,
GraphProjectMemoryUsageService graphProjectMemoryUsageService,
NodeLabelExporterBuilder nodeLabelExporterBuilder,
NodePropertyExporterBuilder nodePropertyExporterBuilder,
ProcedureReturnColumns procedureReturnColumns,
RelationshipExporterBuilder relationshipExporterBuilder,
RelationshipPropertiesExporterBuilder relationshipPropertiesExporterBuilder,
TaskRegistryFactory taskRegistryFactory,
TerminationFlag terminationFlag,
TransactionContext transactionContext,
Expand All @@ -116,8 +125,11 @@ public CatalogFacade(
this.databaseId = databaseId;
this.graphDatabaseService = graphDatabaseService;
this.graphProjectMemoryUsageService = graphProjectMemoryUsageService;
this.nodeLabelExporterBuilder = nodeLabelExporterBuilder;
this.nodePropertyExporterBuilder = nodePropertyExporterBuilder;
this.procedureReturnColumns = procedureReturnColumns;
this.relationshipExporterBuilder = relationshipExporterBuilder;
this.relationshipPropertiesExporterBuilder = relationshipPropertiesExporterBuilder;
this.taskRegistryFactory = taskRegistryFactory;
this.terminationFlag = terminationFlag;
this.transactionContext = transactionContext;
Expand Down Expand Up @@ -538,6 +550,7 @@ public Stream<WriteRelationshipPropertiesResult> writeRelationshipProperties(
var result = businessFacade.writeRelationshipProperties(
user,
databaseId,
relationshipPropertiesExporterBuilder,
terminationFlag,
graphName,
relationshipType,
Expand All @@ -556,6 +569,7 @@ public Stream<WriteLabelResult> writeNodeLabel(
var result = businessFacade.writeNodeLabel(
user,
databaseId,
nodeLabelExporterBuilder,
terminationFlag,
graphName,
nodeLabel,
Expand All @@ -574,6 +588,7 @@ public Stream<WriteRelationshipResult> writeRelationships(
var result = businessFacade.writeRelationships(
user,
databaseId,
relationshipExporterBuilder,
taskRegistryFactory,
terminationFlag,
userLogRegistryFactory,
Expand Down
Loading

0 comments on commit e538326

Please sign in to comment.