demo application for modular-spatial-index
Go to file
forest 874028fcb5 add benchmarks to readme 2021-06-29 17:36:10 -05:00
benchmark add benchmarks to readme 2021-06-29 17:36:10 -05:00
LICENSE.md MIT license 2021-06-20 11:23:52 -05:00
README.md add benchmarks to readme 2021-06-29 17:36:10 -05:00
benchmarks.jpg add benchmarks to readme 2021-06-29 17:36:10 -05:00
go.mod update to newer version of library 2021-06-29 16:59:08 -05:00
go.sum update to newer version of library 2021-06-29 16:59:08 -05:00
main.go update to newer version of library 2021-06-29 16:59:08 -05:00
opengl_boilerplate.go create demo repository 2021-06-20 11:01:19 -05:00

README.md

modular-spatial-index-demo-opengl

animated gif showing query zone and selected curve area

This demo was based on Golang OpenGL tutorial by kylewbanks.com.

modular-spatial-index

modular-spatial-index is a simple spatial index adapter for key/value databases like leveldb and Cassandra (or RDBMS like SQLite/Postgres if you want), based on https://github.com/google/hilbert.

It's called "modular" because it doesn't have any indexing logic inside, you bring your own index. It simply defines a mapping from two-dimensional space ([x,y] as integers) to 1-dimensional space (a single string of bytes for a point, or a handful of byte-ranges for a rectangle). You can use these strings of bytes (keys) and byte-ranges (query parameters) in any database to implement a spatial index.

Read amplification for range queries is ~2x-3x in terms of IOPS and bandwidth compared to a 1-dimensional query.

But that constant factor on top of your fast key/value database is a low price to pay for a whole new dimension, right? It's certainly better than the naive approach.

See https://sequentialread.com/building-a-spatial-index-supporting-range-query-using-space-filling-hilbert-curve for more information.

Benchmarks

The benchmarks are part of this repository.

I benchmarked the spatial index against a tuned version of the "One range query for every row in the rectangle" approach I talk about in my blog post linked above, which I am calling the Sliced index, with various slice sizes.

For a test dataset, I used goleveldb to store approximately 1 million keys, each with a 4-kilobyte random value. During the benchmarks, each database index was approximately 3.5GB in size, and the test application was consuming about 30MB of memory.

MIT license