MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Lively <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 7 May 2003 10:05:34 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (37 lines)
On Wednesday, May 7, 2003, at 09:34  AM, Franz Walter Klein wrote:

> Hello AS Gurus,
>
> after years of silence I'm back to the list with a question: I run a
> web*
> server and need to put up a html form that is prefilled with some
> data. I
> need some kind of cgi that performs a lookup within a presorted text
> file
> and retrieves the line matching the search string entered by the remote
> user. The text file is sorted by that search string and may contain up
> to
> 500.000 lines and eventually more. Therefore the code needs to be
> efficient
> to guarantee short response times.
>
> Any ideas very welcome!!!!!
>
Perl...
Perhaps using a real database.
Perhaps you could split the text file into a bunch of little files so
that you have 26 directories each with 26 directories each with 26
directories each with a shortened version of the file.
Build an index of the first few characters of the search string and
keep that in memory and then read to that spot in the file and then
work sequentially.
It really helps if each line is a constant length.
You could do a QuickSearch.  Check the middle item, then halfway to the
end and so on until you narrow it down.
You could use a modified QuickSearch where instead of doing half you
make educated guesses.  Looking for a D you o 1/4 of the way.  Things
like that.

-Mark
Of course there is doing an OSAX in Fortran and doing a keyed read...

ATOM RSS1 RSS2