td 0.10.64 → 0.10.65

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,12 @@
1
+ == 2012-12-27 version 0.10.65
2
+
3
+ * td-client v0.8.40
4
+ * Use Yajl.dump instead of to_json to avoid invalid encoding problem.
5
+ * Fix table:list displays broken database list in Ruby 1.8
6
+ * Fix -e option handling in bulk_import
7
+ * Add 'Last import' column to table:list
8
+ https://github.com/treasure-data/td/issues/6
9
+
1
10
  == 2012-12-10 version 0.10.64
2
11
 
3
12
  * td-client v0.8.39
@@ -278,8 +278,9 @@ module Command
278
278
  exit 1
279
279
  end
280
280
 
281
+ require 'yajl'
281
282
  client.bulk_import_error_records(name) {|r|
282
- puts r.to_json
283
+ puts Yajl.dump(r)
283
284
  }
284
285
  end
285
286
 
@@ -336,13 +337,13 @@ module Command
336
337
  require 'fileutils'
337
338
  FileUtils.mkdir_p(outdir)
338
339
 
339
- require 'json'
340
+ require 'yajl'
340
341
  require 'msgpack'
341
342
  require 'zlib'
342
343
 
343
344
  error = Proc.new {|reason,data|
344
345
  begin
345
- $stderr.puts "#{reason}: #{data.to_json}"
346
+ $stderr.puts "#{reason}: #{Yajl.dump(data)}"
346
347
  rescue
347
348
  $stderr.puts "#{reason}"
348
349
  end
@@ -367,7 +368,7 @@ module Command
367
368
  zout = Zlib::GzipWriter.new(out)
368
369
 
369
370
  t = record['time']
370
- $stderr.puts " sample: #{Time.at(t).utc} #{record.to_json}"
371
+ $stderr.puts " sample: #{Time.at(t).utc} #{Yajl.dump(record)}"
371
372
  end
372
373
 
373
374
  zout.write(record.to_msgpack)
@@ -213,7 +213,7 @@ module Command
213
213
  def write_result(job, output, format)
214
214
  case format
215
215
  when 'json'
216
- require 'json'
216
+ require 'yajl'
217
217
  first = true
218
218
  File.open(output, "w") {|f|
219
219
  f.write "["
@@ -223,7 +223,7 @@ module Command
223
223
  else
224
224
  f.write ","
225
225
  end
226
- f.write row.to_json
226
+ f.write Yajl.dump(row)
227
227
  }
228
228
  f.write "]"
229
229
  }
@@ -239,16 +239,16 @@ module Command
239
239
  }
240
240
 
241
241
  when 'csv'
242
- require 'json'
242
+ require 'yajl'
243
243
  require 'csv'
244
244
  CSV.open(output, "w") {|writer|
245
245
  job.result_each {|row|
246
- writer << row.map {|col| col.is_a?(String) ? col.to_s : col.to_json }
246
+ writer << row.map {|col| col.is_a?(String) ? col.to_s : Yajl.dump(col) }
247
247
  }
248
248
  }
249
249
 
250
250
  when 'tsv'
251
- require 'json'
251
+ require 'yajl'
252
252
  File.open(output, "w") {|f|
253
253
  job.result_each {|row|
254
254
  first = true
@@ -258,7 +258,7 @@ module Command
258
258
  else
259
259
  f.write "\t"
260
260
  end
261
- f.write col.is_a?(String) ? col.to_s : col.to_json
261
+ f.write col.is_a?(String) ? col.to_s : Yajl.dump(col)
262
262
  }
263
263
  f.write "\n"
264
264
  }
@@ -270,7 +270,7 @@ module Command
270
270
  end
271
271
 
272
272
  def render_result(job, opts)
273
- require 'json'
273
+ require 'yajl'
274
274
  rows = []
