tapsoob 0.3.22-java → 0.3.27-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tapsoob/data_stream.rb +28 -8
- data/lib/tapsoob/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c121ad1d7de6889a3cc1e79d39ab7844099a88a3da79654c1bfba1ddaba87f6
|
4
|
+
data.tar.gz: fac74e80043e1e2418f11541db774650f483a866e52fdfbe7282d4eb3f63a47a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4091d6a83bd692f59661236077028ee8c082b9fbe46d8adc7bb38afe736a6f26b3fcb404e4eeb9e2f0597cad75438cfbdeea5dabe9ad70f34f1582f202b7f54e
|
7
|
+
data.tar.gz: 3faea33ccd48dc605cd0f70e8f8fd9c68ed9a0d77ae057af193051a004124a91a9d2b65f3265878368e0aa9d035631ce6af4eb4142b2bd6bcc0070b4a9060152
|
data/lib/tapsoob/data_stream.rb
CHANGED
@@ -219,6 +219,9 @@ module Tapsoob
|
|
219
219
|
end
|
220
220
|
|
221
221
|
def import_rows(rows)
|
222
|
+
columns = rows[:header]
|
223
|
+
data = rows[:data]
|
224
|
+
|
222
225
|
# Decode blobs
|
223
226
|
if rows.has_key?(:types) && rows[:types].include?("blob")
|
224
227
|
blob_indices = rows[:types].each_index.select { |idx| rows[:types][idx] == "blob" }
|
@@ -229,10 +232,27 @@ module Tapsoob
|
|
229
232
|
end
|
230
233
|
end
|
231
234
|
|
235
|
+
# Parse date/datetime/time columns
|
236
|
+
if rows.has_key?(:types)
|
237
|
+
%w(date datetime time).each do |type|
|
238
|
+
if rows[:types].include?(type)
|
239
|
+
type_indices = rows[:types].each_index.select { |idx| rows[:types][idx] == type }
|
240
|
+
rows[:data].each_index do |idx|
|
241
|
+
type_indices.each do |ti|
|
242
|
+
rows[:data][idx][ti] = Sequel.send("string_to_#{type}".to_sym, rows[:data][idx][ti])
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
232
249
|
# Remove id column
|
233
|
-
|
250
|
+
if @options[:"discard-identity"]
|
251
|
+
columns = rows[:header] - ["id"]
|
252
|
+
data = data.map { |d| d[1..-1] }
|
253
|
+
end
|
234
254
|
|
235
|
-
table.import(columns,
|
255
|
+
table.import(columns, data, :commit_every => 100)
|
236
256
|
state[:offset] += rows[:data].size
|
237
257
|
rescue Exception => ex
|
238
258
|
case ex.message
|
@@ -250,19 +270,19 @@ module Tapsoob
|
|
250
270
|
state[:offset] = table.count
|
251
271
|
end
|
252
272
|
|
253
|
-
def self.factory(db, state)
|
273
|
+
def self.factory(db, state, opts)
|
254
274
|
if defined?(Sequel::MySQL) && Sequel::MySQL.respond_to?(:convert_invalid_date_time=)
|
255
275
|
Sequel::MySQL.convert_invalid_date_time = :nil
|
256
276
|
end
|
257
277
|
|
258
278
|
if state.has_key?(:klass)
|
259
|
-
return eval(state[:klass]).new(db, state)
|
279
|
+
return eval(state[:klass]).new(db, state, opts)
|
260
280
|
end
|
261
281
|
|
262
282
|
if Tapsoob::Utils.single_integer_primary_key(db, state[:table_name].to_sym)
|
263
|
-
DataStreamKeyed.new(db, state)
|
283
|
+
DataStreamKeyed.new(db, state, opts)
|
264
284
|
else
|
265
|
-
DataStream.new(db, state)
|
285
|
+
DataStream.new(db, state, opts)
|
266
286
|
end
|
267
287
|
end
|
268
288
|
end
|
@@ -270,8 +290,8 @@ module Tapsoob
|
|
270
290
|
class DataStreamKeyed < DataStream
|
271
291
|
attr_accessor :buffer
|
272
292
|
|
273
|
-
def initialize(db, state)
|
274
|
-
super(db, state)
|
293
|
+
def initialize(db, state, opts = {})
|
294
|
+
super(db, state, opts)
|
275
295
|
@state = { :primary_key => order_by(state[:table_name]).first, :filter => 0 }.merge(@state)
|
276
296
|
@state[:chunksize] ||= DEFAULT_CHUNKSIZE
|
277
297
|
@buffer = []
|
data/lib/tapsoob/version.rb
CHANGED