Last active
August 29, 2015 13:57
-
-
Save blangel/9758633 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The GeoQueryRequest will contain the inputted QueryRequest (decorated with geo-hash/etc) | |
| // as well as a QueryResultGeoFilter to post process the results | |
| GeoQueryRequst geoQueryRequest = geo.radiusQuery(QueryRequest request, double latitude, double longitude, double radius, Config config); | |
| QueryRequest queryRequest = geoQueryRequest.queryRequest; | |
| // clients will use GeoQueryRequest in a manner similar to the following | |
| List<Map<String, AttributeValue>> resultItems = new ArrayList<Map<String, AttributeValue>>((limit < 1000 ? limit : 1000)); | |
| do { | |
| try { | |
| queryResult = ddb.query(queryRequest); | |
| } catch (ResourceNotFoundException rnfe) { | |
| // queryRequest not found, simply break | |
| break; | |
| } | |
| List<Map<String, AttributeValue>> items = queryResult.getItems(); | |
| // filter the results using the geo filter | |
| List<Map<String, AttributeValue>> filteredItems = geoQueryRequest.queryResultGeoFilter.filter(items); | |
| resultItems.addAll(filteredItems); | |
| queryRequest = queryRequest.withExclusiveStartKey(queryResult.getLastEvaluatedKey()); | |
| } while ((queryResult.getLastEvaluatedKey() != null) && (resultItems.size() < limit)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment