diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-03-23 14:01:47 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-03-23 14:30:35 +0000 |
commit | 4867cc43efc6d92e5ff9db2924cb38280ebe7037 (patch) | |
tree | 5d70de573af95f0d0e930881186f45cd7b578a01 /config-model | |
parent | 49492f5698d52b87ee0ac98cf32d991246876125 (diff) |
add unit test
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java new file mode 100644 index 00000000000..6ecd937af46 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/searchdefinition/document/HnswIndexParamsTestCase.java @@ -0,0 +1,53 @@ + + +package com.yahoo.searchdefinition.document; + +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static com.yahoo.searchdefinition.document.HnswIndexParams.DistanceMetric; + +public class HnswIndexParamsTestCase { + + @Test + public void override_from() throws Exception { + var empty = new HnswIndexParams(); + var builder = new HnswIndexParams.Builder(); + builder.setMaxLinksPerNode(7); + var one = builder.build(); + builder.setDistanceMetric("angular"); + var two = builder.build(); + builder.setNeighborsToExploreAtInsert(42); + var three = builder.build(); + builder.setMaxLinksPerNode(17); + builder.setDistanceMetric("geodegrees"); + builder.setNeighborsToExploreAtInsert(500); + var four = builder.build(); + + assertThat(empty.maxLinksPerNode(), is(16)); + assertThat(empty.distanceMetric(), is(DistanceMetric.EUCLIDEAN)); + assertThat(empty.neighborsToExploreAtInsert(), is(200)); + + assertThat(one.maxLinksPerNode(), is(7)); + assertThat(two.distanceMetric(), is(DistanceMetric.ANGULAR)); + assertThat(three.neighborsToExploreAtInsert(), is(42)); + + assertThat(four.maxLinksPerNode(), is(17)); + assertThat(four.distanceMetric(), is(DistanceMetric.GEODEGREES)); + assertThat(four.neighborsToExploreAtInsert(), is(500)); + + var five = four.overrideFrom(empty); + assertThat(five.maxLinksPerNode(), is(17)); + assertThat(five.distanceMetric(), is(DistanceMetric.GEODEGREES)); + assertThat(five.neighborsToExploreAtInsert(), is(500)); + + var six = four.overrideFrom(two); + assertThat(six.maxLinksPerNode(), is(7)); + assertThat(six.distanceMetric(), is(DistanceMetric.ANGULAR)); + assertThat(six.neighborsToExploreAtInsert(), is(500)); + } + +} |