From 0d8d54b378bc7b65b7d69c8da6e5f2e7c94c9340 Mon Sep 17 00:00:00 2001 From: ioannispan Date: Fri, 8 Mar 2024 13:05:24 +0100 Subject: [PATCH] Minor rename --- ...deFilter.java => ExistingTargetNodeFilter.java} | 14 ++++++++++---- ...ering.java => ExistingTargetNodeFiltering.java} | 10 +++++----- .../filteredknn/TargetNodeFiltering.java | 2 +- .../filteredknn/TargetNodeFilterTest.java | 14 +++++++------- .../filteredknn/TargetNodeFilteringTest.java | 14 +++++++------- 5 files changed, 30 insertions(+), 24 deletions(-) rename algo/src/main/java/org/neo4j/gds/similarity/filteredknn/{ProvidedTargetNodeFilter.java => ExistingTargetNodeFilter.java} (91%) rename algo/src/main/java/org/neo4j/gds/similarity/filteredknn/{ProvidedTargetNodeFiltering.java => ExistingTargetNodeFiltering.java} (96%) diff --git a/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ProvidedTargetNodeFilter.java b/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ExistingTargetNodeFilter.java similarity index 91% rename from algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ProvidedTargetNodeFilter.java rename to algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ExistingTargetNodeFilter.java index 97253b0074..c53a4feb97 100644 --- a/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ProvidedTargetNodeFilter.java +++ b/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ExistingTargetNodeFilter.java @@ -42,7 +42,7 @@ * have convinced ourselves that {@link org.neo4j.gds.similarity.knn.Knn} never presents us with such cases. So this * data structure suffices. */ -public final class ProvidedTargetNodeFilter implements TargetNodeFilter { +public final class ExistingTargetNodeFilter implements TargetNodeFilter { private final TreeSet> priorityQueue; private final LongPredicate predicate; private final int bound; @@ -52,7 +52,7 @@ public final class ProvidedTargetNodeFilter implements TargetNodeFilter { /** * @param seeds Optionally seed the priority queue */ - static ProvidedTargetNodeFilter create( + static ExistingTargetNodeFilter create( LongPredicate targetNodePredicate, int bound, Optional>> seeds, @@ -62,10 +62,16 @@ static ProvidedTargetNodeFilter create( seeds.ifPresent(priorityQueue::addAll); - return new ProvidedTargetNodeFilter(priorityQueue, seeds.isPresent(), similarityCutoff, targetNodePredicate, bound); + return new ExistingTargetNodeFilter( + priorityQueue, + seeds.isPresent(), + similarityCutoff, + targetNodePredicate, + bound + ); } - ProvidedTargetNodeFilter( + ExistingTargetNodeFilter( TreeSet> priorityQueue, boolean seeded, double similarityCutoff, diff --git a/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ProvidedTargetNodeFiltering.java b/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ExistingTargetNodeFiltering.java similarity index 96% rename from algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ProvidedTargetNodeFiltering.java rename to algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ExistingTargetNodeFiltering.java index b0ff48e74f..df406e05a6 100644 --- a/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ProvidedTargetNodeFiltering.java +++ b/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/ExistingTargetNodeFiltering.java @@ -41,7 +41,7 @@ import static org.neo4j.gds.similarity.filteredknn.EmptyTargetNodeFilter.EMPTY_CONSUMER; -public final class ProvidedTargetNodeFiltering implements TargetNodeFiltering { +public final class ExistingTargetNodeFiltering implements TargetNodeFiltering { private final HugeObjectArray targetNodeFilters; private final SeedingSummary seedingSummary; @@ -50,7 +50,7 @@ public final class ProvidedTargetNodeFiltering implements TargetNodeFiltering { * @param optionalSimilarityFunction An actual similarity function if you want seeding, empty otherwise */ - static ProvidedTargetNodeFiltering create( + static ExistingTargetNodeFiltering create( NodeFilter sourceNodeFilter, long nodeCount, int k, @@ -80,7 +80,7 @@ static ProvidedTargetNodeFiltering create( nodepairAdder.add(optionalPersonalizedSeeds.get().size()); } - TargetNodeFilter targetNodeFilter = ProvidedTargetNodeFilter.create( + TargetNodeFilter targetNodeFilter = ExistingTargetNodeFilter.create( targetNodePredicate, k, optionalPersonalizedSeeds, @@ -91,7 +91,7 @@ static ProvidedTargetNodeFiltering create( }); var seededOptimally = (startingSeeds[k] == -1) && (optionalSimilarityFunction.isPresent()); //if there less than `k+1` targets, we optimally find solution just by seeding. - return new ProvidedTargetNodeFiltering( + return new ExistingTargetNodeFiltering( neighbourConsumers, new SeedingSummary(nodeCountAdder.longValue(), nodepairAdder.longValue(), seededOptimally) ); @@ -162,7 +162,7 @@ private static Optional>> prepareNode( } - private ProvidedTargetNodeFiltering( + private ExistingTargetNodeFiltering( HugeObjectArray targetNodeFilters, SeedingSummary seedingSummary ) { diff --git a/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFiltering.java b/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFiltering.java index b3e6bb43ed..38ceb99d9a 100644 --- a/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFiltering.java +++ b/algo/src/main/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFiltering.java @@ -54,7 +54,7 @@ static TargetNodeFiltering create( if (targetNodePredicate == NodeFilter.ALLOW_EVERYTHING) { return EmptyTargetNodeFiltering.EMPTY_TARGET_FILTERING; } else { - return ProvidedTargetNodeFiltering.create( + return ExistingTargetNodeFiltering.create( sourceNodeFilter, nodeCount, k, diff --git a/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilterTest.java b/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilterTest.java index c19675c42c..d6578126e4 100644 --- a/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilterTest.java +++ b/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilterTest.java @@ -31,7 +31,7 @@ class TargetNodeFilterTest { @Test void shouldPrioritiseTargetNodes() { - var consumer = ProvidedTargetNodeFilter.create(l -> true, 3, Optional.empty(), Double.MIN_VALUE); + var consumer = ExistingTargetNodeFilter.create(l -> true, 3, Optional.empty(), Double.MIN_VALUE); consumer.offer(23, 3.14); consumer.offer(42, 1.61); @@ -46,7 +46,7 @@ void shouldPrioritiseTargetNodes() { @Test void shouldOnlyKeepTopK() { - var consumer = ProvidedTargetNodeFilter.create(l -> true, 2, Optional.empty(), Double.MIN_VALUE); + var consumer = ExistingTargetNodeFilter.create(l -> true, 2, Optional.empty(), Double.MIN_VALUE); consumer.offer(23, 3.14); consumer.offer(42, 1.61); @@ -60,7 +60,7 @@ void shouldOnlyKeepTopK() { @Test void shouldOnlyIncludeTargetNodes() { - var consumer = ProvidedTargetNodeFilter.create(l -> false, 3, Optional.empty(), Double.MIN_VALUE); + var consumer = ExistingTargetNodeFilter.create(l -> false, 3, Optional.empty(), Double.MIN_VALUE); consumer.offer(23, 3.14); consumer.offer(42, 1.61); @@ -71,7 +71,7 @@ void shouldOnlyIncludeTargetNodes() { @Test void shouldIgnoreExactDuplicates() { - var consumer = ProvidedTargetNodeFilter.create(l -> true, 4, Optional.empty(), Double.MIN_VALUE); + var consumer = ExistingTargetNodeFilter.create(l -> true, 4, Optional.empty(), Double.MIN_VALUE); consumer.offer(23, 3.14); consumer.offer(42, 1.61); @@ -90,7 +90,7 @@ void shouldIgnoreExactDuplicates() { */ @Test void shouldAllowDuplicateElementsWithNewPriorities() { - var consumer = ProvidedTargetNodeFilter.create(l -> true, 4, Optional.empty(), Double.MIN_VALUE); + var consumer = ExistingTargetNodeFilter.create(l -> true, 4, Optional.empty(), Double.MIN_VALUE); consumer.offer(23, 3.14); consumer.offer(42, 1.61); @@ -107,7 +107,7 @@ void shouldAllowDuplicateElementsWithNewPriorities() { @Test void shouldIgnoreLowScoringNodes() { - var targetNodeFilter = ProvidedTargetNodeFilter.create(l -> true, 3, Optional.empty(), 2); + var targetNodeFilter = ExistingTargetNodeFilter.create(l -> true, 3, Optional.empty(), 2); targetNodeFilter.offer(23, 3.14); targetNodeFilter.offer(42, 1.61); @@ -128,7 +128,7 @@ void shouldNotIgnoreLowScoringNodesWhenSeeded() { Pair.of(0.003, 384L) ); - var targetNodeFilter = ProvidedTargetNodeFilter.create(l -> true, 3, Optional.of(seeds), 2); + var targetNodeFilter = ExistingTargetNodeFilter.create(l -> true, 3, Optional.of(seeds), 2); targetNodeFilter.offer(23, 3.14); targetNodeFilter.offer(42, 1.61); diff --git a/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilteringTest.java b/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilteringTest.java index c3e3672c1c..dfe39cb1bf 100644 --- a/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilteringTest.java +++ b/algo/src/test/java/org/neo4j/gds/similarity/filteredknn/TargetNodeFilteringTest.java @@ -37,7 +37,7 @@ void shouldFilterTargetNodes() { int kIsTwo = 2; LongPredicate evenNodesAreTargetNodes = l -> l % 2 == 0; double noSimilarityCutoff = Double.MIN_VALUE; - ProvidedTargetNodeFiltering targetNodeFiltering = ProvidedTargetNodeFiltering.create( + ExistingTargetNodeFiltering targetNodeFiltering = ExistingTargetNodeFiltering.create( NodeFilter.ALLOW_EVERYTHING, thereIsSixNodeInThisFilter, kIsTwo, @@ -74,7 +74,7 @@ public double computeSimilarity(long n, long m) { } }); double noSimilarityCutoff = Double.MIN_VALUE; - ProvidedTargetNodeFiltering targetNodeFiltering = ProvidedTargetNodeFiltering.create( + ExistingTargetNodeFiltering targetNodeFiltering = ExistingTargetNodeFiltering.create( NodeFilter.ALLOW_EVERYTHING, thereIsSixNodeInThisFilter, kIsFive, @@ -113,7 +113,7 @@ public double computeSimilarity(long n, long m) { } }); double noSimilarityCutoff = Double.MIN_VALUE; - ProvidedTargetNodeFiltering targetNodeFiltering = ProvidedTargetNodeFiltering.create( + ExistingTargetNodeFiltering targetNodeFiltering = ExistingTargetNodeFiltering.create( NodeFilter.ALLOW_EVERYTHING, thereIsSixNodeInThisFilter, kIsFive, @@ -135,7 +135,7 @@ void shouldRestrictToSourceFilteredNodes() { int kIsTwo = 2; LongPredicate evenNodesAreTargetNodes = l -> l % 2 == 0; double noSimilarityCutoff = Double.MIN_VALUE; - ProvidedTargetNodeFiltering targetNodeFiltering = ProvidedTargetNodeFiltering.create( + ExistingTargetNodeFiltering targetNodeFiltering = ExistingTargetNodeFiltering.create( l -> l > 0, thereIsSixNodeInThisFilter, kIsTwo, @@ -148,7 +148,7 @@ void shouldRestrictToSourceFilteredNodes() { var targetNodeFilterZero = targetNodeFiltering.get(0); var targetNodeFilterOne = targetNodeFiltering.get(1); assertThat(targetNodeFilterZero).isInstanceOf(EmptyTargetNodeFilter.class); - assertThat(targetNodeFilterOne).isInstanceOf(ProvidedTargetNodeFilter.class); + assertThat(targetNodeFilterOne).isInstanceOf(ExistingTargetNodeFilter.class); } @@ -166,7 +166,7 @@ public double computeSimilarity(long n, long m) { } }); - ProvidedTargetNodeFiltering targetNodeFiltering = ProvidedTargetNodeFiltering.create( + ExistingTargetNodeFiltering targetNodeFiltering = ExistingTargetNodeFiltering.create( NodeFilter.ALLOW_EVERYTHING, gazillionNodes, gazillionK, @@ -194,7 +194,7 @@ public double computeSimilarity(long n, long m) { } }); - ProvidedTargetNodeFiltering targetNodeFiltering = ProvidedTargetNodeFiltering.create( + ExistingTargetNodeFiltering targetNodeFiltering = ExistingTargetNodeFiltering.create( NodeFilter.ALLOW_EVERYTHING, gazillionNodes, gazillionK,