|
What is Aruna DB? |
Last Updated: 9/25/2001
A_TempFile
You can export values into this class and then iterate over those values. This works exactly like an Array except when the specified amount of memory is used up the values are written to disk. If the all data fits in the specified memory size, then this class works exactly like an Array. The class was created to allow my to put large amounts of data from the A_BTree, A_Table, and A_Index classes and then iterate over them. This class takes into account the fact that all the data may not fit in memory.
The temporary file used will have an extension of .tmp. This is a rows in, rows out kind of class. The rows are returned in the exact same order they are put in. If you want to order the data, see the A_FileSort class.
tmp = A_TempFile.new()
tmp.write(['hello world', 'Test this 1', 2])
tmp.write(['hello world3', 'Test this 1', 2])
tmp.write(['hello world', 'Test this 3', 2])
tmp.each {|data| print "#{data.join(',')}\n"}
tmp.close()
A_TempFile.version()
Returns the version of this class.
A_TempFile.buffer_size=(new_size)
Allows you set the memory size in bytes of the buffer. This value is used to determine if the buffer is full and should written to disk. This value applies to all temp files. The default value is 500K.
A_TempFile.buffer_size()
Returns the currently defined size of the buffer used for temp files.
A_TempFile.new(path=nil)
Creates a new object.
close()
Close this temp file and all opened temporary files.
each()
Iterate over all rows in the temp file. Yields(data).
write(data)
Write this data to the temp file.
tst_a_tempfile.rb - this script performs basic testing for the A_TempFile class. To run this tests type:
ruby -I.. tst_a_tempfile.rb
7 - prints high level stuff like creating and opening an A_TempFile object
71 - prints information about reading and writing blocks of data to and from disk.