At 8:51 AM +0800 7/12/08, paragasu wrote:
> Why not use a hash table based upon the name of the file and
distribute files that way?
sorry tedd, i don't really get it. but i am interested to know more
about the hash table concept.
can you explain a little bit more..
paragasu:
A hash table is simply a result from an algorithm where you take the
name of the file and produce a number from it. It can be any
computation you want that produces a number -- such as just totalling
the number of letters in the name.
For example, tedd.gif would compute to 4, whereas Rob.gif would be a
meager 3, and Daniel.gif would be a six (which is probably over-rated
for him anyway). :-)
Now, just use our respective number for storage in directories --
tedd.gif would be stored in directory 4, Ron.gif would be stored in
directory 3, and Daniel.gif in directory 6.
If you store the names of the files in a database, then you don't
need to store the paths as well because the paths can be computed
from the file names -- do you see?
Also, you don't need to create a directory until there's actually a
need for one.
This is old logic for creating memory structures where we weren't
forced to allocate memory beforehand -- it's like a large array with
holes in it. It's kind of slick when you can apply it to other stuff.
Now, the example I gave was pretty simple. However, a good hash
algorithm is one that distributes things evenly, and that's a bit
more complicated -- I'll leave that for another time.
<now returning you to your normal television viewing pleasure> :-)
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php