ioblockreader 1.0.4.20130725 → 1.0.5.20130917

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS CHANGED
@@ -5,3 +5,4 @@
5
5
  * 1.0.2.20130613
6
6
  * 1.0.3.20130618
7
7
  * 1.0.4.20130725
8
+ * 1.0.5.20130917
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  = IOBlockReader Release History
2
2
 
3
+ == 1.0.5.20130917 (Beta)
4
+
5
+ * Bug correction: Sometimes first block to be read was deleted incorrectly.
6
+
3
7
  == 1.0.4.20130725 (Beta)
4
8
 
5
9
  * cached_block was not being updated correctly when blocks were invalidated.
data/ReleaseInfo CHANGED
@@ -2,7 +2,7 @@
2
2
  # This file has been generated by RubyPackager during a delivery.
3
3
  # More info about RubyPackager: http://rubypackager.sourceforge.net
4
4
  {
5
- :version => '1.0.4.20130725',
5
+ :version => '1.0.5.20130917',
6
6
  :tags => [ 'Beta' ],
7
7
  :dev_status => 'Beta'
8
8
  }
@@ -54,9 +54,9 @@ module IOBlockReader
54
54
  else
55
55
  # Use the cache if possible
56
56
  return @cached_block.data[range.first - @cached_block.offset..range.last - @cached_block.offset] if ((@cached_block != nil) and (range.first >= @cached_block.offset) and (range.last < @cached_block_end_offset))
57
- #puts "[IOBlockReader] - [](#{range.inspect}) - Cache miss"
58
57
  first_block_index, first_offset_in_block = range.first.divmod(@block_size)
59
58
  last_block_index, last_offset_in_block = range.last.divmod(@block_size)
59
+ #puts "[IOBlockReader] - [](#{range.inspect}) - Cache miss: load blocks #{first_block_index} - #{last_block_index}"
60
60
  # First check if all blocks are already loaded
61
61
  if (first_block_index == last_block_index)
62
62
  if ((block = @blocks[first_block_index]) == nil)
@@ -320,11 +320,12 @@ module IOBlockReader
320
320
  # * *first_block_index* (_Fixnum_): First block that has to be loaded
321
321
  # * *last_block_index* (_Fixnum_): Last block that has to be loaded
322
322
  def read_needed_blocks(indexes_needing_loading, first_block_index, last_block_index)
323
+ #puts "[IOBlockReader] - read_needed_blocks([ #{indexes_needing_loading.join(', ')} ], #{first_block_index}, #{last_block_index})"
323
324
  # We need to read from the IO
324
325
  # First check if we need to remove some blocks prior
325
326
  removed_blocks = []
326
327
  nbr_freeable_blocks = 0
327
- other_blocks = @blocks[0..first_block_index-1]
328
+ other_blocks = (first_block_index > 0) ? @blocks[0..first_block_index-1] : []
328
329
  other_blocks.concat(@blocks[last_block_index+1..-1]) if (last_block_index+1 < @blocks.size)
329
330
  other_blocks.each do |block|
330
331
  nbr_freeable_blocks += 1 if (block != nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ioblockreader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4.20130725
4
+ version: 1.0.5.20130917
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-25 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Ruby library giving block-buffered and cached read over IO objects with
15
15
  a String-like interface. Ideal to parse big files as Strings, limiting memory consumption.