Skip to content

Commit

Permalink
clean up stats result builder dependency direction
Browse files Browse the repository at this point in the history
  • Loading branch information
lassewesth committed Sep 30, 2024
1 parent fd375ac commit 0ef0c63
Show file tree
Hide file tree
Showing 48 changed files with 442 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class CentralityAlgorithmsStatsModeBusinessFacade {
public <RESULT> RESULT articleRank(
GraphName graphName,
ArticleRankStatsConfig configuration,
StatsResultBuilder<ArticleRankStatsConfig, PageRankResult, RESULT> resultBuilder
StatsResultBuilder<PageRankResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -79,7 +79,7 @@ public <RESULT> RESULT articleRank(
public <RESULT> RESULT articulationPoints(
GraphName graphName,
ArticulationPointsStatsConfig configuration,
StatsResultBuilder<ArticulationPointsStatsConfig, BitSet, RESULT> resultBuilder
StatsResultBuilder<BitSet, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -94,7 +94,7 @@ public <RESULT> RESULT articulationPoints(
public <RESULT> RESULT betweennessCentrality(
GraphName graphName,
BetweennessCentralityStatsConfig configuration,
StatsResultBuilder<BetweennessCentralityStatsConfig, CentralityAlgorithmResult, RESULT> resultBuilder
StatsResultBuilder<CentralityAlgorithmResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -109,7 +109,7 @@ public <RESULT> RESULT betweennessCentrality(
public <RESULT> RESULT celf(
GraphName graphName,
InfluenceMaximizationStatsConfig configuration,
StatsResultBuilder<InfluenceMaximizationStatsConfig, CELFResult, RESULT> resultBuilder
StatsResultBuilder<CELFResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -124,7 +124,7 @@ public <RESULT> RESULT celf(
public <RESULT> RESULT closenessCentrality(
GraphName graphName,
ClosenessCentralityStatsConfig configuration,
StatsResultBuilder<ClosenessCentralityStatsConfig, CentralityAlgorithmResult, RESULT> resultBuilder
StatsResultBuilder<CentralityAlgorithmResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -139,7 +139,7 @@ public <RESULT> RESULT closenessCentrality(
public <RESULT> RESULT degreeCentrality(
GraphName graphName,
DegreeCentralityStatsConfig configuration,
StatsResultBuilder<DegreeCentralityStatsConfig, CentralityAlgorithmResult, RESULT> resultBuilder
StatsResultBuilder<CentralityAlgorithmResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -154,7 +154,7 @@ public <RESULT> RESULT degreeCentrality(
public <RESULT> RESULT eigenVector(
GraphName graphName,
EigenvectorStatsConfig configuration,
StatsResultBuilder<EigenvectorStatsConfig, PageRankResult, RESULT> resultBuilder
StatsResultBuilder<PageRankResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -169,7 +169,7 @@ public <RESULT> RESULT eigenVector(
public <RESULT> RESULT harmonicCentrality(
GraphName graphName,
HarmonicCentralityStatsConfig configuration,
StatsResultBuilder<HarmonicCentralityStatsConfig, CentralityAlgorithmResult, RESULT> resultBuilder
StatsResultBuilder<CentralityAlgorithmResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -184,7 +184,7 @@ public <RESULT> RESULT harmonicCentrality(
public <RESULT> RESULT pageRank(
GraphName graphName,
PageRankStatsConfig configuration,
StatsResultBuilder<PageRankStatsConfig, PageRankResult, RESULT> resultBuilder
StatsResultBuilder<PageRankResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class CommunityAlgorithmsStatsModeBusinessFacade {
public <RESULT> RESULT k1Coloring(
GraphName graphName,
K1ColoringStatsConfig configuration,
StatsResultBuilder<K1ColoringStatsConfig, K1ColoringResult, RESULT> resultBuilder
StatsResultBuilder<K1ColoringResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -93,7 +93,7 @@ public <RESULT> RESULT k1Coloring(
public <RESULT> RESULT kCore(
GraphName graphName,
KCoreDecompositionStatsConfig configuration,
StatsResultBuilder<KCoreDecompositionStatsConfig, KCoreDecompositionResult, RESULT> resultBuilder
StatsResultBuilder<KCoreDecompositionResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -108,7 +108,7 @@ public <RESULT> RESULT kCore(
public <RESULT> RESULT kMeans(
GraphName graphName,
KmeansStatsConfig configuration,
StatsResultBuilder<KmeansStatsConfig, KmeansResult, RESULT> resultBuilder
StatsResultBuilder<KmeansResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -123,7 +123,7 @@ public <RESULT> RESULT kMeans(
public <RESULT> RESULT labelPropagation(
GraphName graphName,
LabelPropagationStatsConfig configuration,
StatsResultBuilder<LabelPropagationStatsConfig, LabelPropagationResult, RESULT> resultBuilder
StatsResultBuilder<LabelPropagationResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -138,7 +138,7 @@ public <RESULT> RESULT labelPropagation(
public <RESULT> RESULT lcc(
GraphName graphName,
LocalClusteringCoefficientStatsConfig configuration,
StatsResultBuilder<LocalClusteringCoefficientStatsConfig, LocalClusteringCoefficientResult, RESULT> resultBuilder
StatsResultBuilder<LocalClusteringCoefficientResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -153,7 +153,7 @@ public <RESULT> RESULT lcc(
public <RESULT> RESULT leiden(
GraphName graphName,
LeidenStatsConfig configuration,
StatsResultBuilder<LeidenStatsConfig, LeidenResult, RESULT> resultBuilder
StatsResultBuilder<LeidenResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -168,7 +168,7 @@ public <RESULT> RESULT leiden(
public <RESULT> RESULT louvain(
GraphName graphName,
LouvainStatsConfig configuration,
StatsResultBuilder<LouvainStatsConfig, LouvainResult, RESULT> resultBuilder
StatsResultBuilder<LouvainResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -183,7 +183,7 @@ public <RESULT> RESULT louvain(
public <RESULT> RESULT modularity(
GraphName graphName,
ModularityStatsConfig configuration,
StatsResultBuilder<ModularityStatsConfig, ModularityResult, RESULT> resultBuilder
StatsResultBuilder<ModularityResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -198,7 +198,7 @@ public <RESULT> RESULT modularity(
public <RESULT> RESULT modularityOptimization(
GraphName graphName,
ModularityOptimizationStatsConfig configuration,
StatsResultBuilder<ModularityOptimizationStatsConfig, ModularityOptimizationResult, RESULT> resultBuilder
StatsResultBuilder<ModularityOptimizationResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -213,7 +213,7 @@ public <RESULT> RESULT modularityOptimization(
public <RESULT> RESULT scc(
GraphName graphName,
SccStatsConfig configuration,
StatsResultBuilder<SccStatsConfig, HugeLongArray, RESULT> resultBuilder
StatsResultBuilder<HugeLongArray, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -228,7 +228,7 @@ public <RESULT> RESULT scc(
public <RESULT> RESULT triangleCount(
GraphName graphName,
TriangleCountStatsConfig configuration,
StatsResultBuilder<TriangleCountStatsConfig, TriangleCountResult, RESULT> resultBuilder
StatsResultBuilder<TriangleCountResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -243,7 +243,7 @@ public <RESULT> RESULT triangleCount(
public <RESULT> RESULT wcc(
GraphName graphName,
WccStatsConfig configuration,
StatsResultBuilder<WccStatsConfig, DisjointSetStruct, RESULT> resultBuilder
StatsResultBuilder<DisjointSetStruct, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ RESULT_TO_CALLER processAlgorithmForStats(
Label label,
Supplier<MemoryEstimation> estimationFactory,
Computation<RESULT_FROM_ALGORITHM> computation,
StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
StatsResultBuilder<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public <CONFIGURATION extends AlgoBaseConfig, RESULT_TO_CALLER, RESULT_FROM_ALGO
Label label,
Supplier<MemoryEstimation> estimationFactory,
Computation<RESULT_FROM_ALGORITHM> computation,
StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
StatsResultBuilder<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
) {
return algorithmProcessingTemplate.processAlgorithmForStats(
Optional.empty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public <CONFIGURATION extends AlgoBaseConfig, RESULT_TO_CALLER, RESULT_FROM_ALGO
Label label,
Supplier<MemoryEstimation> estimationSupplier,
Computation<RESULT_FROM_ALGORITHM> computation,
StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
StatsResultBuilder<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
) {
var resultRenderer = new StatsResultRenderer<>(configuration, resultBuilder);
var resultRenderer = new StatsResultRenderer<>(resultBuilder);

return processAlgorithmAndAnySideEffects(
relationshipWeightOverride,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

import java.util.Optional;


public interface StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> {
public interface StatsResultBuilder<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> {
/**
* You implement this and use as much or as little of the gathered data as is appropriate.
* Plus your own injected dependencies of course.
Expand All @@ -33,7 +32,6 @@ public interface StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT
*/
RESULT_TO_CALLER build(
Graph graph,
CONFIGURATION configuration,
Optional<RESULT_FROM_ALGORITHM> result,
AlgorithmProcessingTimings timings
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@
*/
package org.neo4j.gds.applications.algorithms.machinery;

import org.neo4j.gds.config.AlgoBaseConfig;
import org.neo4j.gds.core.loading.GraphResources;

import java.util.Optional;

class StatsResultRenderer<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER, CONFIGURATION extends AlgoBaseConfig> implements ResultRenderer<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER, Void> {
private final CONFIGURATION configuration;
private final StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder;
class StatsResultRenderer<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> implements ResultRenderer<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER, Void> {
private final StatsResultBuilder<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> statsResultBuilder;

StatsResultRenderer(
CONFIGURATION configuration,
StatsResultBuilder<CONFIGURATION, RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> resultBuilder
) {
this.configuration = configuration;
this.resultBuilder = resultBuilder;
StatsResultRenderer(StatsResultBuilder<RESULT_FROM_ALGORITHM, RESULT_TO_CALLER> statsResultBuilder) {
this.statsResultBuilder = statsResultBuilder;
}

@Override
Expand All @@ -43,9 +37,8 @@ public RESULT_TO_CALLER render(
AlgorithmProcessingTimings timings,
Optional<Void> unused
) {
return resultBuilder.build(
return statsResultBuilder.build(
graphResources.graph(),
configuration,
result,
timings
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MiscellaneousApplicationsStatsModeBusinessFacade {
public <RESULT> RESULT scaleProperties(
GraphName graphName,
ScalePropertiesStatsConfig configuration,
StatsResultBuilder<ScalePropertiesStatsConfig, ScalePropertiesResult, RESULT> resultBuilder
StatsResultBuilder<ScalePropertiesResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class NodeEmbeddingAlgorithmsStatsModeBusinessFacade {
public <RESULT> RESULT fastRP(
GraphName graphName,
FastRPStatsConfig configuration,
StatsResultBuilder<FastRPStatsConfig, FastRPResult, RESULT> resultBuilder
StatsResultBuilder<FastRPResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class PathFindingAlgorithmsStatsModeBusinessFacade {
public <RESULT> RESULT bellmanFord(
GraphName graphName,
AllShortestPathsBellmanFordStatsConfig configuration,
StatsResultBuilder<AllShortestPathsBellmanFordStatsConfig, BellmanFordResult, RESULT> resultBuilder
StatsResultBuilder<BellmanFordResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -77,7 +77,7 @@ public <RESULT> RESULT bellmanFord(
public <RESULT> RESULT breadthFirstSearch(
GraphName graphName,
BfsStatsConfig configuration,
StatsResultBuilder<BfsStatsConfig, HugeLongArray, RESULT> resultBuilder
StatsResultBuilder<HugeLongArray, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -92,7 +92,7 @@ public <RESULT> RESULT breadthFirstSearch(
public <RESULT> RESULT deltaStepping(
GraphName graphName,
AllShortestPathsDeltaStatsConfig configuration,
StatsResultBuilder<AllShortestPathsDeltaStatsConfig, PathFindingResult, RESULT> resultBuilder
StatsResultBuilder<PathFindingResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -107,7 +107,7 @@ public <RESULT> RESULT deltaStepping(
public <RESULT> RESULT randomWalk(
GraphName graphName,
RandomWalkStatsConfig configuration,
StatsResultBuilder<RandomWalkStatsConfig, Stream<long[]>, RESULT> resultBuilder
StatsResultBuilder<Stream<long[]>, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -122,7 +122,7 @@ public <RESULT> RESULT randomWalk(
public <RESULT> RESULT spanningTree(
GraphName graphName,
SpanningTreeStatsConfig configuration,
StatsResultBuilder<SpanningTreeStatsConfig, SpanningTree, RESULT> resultBuilder
StatsResultBuilder<SpanningTree, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -137,7 +137,7 @@ public <RESULT> RESULT spanningTree(
public <RESULT> RESULT steinerTree(
GraphName graphName,
SteinerTreeStatsConfig configuration,
StatsResultBuilder<SteinerTreeStatsConfig, SteinerTreeResult, RESULT> resultBuilder
StatsResultBuilder<SteinerTreeResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class SimilarityAlgorithmsStatsModeBusinessFacade {
public <RESULT> RESULT filteredKnn(
GraphName graphName,
FilteredKnnStatsConfig configuration,
StatsResultBuilder<FilteredKnnStatsConfig, FilteredKnnResult, RESULT> resultBuilder
StatsResultBuilder<FilteredKnnResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -68,7 +68,7 @@ public <RESULT> RESULT filteredKnn(
public <RESULT> RESULT filteredNodeSimilarity(
GraphName graphName,
FilteredNodeSimilarityStatsConfig configuration,
StatsResultBuilder<FilteredNodeSimilarityStatsConfig, NodeSimilarityResult, RESULT> resultBuilder
StatsResultBuilder<NodeSimilarityResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -83,7 +83,7 @@ public <RESULT> RESULT filteredNodeSimilarity(
public <RESULT> RESULT knn(
GraphName graphName,
KnnStatsConfig configuration,
StatsResultBuilder<KnnStatsConfig, KnnResult, RESULT> resultBuilder
StatsResultBuilder<KnnResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand All @@ -98,7 +98,7 @@ public <RESULT> RESULT knn(
public <RESULT> RESULT nodeSimilarity(
GraphName graphName,
NodeSimilarityStatsConfig configuration,
StatsResultBuilder<NodeSimilarityStatsConfig, NodeSimilarityResult, RESULT> resultBuilder
StatsResultBuilder<NodeSimilarityResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
Expand Down
Loading

0 comments on commit 0ef0c63

Please sign in to comment.