td 0.10.52 → 0.10.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ == 2012-10-02 version 0.10.53
3
+
4
+ * bulk_import:prepare_parts works with Ruby 1.8
5
+ * bulk_import:prepare_parts supports 'msgpack' format
6
+ * bulk_import:prepare_parts supports gzip decompression
7
+
8
+
2
9
  == 2012-09-26 version 0.10.52
3
10
 
4
11
  * bulk_import:upload_parts subcommand supports --parallel option to upload
@@ -321,7 +321,10 @@ module Command
321
321
  outdir = s
322
322
  }
323
323
 
324
- *files = op.cmd_parse
324
+ files = op.cmd_parse
325
+
326
+ # TODO ruby 1.9
327
+ files = [files] unless files.is_a?(Array)
325
328
 
326
329
  unless outdir
327
330
  $stderr.puts "-o, --output DIR option is required."
@@ -350,7 +353,7 @@ module Command
350
353
  $stderr.puts "Processing #{ifname}..."
351
354
  record_num = 0
352
355
 
353
- basename = File.basename(ifname).split('.').first
356
+ basename = File.basename(ifname).sub(/\.(?:csv|tsv|json|msgpack)(?:\.gz)?$/i,'').split('.').join('_')
354
357
  File.open(ifname) {|io|
355
358
  of_index = 0
356
359
  out = nil
@@ -1,6 +1,28 @@
1
1
 
2
2
  module TreasureData
3
3
  class FileReader
4
+ require 'zlib'
5
+
6
+ class DecompressIOFilter
7
+ def self.filter(io, error, opts)
8
+ case opts[:compress]
9
+ when 'gzip'
10
+ return Zlib::GzipReader.new(io)
11
+ when 'plain'
12
+ return io
13
+ when nil
14
+ data = io.read(2)
15
+ io.rewind
16
+ if data.unpack('CC') == [0x1f, 0x8b]
17
+ return Zlib::GzipReader.new(io)
18
+ else
19
+ return io
20
+ end
21
+ else
22
+ raise "unknown compression type #{opts[:compress]}"
23
+ end
24
+ end
25
+ end
4
26
 
5
27
  class MessagePackParsingReader
6
28
  def initialize(io, error, opts)
@@ -11,7 +33,7 @@ module TreasureData
11
33
  end
12
34
 
13
35
  def forward
14
- @u.forward
36
+ @u.each {|r| break r }
15
37
  end
16
38
  end
17
39
 
@@ -313,6 +335,7 @@ module TreasureData
313
335
  case @format
314
336
  when 'text'
315
337
  Proc.new {|io,error|
338
+ io = DecompressIOFilter.filter(io, error, opts)
316
339
  reader = LineReader.new(io, error, opts)
317
340
  parser = DelimiterParser.new(reader, error, opts)
318
341
  if opts[:column_header]
@@ -337,6 +360,7 @@ module TreasureData
337
360
 
338
361
  when 'json'
339
362
  Proc.new {|io,error|
363
+ io = DecompressIOFilter.filter(io, error, opts)
340
364
  reader = LineReader.new(io, error, opts)
341
365
  parser = JSONParser.new(reader, error, opts)
342
366
  if opts[:column_header]
@@ -356,6 +380,7 @@ module TreasureData
356
380
 
357
381
  when 'msgpack'
358
382
  Proc.new {|io,error|
383
+ io = DecompressIOFilter.filter(io, error, opts)
359
384
  parser = MessagePackParsingReader.new(io, error, opts)
360
385
  if opts[:column_header]
361
386
  column_names = parser.forward
data/lib/td/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.10.52'
3
+ VERSION = '0.10.53'
4
4
 
5
5
  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.52
4
+ version: 0.10.53
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-09-27 00:00:00.000000000 Z
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack