lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 26-Jun-07, at 1:05 PM, Shmuel Zeigerman wrote:

chandan datta wrote:
Thanks /Shmuel /for the code,but it would really help if someone comes up a faster way-or if at all doing this in Lua is a good idea.

You can create an index file (similar to "table of contents" in a book).
Creating such an index is slow but using is very fast.
It will contain offsets into the log files, so it'd be possible
to "jump" to the required record (or group of records) - rather than
doing a linear search.

Presumably, the files are in order, so you could do a binary search
instead of a linear search, even though the records are variable
length. Use the :seek() method to move about in the file.