-
Notifications
You must be signed in to change notification settings - Fork 1
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
Request only nearby and recent business records #35
Comments
This means we have to able to query business records by geolocation. |
S2 Geometry Library looks great. |
Since the search region depends on the visible area (zoom level) on the map, I think a single geohash is not sufficient for our purpose. Ideally, every business record should be indexed by individual zoom levels. |
According to the DynamoDB quota, DynamoDB can have at most 20 global secondary indexes per table. Not all of the zoom levels supported by Mapbox (0 to 22) fit in this limitation. |
We have to determine some typical zoom levels. |
I use zoom levels 17 and 18 with my mobile phone during I walk my dog. |
Zoom levels to index,
Above indexing is enough for dog walking. Further indexing is necessary for browsing. Unfortunately I have no clue about it.
Indexing the level 0 is not necessary because it is equivalent to scanning every record. |
7 global secondary indexes should not harm, but consume more WCUs and RCUs. |
To work around the limitation of the number of global secondary indexes, we could store an additional item per zoom level in the table, that associates a business record with its map tile coordinates at a specific zoom level.
Since this method needs more |
I prefer global secondary index as long as the quota does not matter. |
To query business records of a specific dog at a zoom level
|
There are two different sets of requirements for a primary key combination, one for a specific dog (private view), and the other for all dogs (public view; i.e., #38). |
One solution is to create 7 more similar indexes for the public view. This consumes precious indexes. |
Another solution is to create separate items for public and private views. The two views share indexes but have different prefixes. Private item,
Public item,
|
By the way, isn't it a bad idea to have a huge partition in DynamoDB? The map tile indexing I proposed here will create a huge partition especially for lower zoom levels. |
When I googled about the problems having a huge partition in DynamoDB, I found a scary article said the partition size is up to 10GB! But according to the documentation, this limit is applied only to a table with one or more local secondary indexes. So this should not matter to the business record table. |
A huge partition may be more susceptible to the capacity cap per partition (3,000 RCUs and 1,000 WCUs). It should not matter for our app so far. |
I found that CloudFormation cannot create or delete more than one global secondary index in a single update. This is painful. |
We have to provision global secondary indexes (GSIs) one by one. I hope I am not stupid enough to edit the CDK stack every time I provision a single GSI. May we use a context value to control which GSI is going to be provisioned? |
How do we get map tiles visible on the screen? We can listen for "sourcedata" event to know which map tile is requested, but no event is notified after the map tile is cached. |
My concern is that once business records in a map tile are queried at a "sourcedata" event, they will not be re-queried unless mapbox cache is cleared. But this should not matter unless you want to monitor business records of your dog friend updated by other than you. Because updates made by you are immediately recorded on memory. |
We have to invent our own caching feature though, use "sourcedata" events for now. |
Because not all of zoom levels are indexed, use the following algorithm to cover a queried map tile at (
|
One problem of depending on a "sourcedata" event is that the maximum zoom level is capped by that of the event (tile) source. It is 16 in the case of the style |
A global business explorer (#38) will be added as a map tile source in the future. For finer zoom levels, I think we can count on it. |
I realized that the zoom level zero also has to be indexed because there is no index scanning all of public records. |
Requesting all of the business records online will incur too much network traffic and AWS charge. We have to limit the request.
Basic strategy,
N
recent business recordsThe text was updated successfully, but these errors were encountered: