redshift-connector-data_file 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f4a0fc069c6eb635d15751a45ccd2f2a7bf86c1
4
- data.tar.gz: 4789569a3178cf601a307c349e3ba42e07830bb5
3
+ metadata.gz: 5fab0d487a44643d1add17ce0323edab71ac75b8
4
+ data.tar.gz: b415428c7d55384f2c7ac9b83ea537947247dfbd
5
5
  SHA512:
6
- metadata.gz: 53e845941f6242c5804bcbc0918e8efe64a8cc825e896803ac2015b59774b199ec7ea43421aaf0a8ebd0cfc59cc394f663908174f2563fa34970d8159cc231e0
7
- data.tar.gz: 434c36b9a6cfac9719e88245bdd187b1a6bd6ba28f9464ec611eefddfebfeb4b4e5549400ebc8fc08f0050470f31df3b9ada1f495f16c7962d414556e5cd15bb
6
+ metadata.gz: 8882dc7483274809e15bb4d6d1a7110aa5700946e300fb74399b3c895d7f0d1dd9a0aba7c61c6b5e0a5cf280251196efaa9022a89582111623898775a6910942
7
+ data.tar.gz: 0d5b894719f9ff572fcd9f4a6077adf7ed80ee6da8525a3dc77526a9403c243b32fb9b2337d450482f79b53fb81b5a37e44ae9a030829b4767ce10f5b72348bb
@@ -18,5 +18,36 @@ module RedshiftConnector
18
18
  def all_data_objects
19
19
  data_files.select {|obj| obj.data_object? }
20
20
  end
21
+
22
+ REPORT_SIZE = 10_0000
23
+
24
+ def each_batch(report: true)
25
+ @logger.info "reader: #{@reader_class}"
26
+ n = 0
27
+ reported = 0
28
+ do_each_batch(@batch_size) do |rows|
29
+ yield rows
30
+ n += rows.size
31
+ if n / REPORT_SIZE > reported
32
+ @logger.info "#{n} rows processed" if report
33
+ reported = n / REPORT_SIZE
34
+ end
35
+ end
36
+ @logger.info "total #{n} rows processed" if report
37
+ end
38
+
39
+ def do_each_batch(batch_size)
40
+ filter = @filter
41
+ buf = []
42
+ each_row do |row|
43
+ buf.push filter.(*row)
44
+ if buf.size == batch_size
45
+ yield buf
46
+ buf = []
47
+ end
48
+ end
49
+ yield buf unless buf.empty?
50
+ end
51
+ private :do_each_batch
21
52
  end
22
53
  end
@@ -1,5 +1,5 @@
1
1
  module RedshiftConnector
2
2
  module DataFile
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redshift-connector-data_file
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hidekazu Kobayashi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-05-12 00:00:00.000000000 Z
12
+ date: 2017-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler