Skip to content

Commit

Permalink
Remove MutateStubConfigurationValidationDecorator.java
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisPanagiotas committed Aug 29, 2024
1 parent c0ca33b commit 0c10772
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@
@Configuration
public interface PageRankMutateConfig extends PageRankConfig, MutateNodePropertyConfig {

static PageRankMutateConfig of(CypherMapWrapper userInput) {
private static PageRankMutateConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}

return new PageRankMutateConfigImpl(userInput);
}

static PageRankMutateConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankMutateConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@
@Configuration
public interface PageRankStatsConfig extends PageRankConfig {

static PageRankStatsConfig of(CypherMapWrapper userInput) {
private static PageRankStatsConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
return new PageRankStatsConfigImpl(userInput);
}

static PageRankStatsConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankStatsConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@
@Configuration
public interface PageRankStreamConfig extends PageRankConfig {

static PageRankStreamConfig of(CypherMapWrapper userInput) {
private static PageRankStreamConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}

return new PageRankStreamConfigImpl(userInput);
}

static PageRankStreamConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankStreamConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@
@Configuration
public interface PageRankWriteConfig extends PageRankConfig, WritePropertyConfig {

static PageRankWriteConfig of(CypherMapWrapper userInput) {
private static PageRankWriteConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
return new PageRankWriteConfigImpl(userInput);
}

static PageRankWriteConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankWriteConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Function<CypherMapWrapper, AlgoBaseConfig> lookup(Algorithm algorithm) {
return switch (algorithm) {
case AllShortestPaths -> null;
case ApproximateMaximumKCut -> ApproxMaxKCutMutateConfig::of;
case ArticleRank -> PageRankMutateConfig::of;
case ArticleRank -> PageRankMutateConfig::configWithDampingFactor;
case ArticulationPoints -> ArticulationPointsMutateConfig::of;
case AStar -> ShortestPathAStarMutateConfig::of;
case BellmanFord -> AllShortestPathsBellmanFordMutateConfig::of;
Expand All @@ -94,7 +94,7 @@ public Function<CypherMapWrapper, AlgoBaseConfig> lookup(Algorithm algorithm) {
case DeltaStepping -> AllShortestPathsDeltaMutateConfig::of;
case DFS -> DfsMutateConfig::of;
case Dijkstra -> ShortestPathDijkstraMutateConfig::of;
case EigenVector -> PageRankMutateConfig::of;
case EigenVector -> PageRankMutateConfig::configWithoutDampingFactor;
case FastRP -> FastRPMutateConfig::of;
case FilteredKNN -> FilteredKnnMutateConfig::of;
case FilteredNodeSimilarity -> FilteredNodeSimilarityMutateConfig::of;
Expand All @@ -118,7 +118,7 @@ public Function<CypherMapWrapper, AlgoBaseConfig> lookup(Algorithm algorithm) {
case ModularityOptimization -> ModularityOptimizationMutateConfig::of;
case NodeSimilarity -> NodeSimilarityMutateConfig::of;
case Node2Vec -> Node2VecMutateConfig::of;
case PageRank -> PageRankMutateConfig::of;
case PageRank -> PageRankMutateConfig::configWithDampingFactor;
case RandomWalk -> null;
case ScaleProperties -> ScalePropertiesMutateConfig::of;
case SCC -> SccMutateConfig::of;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public PageRankAlgorithmFactory<PageRankMutateConfig> algorithmFactory(Execution
}
@Override
public NewConfigFunction<PageRankMutateConfig> newConfigFunction() {
return (___, config) -> {
if (config.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
return PageRankMutateConfig.of(config);
};
return (___, config) -> PageRankMutateConfig.configWithoutDampingFactor(config);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public PageRankAlgorithmFactory<PageRankStatsConfig> algorithmFactory(ExecutionC
}
@Override
public NewConfigFunction<PageRankStatsConfig> newConfigFunction() {
return (___, config) -> {
if (config.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
return PageRankStatsConfig.of(config);
};
return (___, config) -> PageRankStatsConfig.configWithoutDampingFactor(config);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public PageRankAlgorithmFactory<PageRankStreamConfig> algorithmFactory(Execution

@Override
public NewConfigFunction<PageRankStreamConfig> newConfigFunction() {
return (___, config) -> {
if (config.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
return PageRankStreamConfig.of(config);
};
return (___, config) -> PageRankStreamConfig.configWithoutDampingFactor(config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ public PageRankAlgorithmFactory<PageRankWriteConfig> algorithmFactory(ExecutionC

@Override
public NewConfigFunction<PageRankWriteConfig> newConfigFunction() {
return (___, config) -> {
if (config.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
return PageRankWriteConfig.of(config);
};
return (___, config) -> PageRankWriteConfig.configWithoutDampingFactor(config);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankMutateConfig> algorithmFactory(Execution

@Override
public NewConfigFunction<PageRankMutateConfig> newConfigFunction() {
return (___,config) -> PageRankMutateConfig.of(config);
return (___,config) -> PageRankMutateConfig.configWithDampingFactor(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.neo4j.gds.executor.ComputationResultConsumer;
import org.neo4j.gds.executor.ExecutionContext;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.procedures.algorithms.centrality.PageRankStatsResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;

import java.util.stream.Stream;

Expand All @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankStatsConfig> algorithmFactory(ExecutionC

@Override
public NewConfigFunction<PageRankStatsConfig> newConfigFunction() {
return (___,config) -> PageRankStatsConfig.of(config);
return (___,config) -> PageRankStatsConfig.configWithDampingFactor(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.neo4j.gds.executor.ComputationResultConsumer;
import org.neo4j.gds.executor.ExecutionContext;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.procedures.algorithms.centrality.CentralityStreamResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;

import java.util.stream.Stream;

Expand All @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankStreamConfig> algorithmFactory(Execution

@Override
public NewConfigFunction<PageRankStreamConfig> newConfigFunction() {
return (___,config) -> PageRankStreamConfig.of(config);
return (___,config) -> PageRankStreamConfig.configWithDampingFactor(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.neo4j.gds.executor.ComputationResultConsumer;
import org.neo4j.gds.executor.ExecutionContext;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.procedures.algorithms.centrality.PageRankWriteResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;

import java.util.stream.Stream;

Expand All @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankWriteConfig> algorithmFactory(ExecutionC

@Override
public NewConfigFunction<PageRankWriteConfig> newConfigFunction() {
return (___,config) -> PageRankWriteConfig.of(config);
return (___,config) -> PageRankWriteConfig.configWithDampingFactor(config);
}

@Override
Expand Down
Loading

0 comments on commit 0c10772

Please sign in to comment.