Re: Smart Table creation for 2D range query

2017-05-09 Thread Jon Haddad
Sure, I don't see why not. Ultimately this is more or less the same thing I proposed. You end up with a slightly different way of encoding a point in space into a rough geographical area. Whether you encode them as a tree structure or some prefix of a geohash is a matter of convenience. I'm

Re: Smart Table creation for 2D range query

2017-05-09 Thread Jim Ancona
Couldn't you use a bucketing strategy for the hash value, much like with time series data? That is, choose a partition key granularity that puts a reasonable number of rows in a partition, with the actual hash being the clustering key. Then ranges that within the partition key granularity could be

Re: Smart Table creation for 2D range query

2017-05-09 Thread Jon Haddad
The problem with using geohashes is that you can’t efficiently do ranges with random token distribution. So even if your scalar values are close to each other numerically they’ll likely end up on different nodes, and you end up doing a scatter gather. If the goal is to provide a scalable

Re: Smart Table creation for 2D range query

2017-05-09 Thread Jim Ancona
There are clever ways to encode coordinates into a single scalar value where points that are close on a surface are also close in value, making queries efficient. Examples are Geohash and Google's S2

Re: Smart Table creation for 2D range query

2017-05-08 Thread Jon Haddad
It gets a little tricky when you try to add in the coordinates to the clustering key if you want to do operations that are more complex. For instance, finding all the elements within a radius of point (x,y) isn’t particularly fun with Cassandra. I recommend moving that logic into the

Re: Smart Table creation for 2D range query

2017-05-08 Thread kurt greaves
Note that will not give you the desired range queries of 0 >= x <= 1 and 0 >= y <= 1. ​Something akin to Jon's solution could give you those range queries if you made the x and y components part of the clustering key. For example, a space of (1,1) could contain all x,y coordinates where x and y

Re: Smart Table creation for 2D range query

2017-05-08 Thread Anthony Grasso
Hi Lydia, Yes. This will define the *x*, *y* columns as the components of the partition key. Note that by doing this both *x* and *y* values will be required to at a minimum to perform a valid query. Alternatively, the *x* and *y* values could be combined in into a single text field as Jon has

Re: Smart Table creation for 2D range query

2017-05-07 Thread Lydia Ickler
Like this? CREATE TABLE test ( x double, y double, m1 int, ... m5 int, PRIMARY KEY ((x,y), m1, … , m5) ) > Am 05.05.2017 um 21:54 schrieb Nitan Kainth : > > Make metadata as partition key and x,y as part of partition key i.e. Primary > key. It should work > > Sent from my

Re: Smart Table creation for 2D range query

2017-05-05 Thread Jon Haddad
I think you’ll want to model your table similar to how an R-Tree [1] / Quad tree [2] works. Let’s suppose you had a 10x10 meter land area and you wanted to put stuff in there. In order to find “all the things in point x,y”, you could break your land area into a grid. A partition would

Re: Smart Table creation for 2D range query

2017-05-05 Thread Nitan Kainth
Make metadata as partition key and x,y as part of partition key i.e. Primary key. It should work Sent from my iPhone > On May 5, 2017, at 2:40 PM, Lydia wrote: > > Hi all, > > I am new to Apache Cassandra and I would like to get some advice on how to > tackle a

Smart Table creation for 2D range query

2017-05-05 Thread Lydia
Hi all, I am new to Apache Cassandra and I would like to get some advice on how to tackle a table creation / indexing in a sophisticated way. My aim is to store x- and y-coordinates, accompanied by some columns with meta information (m1, ... ,m5). There will be around 100,000,000 rows overall.