Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: (OT) should i limit number of files in a directory

by sgt (Deacon)
on Sep 12, 2008 at 12:21 UTC ( [id://710891]=note: print w/replies, xml ) Need Help??


in reply to (OT) should i limit number of files in a directory

Hi Leo,

I would use a simple n-level deep scheme which consists of a rootdir with subdirs a-z where each contain dirs a-z (this repeated n times), and an index (plain file or dbm). As many have noted such a scheme transforms the usual linear search in a directory in something closer to a binary search.

An iterator would give the dir-part a/a/b, a/a/c, ..., a/a/z, a/b/a,... and start over when the list is exhausted; this way it is easier to keep the entries (almost) equally distributed especially if a few processes are writing concurrently in your (virtual) filesystem.

The index key would be the name of the file. Additional meta-info can be attached easily

for example

  • key 7644ebf125065a6c220dcd35b5190e57 => a/a/b/7644ebf125065a6c220dcd35b5190e57, a/a/b/7644ebf125065a6c220dcd35b5190e57.1st_pass, etc
  • cheers --stephan

    Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others chanting in the Monastery: (4)
    As of 2024-03-28 21:07 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found