sdbcli 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/sdbcli +10 -12
  2. metadata +1 -1
data/bin/sdbcli CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
3
3
 
4
- Version = '1.3.1'
4
+ Version = '1.3.2'
5
5
  HISTORY_FILE = File.join((ENV['HOME'] || ENV['USERPROFILE'] || '.'), '.sdbcli_history')
6
6
  HISTSIZE = 500
7
7
  SELECT_LIMIT = 2500
@@ -26,7 +26,7 @@ $format = :yaml
26
26
  $consistent = false
27
27
  import = nil
28
28
  export = nil
29
- $import_export_retry = 3
29
+ $request_retry = 3
30
30
  $retry_interval = 3
31
31
  timeout = 60
32
32
  iteratable = false
@@ -42,7 +42,7 @@ ARGV.options do |opt|
42
42
  opt.on('' , '--import=DOMAIN,FILE') {|v| import = v.split(/\s*,\s*/, 2) + [false] }
43
43
  opt.on('' , '--import-replace=DOMAIN,FILE') {|v| import = v.split(/\s*,\s*/, 2) + [true] }
44
44
  opt.on('' , '--export=DOMAIN,FILE') {|v| export = v.split(/\s*,\s*/, 2) }
45
- opt.on('' , '--retry=NUM', Integer) {|v| $import_export_retry = v.to_i }
45
+ opt.on('' , '--retry=NUM', Integer) {|v| $request_retry = v.to_i }
46
46
  opt.on('' , '--retry-interval=SECOND', Integer) {|v| $retry_interval = v.to_i }
47
47
  opt.on('' , '--require=FILE_LIST', Array) {|v| v.each {|i| require i} }
48
48
  opt.on('' , '--iteratable') { iteratable = true }
@@ -177,20 +177,20 @@ def execute(src, show_rows = false)
177
177
  end
178
178
 
179
179
  def retry_api_call
180
- ($import_export_retry + 1).times do |i|
180
+ ($request_retry + 1).times do |i|
181
181
  begin
182
182
  yield
183
183
  break
184
184
  rescue Errno::ETIMEDOUT => e
185
- raise e if i >= $import_export_retry
185
+ raise e if i >= $request_retry
186
186
  rescue SimpleDB::Error => e
187
187
  if /\AServiceUnavailable:/ =~ e.message
188
- raise e if i >= $import_export_retry
188
+ raise e if i >= $request_retry
189
189
  else
190
190
  raise e
191
191
  end
192
192
  rescue Timeout::Error => e
193
- raise e if i >= $import_export_retry
193
+ raise e if i >= $request_retry
194
194
  end
195
195
 
196
196
  wait_sec = $retry_interval * (i + 1)
@@ -215,15 +215,14 @@ if export
215
215
  raise 'must not happen'
216
216
  end
217
217
 
218
- query = "SELECT * FROM #{export_domain} "
219
- query_expr = "WHERE itemName() IS NOT NULL ORDER BY itemName() LIMIT #{SELECT_LIMIT}"
218
+ query = "SELECT * FROM #{export_domain} LIMIT #{SELECT_LIMIT}"
220
219
  rownum = 0
221
220
 
222
221
  loop do
223
222
  items = nil
224
223
 
225
224
  retry_api_call do
226
- items = $runner.execute(query + query_expr, true, $consistent)
225
+ items = $runner.execute(query, true, $consistent)
227
226
  end
228
227
 
229
228
  break if items.empty?
@@ -243,8 +242,7 @@ if export
243
242
  raise 'must not happen'
244
243
  end
245
244
 
246
- tail_item_name = "'" + items.last[0].gsub(/'/, "''") + "'"
247
- query_expr = "WHERE itemName() > #{tail_item_name} ORDER BY itemName() LIMIT #{SELECT_LIMIT}"
245
+ query = 'NEXT'
248
246
 
249
247
  output_error("#{rownum} #{rownum > 1 ? 'rows' : 'row'} was outputted...", true)
250
248
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdbcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: