Next Lightweight Databases 47

Indexing

        sub build_index_for_users {
          my ($fh, $index_fh) = @_;
          seek $fh, 0, SEEK_SET;
          seek $index_fh, 0, SEEK_SET;
          truncate $index_fh, 0;       # Discard old index
          my $pos = tell $fh;
          while (<$fh>) {
            my $uid = (split /:/)[1];
            seek $index_fh, $uid * 10, SEEK_SET;
            print $index_fh, pack "A10", $pos;
            $pos = tell $fh;
          }
        }


Next Copyright © 2003 M. J. Dominus