dynamodb_geo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/dynamodb_geo.rb +6 -5
- data/lib/dynamodb_geo/version.rb +1 -1
- data/lib/dynamodb_manager.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df20011ecbf64926816afdd5e4eaaa1abfa8ca5858b663e81cd690aa2385d284
|
4
|
+
data.tar.gz: 72af72a1f8de5bce17213d8cbfc452c04df1d9c6ae641e440703a54013ff887d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 330cb41e5276a0f0b67a00eb95c238297812b807332c30f2139b7090b41c9a190f8c2775dffa69f9b45904263aa94c94b5d00f5ba3d497e1481ce8bf7846a7e4
|
7
|
+
data.tar.gz: 35e9d9f59af12644d402911f1407242aa9eefdad21990bd8fd4a9a63b8f92c4d62a6a177826b086cac5bd9b01d4cdd2b143f07819efae7973c4833f9048919ea
|
data/README.md
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
## DynamoDB
|
3
3
|
This is an attempt at storing and querying geohash data in DynamoDB.
|
4
4
|
|
5
|
-
We store objects in DynamoDB, when we query, we look for a customizable number of stored items by zooming out exactly one level.
|
5
|
+
We store objects in DynamoDB, when we query, we look for a customizable number of stored items by zooming out exactly one level.
|
6
|
+
We return the objects in an attempt at the closest items first.
|
6
7
|
|
7
8
|
Items are searched as the following.
|
8
|
-
|
9
|
+
|
10
|
+
Given the lat, long we calculate a hash - assume 9x0qz. We go up one level to 9x0q and calculate all neighbouring hashes.
|
9
11
|
|
10
12
|
9x0p 9x0r 9x0x
|
11
13
|
9x0n 9x0q 9x0w => ["9x0q", "9x0r", "9x0x", "9x0w", "9x0t", "9x0m", "9x0j", "9x0n", "9x0p"]
|
data/lib/dynamodb_geo.rb
CHANGED
@@ -2,13 +2,14 @@ require 'dynamodb_manager'
|
|
2
2
|
|
3
3
|
module DynamodbGeo
|
4
4
|
class << self
|
5
|
-
def new(region:, table_name:, access_key_id: nil, secret_access_key: nil, profile_name: 'default')
|
5
|
+
def new(region:, table_name:, access_key_id: nil, secret_access_key: nil, profile_name: 'default', endpoint: nil)
|
6
6
|
DynamodbManager.new(
|
7
|
-
region:
|
8
|
-
access_key_id:
|
7
|
+
region: region,
|
8
|
+
access_key_id: access_key_id,
|
9
9
|
secret_access_key: secret_access_key,
|
10
|
-
profile_name:
|
11
|
-
table_name:
|
10
|
+
profile_name: profile_name,
|
11
|
+
table_name: table_name,
|
12
|
+
endpoint: endpoint
|
12
13
|
)
|
13
14
|
end
|
14
15
|
end
|
data/lib/dynamodb_geo/version.rb
CHANGED
data/lib/dynamodb_manager.rb
CHANGED
@@ -4,7 +4,7 @@ require 'store'
|
|
4
4
|
|
5
5
|
class DynamodbManager
|
6
6
|
attr_accessor :client, :table_name, :hash_key, :range_key, :geohash_key, :geojson, :geohash_index, :hash_key_length, :local_area_size, :max_item_return
|
7
|
-
def initialize(region:, table_name:, access_key_id: nil, secret_access_key: nil, profile_name: 'default')
|
7
|
+
def initialize(region:, table_name:, access_key_id: nil, secret_access_key: nil, profile_name: 'default', endpoint: nil)
|
8
8
|
if access_key_id.nil? && secret_access_key.nil?
|
9
9
|
access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
10
10
|
secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
@@ -23,10 +23,18 @@ class DynamodbManager
|
|
23
23
|
@local_area_size = 5
|
24
24
|
@max_item_return = 10
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
if endpoint
|
27
|
+
@client = Aws::DynamoDB::Client.new(
|
28
|
+
region: region,
|
29
|
+
credentials: credentials,
|
30
|
+
endpoint: endpoint
|
31
|
+
)
|
32
|
+
else
|
33
|
+
@client = Aws::DynamoDB::Client.new(
|
34
|
+
region: region,
|
35
|
+
credentials: credentials,
|
36
|
+
)
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
def table
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamodb_geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ahn
|
@@ -127,7 +127,7 @@ requirements: []
|
|
127
127
|
rubygems_version: 3.1.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
|
-
summary: dynamodb_geo-0.1.
|
130
|
+
summary: dynamodb_geo-0.1.1
|
131
131
|
test_files:
|
132
132
|
- spec/dynamodb_geo_spec.rb
|
133
133
|
- spec/geohash_spec.rb
|