sdbcli 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +12 -0
- data/bin/sdbcli +1 -1
- data/lib/sdbcli/sdb-client.rb +14 -2
- metadata +1 -1
data/README
CHANGED
@@ -25,6 +25,7 @@ https://bitbucket.org/winebarrel/sdbcli
|
|
25
25
|
--export=DOMAIN,FILE
|
26
26
|
--retry=NUM
|
27
27
|
--retry-interval=SECOND
|
28
|
+
--require=FILE_LIST
|
28
29
|
shell> export AWS_ACCESS_KEY_ID='...'
|
29
30
|
shell> export AWS_SECRET_ACCESS_KEY='...'
|
30
31
|
shell> export SDB_ENDPOINT='sdb.ap-northeast-1.amazonaws.com' # or SDB_REGION=ap-northeast-1
|
@@ -153,7 +154,18 @@ If '-' is specified as a file name, the input/output of data will become a stand
|
|
153
154
|
- 1994
|
154
155
|
- 1988
|
155
156
|
# 3 rows in set
|
157
|
+
|
156
158
|
ap-northeast-1> select * from employees limit 3 | hire_date.to_f.avg;
|
157
159
|
--- 1991.0
|
160
|
+
|
161
|
+
ap-northeast-1> select * from employees | select {|i| i.first_name =~ /^C/ }.map {|i| Time.parse(i.birth_date).mon }.inject({}) {|r, i| r[i] ||= 0 \; r[i] += 1\; r }.sort_by {|k,v| k };
|
162
|
+
---
|
163
|
+
- [1, 1]
|
164
|
+
- [3, 1]
|
165
|
+
- [5, 1]
|
166
|
+
- [8, 2]
|
167
|
+
- [10, 1]
|
168
|
+
- [12, 3]
|
169
|
+
# 6 rows in set
|
158
170
|
|
159
171
|
'sum' method and 'avg' method are added to Array class.
|
data/bin/sdbcli
CHANGED
data/lib/sdbcli/sdb-client.rb
CHANGED
@@ -3,6 +3,8 @@ require 'base64'
|
|
3
3
|
require 'net/https'
|
4
4
|
require 'openssl'
|
5
5
|
require 'nokogiri'
|
6
|
+
require 'stringio'
|
7
|
+
require 'zlib'
|
6
8
|
|
7
9
|
module SimpleDB
|
8
10
|
class Error < StandardError; end
|
@@ -100,13 +102,23 @@ module SimpleDB
|
|
100
102
|
doc = https.start do |w|
|
101
103
|
req = Net::HTTP::Post.new('/',
|
102
104
|
'Host' => @endpoint,
|
103
|
-
'Content-Type' => 'application/x-www-form-urlencoded'
|
105
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
106
|
+
'Accept-Encoding' => 'gzip'
|
104
107
|
)
|
105
108
|
|
106
109
|
req.set_form_data(params)
|
107
110
|
res = w.request(req)
|
111
|
+
body = nil
|
108
112
|
|
109
|
-
|
113
|
+
if res['Content-Encoding'] == 'gzip'
|
114
|
+
StringIO.open(res.body, 'rb') do |f|
|
115
|
+
body = Zlib::GzipReader.wrap(f).read
|
116
|
+
end
|
117
|
+
else
|
118
|
+
body = res.bod
|
119
|
+
end
|
120
|
+
|
121
|
+
Nokogiri::XML(body)
|
110
122
|
end
|
111
123
|
|
112
124
|
validate(doc)
|