pg_data_encoder 0.1.9 → 0.1.10

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: 431bdd87361eddc821f92a2f930ea9164d6d5520
4
- data.tar.gz: e4ed69cc46abb4ac4ce20096e66cd5f9356361f0
3
+ metadata.gz: e3209836eee4a3a5800d46fc64ba77c03e64d252
4
+ data.tar.gz: 4de943949a6bf7ea016226d65f20e4551fbe4a1e
5
5
  SHA512:
6
- metadata.gz: f30bc9742ae41a779ba406eb29451cdbf0abbdef4aa678044c2b2fab923de2014097f8ab14e3ed5314255b73e62f1677643ffe9884af26335cb6645b57bace09
7
- data.tar.gz: 1f435434aa8517f0114d66d47d92cb1229946a954fc21319dbff0b820c6183387c4d100a04a5337d7b9fea0eec79dd6fcf12a23be114b1234d23a858a836c527
6
+ metadata.gz: 8beb1b7cd49c58110c75a16b84ec06fe296df2eaee2a488f1d6aa2f6d3ee3b788cf00a4b517ab12068ee053f333829f536f0e7e86e3f445097b1058e1038c851
7
+ data.tar.gz: d1ce10832ca535eb9800cecc7e94c9f10eba4ed8db8a7f53e38b2a58836c634d077a3531054c611d311250d89336163d361c14c71073a53997e4799913457274
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'activerecord', "~> 4.2.6"
4
+ gem 'activesupport', "~> 4.2.6"
5
+ gem 'pg_data_encoder'
6
+ gem 'postgres-copy', "~> 1.0.0"
7
+ gem 'pg'
@@ -1,17 +1,17 @@
1
- require 'active_record'
2
1
  require 'postgres-copy'
2
+ require 'active_record'
3
3
  require 'pg_data_encoder'
4
4
  require 'benchmark'
5
5
  # Create a test db before running
6
6
  # add any needed username, password, port
7
7
  # install the required gems
8
8
  #
9
- # gem install postgres-copy pg_data_encoder activerecord --no-ri --no-rdoc
9
+ # the easiest would to install bundler
10
+ # > gem install bundler
11
+ # > bundle install
12
+ # > bundle exec fast_load.rb
10
13
 
11
14
 
12
- ActiveSupport.on_load :active_record do
13
- require "postgres-copy/active_record"
14
- end
15
15
  ActiveRecord::Base.establish_connection(
16
16
  :adapter => "postgresql",
17
17
  :host => "localhost",
@@ -24,8 +24,8 @@ ActiveRecord::Base.connection.execute %{
24
24
  }
25
25
 
26
26
  class TestModel < ActiveRecord::Base
27
+ acts_as_copy_target
27
28
  end
28
-
29
29
  encoder = PgDataEncoder::EncodeForCopy.new
30
30
 
31
31
  puts "Loading data to disk"
@@ -36,7 +36,7 @@ puts Benchmark.measure {
36
36
  }
37
37
  puts "inserting into db"
38
38
  puts Benchmark.measure {
39
- TestModel.pg_copy_from(encoder.get_io, :format => :binary, :columns => [:data])
39
+ TestModel.copy_from(encoder.get_io, :format => :binary, :columns => [:data])
40
40
  }
41
41
 
42
42
  encoder.remove
@@ -134,7 +134,7 @@ module PgDataEncoder
134
134
  r = io.read(16).unpack("H*").first
135
135
  "#{r[0..7]}-#{r[8..11]}-#{r[12..15]}-#{r[16..19]}-#{r[20..-1]}"
136
136
  }
