Skip to content

Commit

Permalink
Update CoverTree to allow Jackson serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
wirefreethought committed May 19, 2021
1 parent a35c446 commit 37eee08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 113 deletions.
114 changes: 5 additions & 109 deletions pom.xml
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.zabuzard.closy</groupId>
<artifactId>closy</artifactId>
<version>1.2.1</version>
<version>1.2.1_01</version>
<packaging>jar</packaging>

<properties>
Expand All @@ -18,7 +18,7 @@
<name>Closy</name>
<description>Closy is a library that provides fast and generic solutions for nearest neighbor search (NNS)
</description>
<url>https://github.com/Zabuzard/Closy</url>
<url>https://github.com/wirefreethought/Closy</url>
<licenses>
<license>
<name>GNU General Public License v3.0</name>
Expand All @@ -34,112 +34,8 @@
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/Zabuzard/Closy.git</connection>
<developerConnection>scm:git:ssh://github.com:Zabuzard/Closy.git</developerConnection>
<url>http://github.com/Zabuzard/Closy/tree/master</url>
<connection>scm:git:git://github.com/wirefreethought/Closy.git</connection>
<developerConnection>scm:git:ssh://github.com:wirefreethought/Closy.git</developerConnection>
<url>http://github.com/wirefreethought/Closy/tree/master</url>
</scm>

<profiles>
<profile>
<id>release</id>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.keyname}</passphraseServerId>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
21 changes: 17 additions & 4 deletions src/main/java/io/github/zabuzard/closy/internal/CoverTree.java
Expand Up @@ -39,6 +39,10 @@ public final class CoverTree<E> implements NearestNeighborComputation<E> {
*/
private static final int DEFAULT_MIN_NUM_LEVELS = -500;

private CoverTree()
{
}

/**
* Utility method to create a new list instance. Can be used to exchange the
* list type used by the tree.
Expand All @@ -54,43 +58,52 @@ private static <T> List<T> createList() {
/**
* Lock used for synchronization.
*/
private final Object lock = new Object();
private transient Object lock = new Object();

/**
* The base of the tree.
*/
private final double base;
private double base;

/**
* The metric to use for determining distance between elements.
*/
private final Metric<? super E> metric;
private Metric<? super E> metric;

/**
* The current number of levels of the tree.
*/
private final int[] numLevels;
private int[] numLevels;

/**
* The current maximal level of the tree.
*/
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private int maxLevel;

/**
* The maximal minimum level of the tree.
*/
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private int maxMinLevel;

/**
* The maximal amount of levels of the tree.
*/
private int maxNumLevels = CoverTree.DEFAULT_MAX_NUM_LEVELS;

/**
* The current minimal level of the tree.
*/
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private int minLevel;

/**
* The minimum number of levels of the tree.
*/
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private int minNumLevels = CoverTree.DEFAULT_MIN_NUM_LEVELS;

/**
* The root node.
*/
Expand Down

0 comments on commit 37eee08

Please sign in to comment.