ioblockreader 1.0.4.20130725 → 1.0.5.20130917
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/AUTHORS +1 -0
- data/ChangeLog +4 -0
- data/ReleaseInfo +1 -1
- data/lib/ioblockreader/ioblockreader.rb +3 -2
- metadata +2 -2
data/AUTHORS
CHANGED
data/ChangeLog
CHANGED
data/ReleaseInfo
CHANGED
@@ -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
|
+
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-
|
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.
|