hflr 1.2.1 → 1.2.3
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/hflr.gemspec +1 -1
- data/lib/hflr/fl_record_file.rb +12 -2
- metadata +1 -1
data/hflr.gemspec
CHANGED
data/lib/hflr/fl_record_file.rb
CHANGED
@@ -31,10 +31,12 @@ class FLRFile
|
|
31
31
|
end
|
32
32
|
if @fast
|
33
33
|
@width = get_record_width_from_file
|
34
|
+
puts "record width: #{@width}"
|
34
35
|
|
35
|
-
records_to_take =
|
36
|
+
records_to_take = 100000000 / @width
|
36
37
|
|
37
38
|
@buffer_size = @width * records_to_take
|
39
|
+
puts "buffer size: #{@buffer_size}"
|
38
40
|
|
39
41
|
@position=0
|
40
42
|
@current_buffer=nil
|
@@ -100,19 +102,25 @@ def fast_get_next_known_line_type
|
|
100
102
|
unless @current_buffer.nil? && (@offsets.nil? || @offsets.empty?)
|
101
103
|
if @current_buffer.nil?
|
102
104
|
chunk = @offsets.shift
|
105
|
+
puts "About to read chunk #{chunk.inspect}"
|
103
106
|
|
104
107
|
@file.pos = chunk.pos
|
105
108
|
@current_buffer=@file.read(chunk.width)
|
109
|
+
puts "current_buffer set to #{@current_buffer}"
|
106
110
|
record= @current_buffer.slice(@position,@width)
|
111
|
+
puts "Got record #{record}"
|
107
112
|
|
108
113
|
@position += @width
|
114
|
+
puts "position: #{@position}"
|
109
115
|
if @position >= @current_buffer.size
|
116
|
+
puts "Reseting buffer"
|
110
117
|
@current_buffer = nil
|
111
118
|
@position=0
|
112
119
|
end
|
113
120
|
return record
|
114
121
|
else
|
115
122
|
record= @current_buffer.slice(@position,@width)
|
123
|
+
puts "Got subsequent record #{record}"
|
116
124
|
@position += @width
|
117
125
|
if @position>=@current_buffer.size
|
118
126
|
@position=0
|
@@ -195,11 +203,13 @@ def offsets_to_read(ranges, width)
|
|
195
203
|
while !offsets.empty?
|
196
204
|
taken << offsets.shift
|
197
205
|
if taken.size * width == @buffer_size || offsets.empty?
|
198
|
-
|
206
|
+
|
207
|
+
chunks << chunk.new(taken.first * @width, taken.size * width)
|
199
208
|
taken = []
|
200
209
|
end # if
|
201
210
|
end # while
|
202
211
|
end # each
|
212
|
+
|
203
213
|
chunks
|
204
214
|
end
|
205
215
|
|