Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bulk insert/query API #337

Open
FreddieWitherden opened this issue Nov 15, 2024 · 1 comment
Open

Add bulk insert/query API #337

FreddieWitherden opened this issue Nov 15, 2024 · 1 comment

Comments

@FreddieWitherden
Copy link
Contributor

One means of greatly reducing overhead is to add support for bulk insert and query APIs based around NumPy arrays. For example, at the moment when one creates an index the most efficient option currently available is to pass in a generator. This generator is then converted to a callback which is passed to the C API. Overall, this is quite a bit less efficient in the non-object case compared to passing a NumPy array of (N,) idxs and (N, 2*ndim) coordinates. With the latter only a single foreign function call would be required consisting of two pointers and a count.

Similar benefits could be had on the query side where one could pass an array of (N, 2*ndim) coordinates to the C API. The resulting idx's could then be returned as a pair of arrays: one of size (M,) consisting of the idx's themselves and another of size (N + 1,) consisting of displacements into this idx array (saying where each query point begins). This would again greatly reduce the amount of time spent in Python/ctypes and also simplify memory management.

From an implementation standpoint this would require some minor additions to libspatialindex but they should be relatively straightforwards (just simple loops which call the C++ routines would suffice as a first pass). The result would be a 'fast path' for when one does not need object support and is working with data already in some native array format.

@hobu
Copy link
Member

hobu commented Nov 18, 2024

From an implementation standpoint this would require some minor additions to libspatialindex but they should be relatively straightforwards

Yes, please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants