Code Monkey home page Code Monkey logo

tinspin-indexes's People

Contributors

bvancea avatar chris0385 avatar dependabot[bot] avatar tzaeschke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinspin-indexes's Issues

Package level of IndexConfig's counstructor doesn't allow to adjust performance

Hi, I noticed yoy wrote that section in ReadMe.md under "performance" header.
"For kD-trees, try disabling defensive copy via IndexConfig..."
But there is no way to create IndexConfig externally as constructor has a package level of visability and there is no any factory method for creating it.
Could you check it?

Improve m0/m1 computation

m0/m1 computation in the quadtree iterators could be improved by replacing

for (int d = 0; d < center.length; d++) {
	m0 <<= 1;
	m1 <<= 1;
	if (max[d] >= center[d]) {
		m1 |= 1;
		if (min[d] >= center[d]) {
			m0 |= 1;
		}
	}
}

with

for (int d = 0; d < center.length; d++) {
	m0 <<= 1;
	m1 <<= 1;
	//Extract signum bit
	m1 |= (Double.doubleToRawLongBits(center[d] - max[d]) >>> 63) & 1;
	m0 |= (Double.doubleToRawLongBits(center[d] - min[d]) >>> 63) & 1;
}

Bug in QuadTreeKD2

Hello, I believe I encountered a bug in QuadTreeKD2. It's not present in QuadTreeKD or QuadTreeKD0.

reproducer (data.txt):

package bug;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

import org.tinspin.index.qthypercube.QuadTreeKD;
import org.tinspin.index.qthypercube2.QuadTreeKD2;
import org.tinspin.index.qtplain.QuadTreeKD0;

public class HelloWorld {
  public static void main(String[] args) {
    try {
      t();
    } catch (Exception e) {
    }
  }

 public static void t() throws Exception {
    BufferedReader reader = new BufferedReader(new FileReader("data.txt"));
    int n = Integer.parseInt(reader.readLine());
    QuadTreeKD2<Integer> tree = QuadTreeKD2.create(2);
    for (int i = 0; i < n; i++) {
      String[] sp = reader.readLine().split(" ");
      double d1 = Double.parseDouble(sp[0]), d2 = Double.parseDouble(sp[1]);

      tree.insert(new double[]{d1, d2}, i);
    }
    int k = Integer.parseInt(reader.readLine());
    for (int i = 0; i < k; i++) {
      String[] sp = reader.readLine().split(" ");
      double d1 = Double.parseDouble(sp[0]), d2 = Double.parseDouble(sp[1]);

      tree.remove(new double[]{d1, d2});
    }
    {
      String[] sp = reader.readLine().split(" ");
      double d1 = Double.parseDouble(sp[0]), d2 = Double.parseDouble(sp[1]);
      var node = tree.query1nn(new double[]{d1, d2});
      boolean has = tree.contains(node.point());
      System.out.println(n);

      System.out.println(has); // Should print true, but prints false with QuadTreeKD2
    }
  }
}

CritbitKD returning wrong results

CritBitKD may rarely return wrong results of data is dense, i.e. if two data points differ exactly at a depth of 64 bit. CritBit would then store unnecessarily the first identical 64bit a infix, which would confuse the query iterator when rebuilding the keys during traversal.

See TestCritBitKD.test64_3_10000_queries.

Caused by: java.lang.ClassNotFoundException: ch.ethz.globis.phtree.PhTreeF

Using the last version (2.0.0) in a Java 20 app breaks as follows:

Exception in thread "main" java.lang.NoClassDefFoundError: ch/ethz/globis/phtree/PhTreeF
at org.tinspin.index.phtree.PHTreeP.(PHTreeP.java:34)
at org.tinspin.index.phtree.PHTreeP.create(PHTreeP.java:38)
...
Caused by: java.lang.ClassNotFoundException: ch.ethz.globis.phtree.PhTreeF
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
Caused by: java.lang.ClassNotFoundException: ch.ethz.globis.phtree.PhTreeF

at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 6 more

The dependency to tinspin is made via Gradle:

implementation 'org.tinspin:tinspin-indexes:2.0.0'

To reproduce, this simple code snippet is enough:

PHTreeP.create(2);

Adding the following dependency fixes the issue:

implementation 'ch.ethz.globis.phtree:phtree:2.8.0'

checkMatch in query iterators check too many bit

This was done because the currentDepth parameter was not always correct.
To fix:

  • Correct all implementations of checkMatch()
  • Correct all calls to checkMatch, in particular, call it with n.posDIff-1 in constructors because the bit at n.posDepth is not set.

Unbounded KNN Iterator

Can Tinspin support an indefinite nearest neighbor search, where I can iteratively query for the next nearest neighbor without a predetermined 'k' value?

Is it possible to simulate this by setting k to something like Integer.MAX_VALUE, or does Tinspin first search for and gather all points AND THEN provide an iterator on these, which would be less efficient?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.