dynamodb-geo.js
dynamodb-geo.js copied to clipboard
Why are ranges split into multiple?
When generating the queries to dispatch to DDB, this library goes through all the cells in a covering area, and splits the low and hi range of each cell into sub-ranges based on the hash key length.
I've gone through the logic quite a few times and I can't figure why trySplit() (splitting of cell range into multiple) is needed.
Can't I just take the lowest minimum range of all the cells, and the highest maximum range of all the cells, and construct a DDB BETWEEN condition on the local secondary index?
For example, if my covering had 3 cells and I have a hashKeyLength of 3:
cell 1:
- rangeMin: 123456789
- rangeMax 123999999
cell 2:
- rangeMin: 124000000
- rangeMax 124999999
cell 3:
- rangeMin: 125000000
- rangeMax 125678912
Can't I just do BETWEEN 123456789 and 125678912?
Why do I have to trySplit() cell1s range (123456789-123999999) into 3 separate ranges?