25
25
import org .junit .jupiter .params .provider .MethodSource ;
26
26
import org .junit .jupiter .params .provider .ValueSource ;
27
27
import org .neo4j .gds .Orientation ;
28
- import org .neo4j .gds .TestProgressTracker ;
28
+ import org .neo4j .gds .SimilarityAlgorithmTasks ;
29
+ import org .neo4j .gds .TestProgressTrackerHelper ;
29
30
import org .neo4j .gds .TestSupport ;
30
31
import org .neo4j .gds .api .Graph ;
31
32
import org .neo4j .gds .applications .algorithms .machinery .AlgorithmMachinery ;
32
33
import org .neo4j .gds .applications .algorithms .machinery .ProgressTrackerCreator ;
33
34
import org .neo4j .gds .applications .algorithms .machinery .RequestScopedDependencies ;
34
35
import org .neo4j .gds .applications .algorithms .similarity .SimilarityAlgorithms ;
36
+ import org .neo4j .gds .applications .algorithms .similarity .SimilarityAlgorithmsBusinessFacade ;
35
37
import org .neo4j .gds .core .concurrency .Concurrency ;
36
38
import org .neo4j .gds .core .concurrency .DefaultPool ;
37
39
import org .neo4j .gds .core .utils .logging .LoggerForProgressTrackingAdapter ;
@@ -784,16 +786,28 @@ void shouldIgnoreParallelEdges(Orientation orientation, int concurrency) {
784
786
785
787
@ Test
786
788
void shouldLogMessages () {
787
- var log = new GdsTestLog ();
788
- var requestScopedDependencies = RequestScopedDependencies .builder ()
789
- .taskRegistryFactory (EmptyTaskRegistryFactory .INSTANCE )
790
- .terminationFlag (TerminationFlag .RUNNING_TRUE )
791
- .userLogRegistryFactory (EmptyUserLogRegistryFactory .INSTANCE )
792
- .build ();
793
- var progressTrackerCreator = new ProgressTrackerCreator (new LoggerForProgressTrackingAdapter (log ), requestScopedDependencies );
794
- var similarityAlgorithms = new SimilarityAlgorithms (progressTrackerCreator , requestScopedDependencies .terminationFlag ());
795
789
796
- similarityAlgorithms .nodeSimilarity (naturalGraph , NodeSimilarityBaseConfigImpl .builder ().build ());
790
+ var params = NodeSimilarityBaseConfigImpl .builder ().build ().toParameters ();
791
+ var progressTrackerWithLog = TestProgressTrackerHelper .create (
792
+ new SimilarityAlgorithmTasks ().nodeSimilarity (naturalGraph , params ),
793
+ new Concurrency (2 )
794
+ );
795
+
796
+ var progressTracker = progressTrackerWithLog .progressTracker ();
797
+ var log = progressTrackerWithLog .log ();
798
+
799
+ var nodeSimilarity = new NodeSimilarity (
800
+ naturalGraph ,
801
+ params ,
802
+ DefaultPool .INSTANCE ,
803
+ progressTracker ,
804
+ NodeFilter .ALLOW_EVERYTHING ,
805
+ NodeFilter .ALLOW_EVERYTHING ,
806
+ TerminationFlag .RUNNING_TRUE ,
807
+ new WccStub (TerminationFlag .RUNNING_TRUE ,new AlgorithmMachinery ())
808
+ );
809
+
810
+ nodeSimilarity .compute ();
797
811
798
812
assertThat (log .getMessages (INFO ))
799
813
.extracting (removingThreadId ())
@@ -814,9 +828,11 @@ void shouldNotLogMessagesWhenLoggingIsDisabled() {
814
828
.userLogRegistryFactory (EmptyUserLogRegistryFactory .INSTANCE )
815
829
.build ();
816
830
var progressTrackerCreator = new ProgressTrackerCreator (new LoggerForProgressTrackingAdapter (log ), requestScopedDependencies );
817
- var similarityAlgorithms = new SimilarityAlgorithms (progressTrackerCreator , requestScopedDependencies .terminationFlag ());
831
+ var similarityAlgorithms = new SimilarityAlgorithms (requestScopedDependencies .terminationFlag ());
818
832
819
- similarityAlgorithms .nodeSimilarity (naturalGraph , NodeSimilarityBaseConfigImpl .builder ().logProgress (false ).build ());
833
+ var similarityBusiness = new SimilarityAlgorithmsBusinessFacade (similarityAlgorithms ,progressTrackerCreator );
834
+
835
+ similarityBusiness .nodeSimilarity (naturalGraph , NodeSimilarityBaseConfigImpl .builder ().logProgress (false ).build ());
820
836
821
837
assertThat (log .getMessages (INFO ))
822
838
.as ("When progress logging is disabled we only log `start` and `finished`." )
@@ -834,22 +850,27 @@ void shouldNotLogMessagesWhenLoggingIsDisabled() {
834
850
@ ParameterizedTest (name = "concurrency = {0}" )
835
851
@ ValueSource (ints = {1 , 2 })
836
852
void shouldLogProgress (int concurrencyValue ) {
837
- var log = new GdsTestLog ();
838
- var requestScopedDependencies = RequestScopedDependencies .builder ()
839
- .taskRegistryFactory (EmptyTaskRegistryFactory .INSTANCE )
840
- .terminationFlag (TerminationFlag .RUNNING_TRUE )
841
- .userLogRegistryFactory (EmptyUserLogRegistryFactory .INSTANCE )
842
- .build ();
843
- var similarityAlgorithms = new SimilarityAlgorithms (null , requestScopedDependencies .terminationFlag ());
844
-
845
- var configuration = NodeSimilarityStreamConfigImpl .builder ().build ();
846
- var progressTracker = new TestProgressTracker (
847
- similarityAlgorithms .constructNodeSimilarityTask (naturalGraph , configuration ),
848
- new LoggerForProgressTrackingAdapter (log ),
849
- new Concurrency (concurrencyValue ),
850
- EmptyTaskRegistryFactory .INSTANCE
853
+ var params = NodeSimilarityBaseConfigImpl .builder ().build ().toParameters ();
854
+ var progressTrackerWithLog = TestProgressTrackerHelper .create (
855
+ new SimilarityAlgorithmTasks ().nodeSimilarity (naturalGraph , params ),
856
+ new Concurrency (concurrencyValue )
851
857
);
852
- similarityAlgorithms .nodeSimilarity (naturalGraph , configuration , progressTracker ).streamResult ().count ();
858
+
859
+ var progressTracker = progressTrackerWithLog .progressTracker ();
860
+ var log = progressTrackerWithLog .log ();
861
+
862
+ var nodeSimilarity = new NodeSimilarity (
863
+ naturalGraph ,
864
+ params ,
865
+ DefaultPool .INSTANCE ,
866
+ progressTracker ,
867
+ NodeFilter .ALLOW_EVERYTHING ,
868
+ NodeFilter .ALLOW_EVERYTHING ,
869
+ TerminationFlag .RUNNING_TRUE ,
870
+ new WccStub (TerminationFlag .RUNNING_TRUE ,new AlgorithmMachinery ())
871
+ );
872
+
873
+ nodeSimilarity .compute ();
853
874
854
875
var progresses = progressTracker .getProgresses ();
855
876
@@ -869,24 +890,33 @@ void shouldLogProgress(int concurrencyValue) {
869
890
870
891
@ Test
871
892
void shouldLogProgressForWccOptimization () {
872
- var log = new GdsTestLog ();
873
- var requestScopedDependencies = RequestScopedDependencies .builder ()
874
- .taskRegistryFactory (EmptyTaskRegistryFactory .INSTANCE )
875
- .terminationFlag (TerminationFlag .RUNNING_TRUE )
876
- .userLogRegistryFactory (EmptyUserLogRegistryFactory .INSTANCE )
877
- .build ();
878
- var similarityAlgorithms = new SimilarityAlgorithms (null , requestScopedDependencies .terminationFlag ());
879
893
880
- var configuration = NodeSimilarityStreamConfigImpl .builder ()
894
+ var params = NodeSimilarityBaseConfigImpl
895
+ .builder ()
881
896
.useComponents (true )
882
- .build ();
883
- var progressTracker = new TestProgressTracker (
884
- similarityAlgorithms .constructNodeSimilarityTask (naturalGraph , configuration ),
885
- new LoggerForProgressTrackingAdapter (log ),
886
- new Concurrency (4 ),
887
- EmptyTaskRegistryFactory .INSTANCE
897
+ .build ()
898
+ .toParameters ();
899
+
900
+ var progressTrackerWithLog = TestProgressTrackerHelper .create (
901
+ new SimilarityAlgorithmTasks ().nodeSimilarity (naturalGraph , params ),
902
+ new Concurrency (4 )
903
+ );
904
+
905
+ var progressTracker = progressTrackerWithLog .progressTracker ();
906
+ var log = progressTrackerWithLog .log ();
907
+
908
+ var nodeSimilarity = new NodeSimilarity (
909
+ naturalGraph ,
910
+ params ,
911
+ DefaultPool .INSTANCE ,
912
+ progressTracker ,
913
+ NodeFilter .ALLOW_EVERYTHING ,
914
+ NodeFilter .ALLOW_EVERYTHING ,
915
+ TerminationFlag .RUNNING_TRUE ,
916
+ new WccStub (TerminationFlag .RUNNING_TRUE ,new AlgorithmMachinery ())
888
917
);
889
- similarityAlgorithms .nodeSimilarity (naturalGraph , configuration , progressTracker ).streamResult ().count ();
918
+
919
+ nodeSimilarity .compute ();
890
920
891
921
var progresses = progressTracker .getProgresses ();
892
922
0 commit comments