hflr 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/hflr.gemspec +1 -1
- data/lib/hflr/fl_record_file.rb +18 -17
- data/test/flrfile_test.rb +1 -0
- metadata +1 -1
data/hflr.gemspec
CHANGED
data/lib/hflr/fl_record_file.rb
CHANGED
@@ -31,11 +31,11 @@ class FLRFile
|
|
31
31
|
end
|
32
32
|
if @fast
|
33
33
|
@width = get_record_width_from_file
|
34
|
-
|
34
|
+
|
35
35
|
records_to_take = 50000001 / @width
|
36
|
-
|
36
|
+
|
37
37
|
@buffer_size = @width * records_to_take
|
38
|
-
|
38
|
+
|
39
39
|
@position=0
|
40
40
|
@current_buffer=nil
|
41
41
|
end
|
@@ -48,7 +48,7 @@ class FLRFile
|
|
48
48
|
end
|
49
49
|
|
50
50
|
@offsets =offsets_to_read(ranges, @width)
|
51
|
-
|
51
|
+
|
52
52
|
@ranges = ranges
|
53
53
|
end
|
54
54
|
|
@@ -100,28 +100,29 @@ def fast_get_next_known_line_type
|
|
100
100
|
unless @current_buffer.nil? && (@offsets.nil? || @offsets.empty?)
|
101
101
|
if @current_buffer.nil?
|
102
102
|
chunk = @offsets.shift
|
103
|
-
|
103
|
+
|
104
104
|
@file.pos = chunk.pos
|
105
105
|
@current_buffer=@file.read(chunk.width)
|
106
106
|
record= @current_buffer.slice(@position,@width)
|
107
|
-
|
108
|
-
|
109
|
-
@position
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
puts "current_buffer changed to #{@current_buffer}"
|
107
|
+
|
108
|
+
@position += @width
|
109
|
+
if @position >= @current_buffer.size
|
110
|
+
@current_buffer = nil
|
111
|
+
@position=0
|
112
|
+
end
|
114
113
|
return record
|
115
114
|
else
|
116
|
-
record= @current_buffer.slice(@position,@width)
|
117
|
-
puts "Getting subsequent record: #{record}"
|
115
|
+
record= @current_buffer.slice(@position,@width)
|
118
116
|
@position += @width
|
119
|
-
|
120
|
-
|
117
|
+
if @position>=@current_buffer.size
|
118
|
+
@position=0
|
119
|
+
@current_buffer=nil
|
120
|
+
end
|
121
|
+
return record
|
121
122
|
end
|
122
123
|
|
123
124
|
else
|
124
|
-
|
125
|
+
|
125
126
|
nil
|
126
127
|
end
|
127
128
|
end
|
data/test/flrfile_test.rb
CHANGED