Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Poor Person's Database

by TheoPetersen (Priest)
on Jun 20, 2001 at 16:37 UTC ( #89977=note: print w/ replies, xml ) Need Help??


in reply to Poor Person's Database

By naming each file for its search term you are basically moving the search and lookup logic to the file system. While file systems are pretty good at looking up file names, you're not necessarily saving anything that a non-linear search of one big file would cost.

To search a file such as you described non-linearly you need to either build an index structure for it (which tells your program, say, what byte to seek to for search terms beginning with the letter 'k') or perform a binary search on the file itself while taking the irregular record structure into account. The latter approach is kind of fun to program; you seek to the middle of the file, cruise forward to the next newline, and then read the next line to see what keyword you are on. Adjust the target forwards or backwards and seek again.

Note that I said it was fun to program, not blindingly fast :) But it should be faster than a linear search for most data.


Comment on Re: Poor Person's Database

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89977]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-10-21 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (96 votes), past polls