275
275
  job.result_each {|row|
276
276
  # TODO limit number of rows to show
@@ -278,7 +278,7 @@ module Command
278
278
  if v.is_a?(String)
279
279
  s = v.to_s
280
280
  else
281
- s = v.to_json
281
+ s = Yajl.dump(v)
282
282
  end
283
283
  # Here does UTF-8 -> UTF-16LE -> UTF8 conversion:
284
284
  # a) to make sure the string doesn't include invalid byte sequence
@@ -81,26 +81,27 @@ module Command
81
81
  client = get_client
82
82
 
83
83
  if db_name
84
- db = get_database(client, db_name)
85
- dbs = [db]
84
+ database = get_database(client, db_name)
85
+ databases = [database]
86
86
  else
87
- dbs = client.databases
87
+ databases = client.databases
88
88
  end
89
89
 
90
90
  rows = []
91
- ::Parallel.each(dbs, :in_threads => num_threads) {|db|
91
+ ::Parallel.each(databases, :in_threads => num_threads) {|db|
92
92
  db.tables.each {|table|
93
93
  pschema = table.schema.fields.map {|f|
94
94
  "#{f.name}:#{f.type}"
95
95
  }.join(', ')
96
- rows << {:Database => db.name, :Table => table.name, :Type => table.type.to_s, :Count => table.count.to_s, :Size => table.estimated_storage_size_string, :Schema => pschema}
96
+ rows << {:Database => db.name, :Table => table.name, :Type => table.type.to_s, :Count => table.count.to_s,
97
+ :Size => table.estimated_storage_size_string, 'Last import' => table.last_import ? table.last_import.localtime : nil, :Schema => pschema}
97
98
  }
98
99
  }
99
100
  rows = rows.sort_by {|map|
100
101
  [map[:Database], map[:Type].size, map[:Table]]
101
102
  }
102
103
 
103
- puts cmd_render_table(rows, :fields => [:Database, :Table, :Type, :Count, :Size, :Schema], :max_width=>500)
104
+ puts cmd_render_table(rows, :fields => [:Database, :Table, :Type, :Count, :Size, 'Last import', :Schema], :max_width=>500)
104
105
 
105
106
  if rows.empty?
106
107
  if db_name
@@ -40,7 +40,7 @@ module TreasureData
40
40
  class LineReader
41
41
  def initialize(io, error, opts)
42
42
  if encoding = opts[:encoding]
43
- io.external_encoding = encoding
43
+ io.set_encoding(encoding) if io.respond_to?(:set_encoding)
44
44
  end
45
45
  #@delimiter = opts[:line_delimiter_expr] || /\r?\n/
46
46
  @io = io
@@ -84,6 +84,7 @@ module TreasureData
84
84
 
85
85
  class JSONParser
86
86
  def initialize(reader, error, opts)
87
+ require 'json' # TODO yajl?
87
88
  @reader = reader
88
89
  @error = error
89
90
  end
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.10.64'
3
+ VERSION = '0.10.65'
4
4
 
5
5
  end
data/td.gemspec CHANGED
@@ -17,9 +17,10 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_dependency "msgpack", "~> 0.4.4"
20
+ gem.add_dependency "yajl-ruby", "~> 1.1.0"
20
21
  gem.add_dependency "hirb", ">= 0.4.5"
21
22
  gem.add_dependency "parallel", "~> 0.5.19"
22
- gem.add_dependency "td-client", "~> 0.8.39"
23
+ gem.add_dependency "td-client", "~> 0.8.40"
23
24
  gem.add_dependency "td-logger", "~> 0.3.16"
24
25
  gem.add_development_dependency "rake", "~> 0.9"
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.64
4
+ version: 0.10.65
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-10 00:00:00.000000000 Z
12
+ date: 2012-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.4.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: yajl-ruby
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.1.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.0
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: hirb
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +82,7 @@ dependencies:
66
82
  requirements:
67
83
  - - ~>
68
84
  - !ruby/object:Gem::Version
69
- version: 0.8.39
85
+ version: 0.8.40
70
86
  type: :runtime
71
87
  prerelease: false
72
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +90,7 @@ dependencies:
74
90
  requirements:
75
91
  - - ~>
76
92
  - !ruby/object:Gem::Version
77
- version: 0.8.39
93
+ version: 0.8.40
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: td-logger
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -176,18 +192,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
192
  - - ! '>='
177
193
  - !ruby/object:Gem::Version
178
194
  version: '0'
179
- segments:
180
- - 0
181
- hash: -3517208562406139060
182
195
  required_rubygems_version: !ruby/object:Gem::Requirement
183
196
  none: false
184
197
  requirements:
185
198
  - - ! '>='
186
199
  - !ruby/object:Gem::Version
187
200
  version: '0'
188
- segments:
189
- - 0
190
- hash: -3517208562406139060
191
201
  requirements: []
192
202
  rubyforge_project:
193
203
  rubygems_version: 1.8.23