diff --git a/CHANGELOG.md b/CHANGELOG.md index 32e42a6..ed70c1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Nothing yet +## [2.1.2] - 2023-10-31 + +### Fixed +- Fixed `create()` method for `IndexConfig` not being static [#33](https://github.com/tzaeschke/tinspin-indexes/issue/35) + ## [2.1.1] - 2023-10-14 ### Fixed @@ -146,7 +151,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added CHANGELOG - [2015-10-11] - Pushed to v1.3.3-SNAPSHOT - [2015-10-11] -[Unreleased]: https://github.com/tzaeschke/tinspin-indexes/compare/tinspin-indexes-2.1.1...HEAD +[Unreleased]: https://github.com/tzaeschke/tinspin-indexes/compare/tinspin-indexes-2.1.2...HEAD +[2.1.2]: https://github.com/tzaeschke/tinspin-indexes/compare/tinspin-indexes-2.1.1...tinspin-indexes-2.1.2 [2.1.1]: https://github.com/tzaeschke/tinspin-indexes/compare/tinspin-indexes-2.1.0...tinspin-indexes-2.1.1 [2.1.0]: https://github.com/tzaeschke/tinspin-indexes/compare/tinspin-indexes-2.0.1...tinspin-indexes-2.1.0 [2.0.1]: https://github.com/tzaeschke/tinspin-indexes/compare/tinspin-indexes-2.0.0...tinspin-indexes-2.0.1 diff --git a/src/main/java/org/tinspin/index/IndexConfig.java b/src/main/java/org/tinspin/index/IndexConfig.java index e5d9303..8265f49 100644 --- a/src/main/java/org/tinspin/index/IndexConfig.java +++ b/src/main/java/org/tinspin/index/IndexConfig.java @@ -25,7 +25,7 @@ protected IndexConfig(int dimensions) { this.dimensions = dimensions; } - public IndexConfig create(int dimensions) { + public static IndexConfig create(int dimensions) { return new IndexConfig(dimensions); } @@ -34,21 +34,23 @@ public IndexConfig create(int dimensions) { * Number of dimensions. * @param dimensions Number of dimensions of keys. */ - public void setDimensions(int dimensions) { + public IndexConfig setDimensions(int dimensions) { this.dimensions = dimensions; + return this; } /** * @param defensiveKeyCopy - * Defensive keys copying. If `false`, the kd-tree will store the passed in + * Defensive keys copying. If 'false', the kd-tree will store the passed in * double[] keys internally (this reduces required memory). - * If `true`, the keys are copied in order to avoid accidental modification. - * The latter obviously requires more memory. + * If 'true', the keys are copied in order to avoid accidental modification. + * The latter obviously requires more memory. Default is 'true'. *
* This setting works only for kd-trees.
*/
- public void setDefensiveKeyCopy(boolean defensiveKeyCopy) {
+ public IndexConfig setDefensiveKeyCopy(boolean defensiveKeyCopy) {
this.defensiveKeyCopy = defensiveKeyCopy;
+ return this;
}
diff --git a/src/test/java/org/tinspin/index/kdtree/KDTreeConfigTest.java b/src/test/java/org/tinspin/index/kdtree/KDTreeConfigTest.java
new file mode 100644
index 0000000..5425b27
--- /dev/null
+++ b/src/test/java/org/tinspin/index/kdtree/KDTreeConfigTest.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2009-2017 Tilmann Zaeschke. All rights reserved.
+ *
+ * This file is part of TinSpin.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.tinspin.index.kdtree;
+
+import org.junit.Test;
+import org.tinspin.index.IndexConfig;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
+import static org.junit.Assert.*;
+import static org.tinspin.index.Index.PointIterator;
+import static org.tinspin.index.Index.PointIteratorKnn;
+
+public class KDTreeConfigTest {
+
+ private static final int N_DUP = 4;
+ private static final int BOUND = 100;
+
+ private List