Class: Ferret::Store::RAMDirectory::RAMIndexInput
- Inherits:
-
BufferedIndexInput
- Object
- IndexInput
- BufferedIndexInput
- Ferret::Store::RAMDirectory::RAMIndexInput
- Defined in:
- lib/ferret/store/ram_store.rb,
ext/ram_directory.c
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(ramfile) ⇒ Object
constructor
**************************************************************************.
- #length ⇒ Object
- #read_internal(rb, roffset, rlen) ⇒ Object
- #seek_internal(rpos) ⇒ Object
Methods inherited from BufferedIndexInput
#initialize_copy, #pos, #read_byte, #read_bytes, #read_chars, #read_int, #read_long, #read_string, #read_uint, #read_ulong, #read_vint, #read_vlong, #refill, #seek
Methods inherited from IndexInput
#pos, #read_byte, #read_bytes, #read_chars, #read_int, #read_long, #read_string, #read_uint, #read_ulong, #read_vint, #seek
Constructor Details
#initialize(ramfile) ⇒ Object
**************************************************************************
RAMIndexInput Methods
**************************************************************************
204 205 206 207 208 |
# File 'ext/ram_directory.c', line 204 def initialize(f) @pointer = 0 @file = f super() end |
Instance Method Details
#close ⇒ Object
265 266 |
# File 'ext/ram_directory.c', line 265 def close end |
#length ⇒ Object
212 213 214 |
# File 'ext/ram_directory.c', line 212 def length return @file.length end |
#read_internal(rb, roffset, rlen) ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'ext/ram_directory.c', line 221 def read_internal(b, offset, length) remainder = length start = @pointer while remainder != 0 buffer_number = (start / BUFFER_SIZE).to_i buffer_offset = start % BUFFER_SIZE bytes_in_buffer = BUFFER_SIZE - buffer_offset if bytes_in_buffer >= remainder bytes_to_copy = remainder else bytes_to_copy = bytes_in_buffer end buffer = @file.buffers[buffer_number] bo2 = buffer_offset do2 = offset b[do2, bytes_to_copy] = buffer[bo2, bytes_to_copy] offset += bytes_to_copy start += bytes_to_copy remainder -= bytes_to_copy end @pointer += length end |
#seek_internal(rpos) ⇒ Object
258 259 260 |
# File 'ext/ram_directory.c', line 258 def seek_internal(pos) @pointer = pos end |