137
- when 1043 #string
137
+ when 1043, 25 #string
138
138
  0.upto(size - 1).map {|i|
139
139
  size = io.read(4).unpack("N").first
140
140
  io.read(size)
@@ -1,3 +1,3 @@
1
1
  module PgDataEncoder
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
+ require 'date'
3
4
 
4
5
  describe "generating data" do
5
6
  it 'should encode hstore data correctly' do
@@ -189,7 +190,7 @@ describe "generating data" do
189
190
 
190
191
  it 'should encode timestamp data correctly' do
191
192
  encoder = PgDataEncoder::EncodeForCopy.new
192
- encoder.add [Time.parse("2013-06-11 15:03:54.62605 UTC")]
193
+ encoder.add [Time.at(1370963034.62605)] #Time.parse("2013-06-11 15:03:54.62605 UTC")
193
194
  encoder.close
194
195
  io = encoder.get_io
195
196
  existing_data = filedata("timestamp.dat")
@@ -202,7 +203,7 @@ describe "generating data" do
202
203
 
203
204
  it 'should encode dates and times in pg 9.2.4' do
204
205
  encoder = PgDataEncoder::EncodeForCopy.new
205
- encoder.add [Date.parse('2015-04-08'), nil, Time.parse("2015-02-13 16:13:57.732772 UTC")]
206
+ encoder.add [Date.parse('2015-04-08'), nil, Time.at(1423844037.732772)] # Time.parse("2015-02-13 16:13:57.732772 UTC")
206
207
  encoder.close
207
208
  io = encoder.get_io
208
209
  existing_data = filedata("dates_p924.dat")
@@ -215,7 +216,7 @@ describe "generating data" do
215
216
 
216
217
  it 'should encode dates and times in pg 9.3.5' do
217
218
  encoder = PgDataEncoder::EncodeForCopy.new
218
- encoder.add [Date.parse('2015-04-08'), nil, Time.parse("2015-02-13 16:13:57.732772 UTC")]
219
+ encoder.add [Date.parse('2015-04-08'), nil, Time.at(1423844037.732772)] # Time.parse("2015-02-13 16:13:57.732772 UTC")
219
220
  encoder.close
220
221
  io = encoder.get_io
221
222
  existing_data = filedata("dates_pg935.dat")
@@ -228,7 +229,7 @@ describe "generating data" do
228
229
 
229
230
  it 'should encode timestamp data correctly' do
230
231
  encoder = PgDataEncoder::EncodeForCopy.new
231
- encoder.add [Time.parse("2013-06-11 15:03:54.62605 UTC")]
232
+ encoder.add [Time.at(1370963034.62605)] # Time.parse("2013-06-11 15:03:54.62605 UTC")
232
233
  encoder.close
233
234
  io = encoder.get_io
234
235
  existing_data = filedata("timestamp.dat")
@@ -241,7 +242,7 @@ describe "generating data" do
241
242
 
242
243
  it 'should encode big timestamp data correctly' do
243
244
  encoder = PgDataEncoder::EncodeForCopy.new
244
- encoder.add [Time.parse("2014-12-02 16:01:22.437311 UTC")]
245
+ encoder.add [Time.at(1417536082.437311)] #Time.parse("2014-12-02 16:01:22.437311 UTC")
245
246
  encoder.close
246
247
  io = encoder.get_io
247
248
  existing_data = filedata("timestamp_9.3.dat")
@@ -280,7 +281,7 @@ describe "generating data" do
280
281
 
281
282
  it 'should encode float correctly from tempfile' do
282
283
  encoder = PgDataEncoder::EncodeForCopy.new(:use_tempfile => true)
283
- encoder.add [Time.parse("2013-06-11 15:03:54.62605 UTC")]
284
+ encoder.add [Time.at(1370963034.62605)] # Time.parse("2013-06-11 15:03:54.62605 UTC")
284
285
  encoder.close
285
286
  io = encoder.get_io
286
287
  existing_data = filedata("timestamp.dat")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_data_encoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Brumm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-29 00:00:00.000000000 Z
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -51,6 +51,8 @@ files:
51
51
  - LICENSE.txt
52
52
  - README.md
53
53
  - Rakefile
54
+ - examples/Gemfile
55
+ - examples/Gemfile.lock
54
56
  - examples/fast_load.rb
55
57
  - lib/pg_data_encoder.rb
56
58
  - lib/pg_data_encoder/decoder.rb
@@ -117,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  version: '0'
118
120
  requirements: []
119
121
  rubyforge_project:
120
- rubygems_version: 2.2.3
122
+ rubygems_version: 2.2.2
121
123
  signing_key:
122
124
  specification_version: 4
123
125
  summary: for faster input of data into postgres you can use this to generate the binary
@@ -162,3 +164,4 @@ test_files:
162
164
  - spec/spec_helper.rb
163
165
  - spec/verify_data_formats_spec.rb
164
166
  - spec/verify_decoder_spec.rb
167
+ has_rdoc: