The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tie::Hash::MinPerfHashTwoLevel::OnDisk - construct or tie a "two level" minimal perfect hash based on disk

SYNOPSIS

  use Tie::Hash::MinPerfHashTwoLevel::OnDisk;

  Tie::Hash::MinPerfHashTwoLevel::OnDisk->make_file(
    file => $some_file,
    source_hash => $some_hash,
    comment => "this is a comment",
    debug => 0,
  );

  my %hash;
  tie %hash, "Tie::Hash::MinPerfHashTwoLevel::OnDisk", $some_file;

DESCRIPTION

This module allows one to either construct, or use a precomputed minimal perfect hash on disk via tied interface. The disk image of the hash is loaded by using mmap, which means that multiple processes may use the same disk image at the same time without memory duplication. The hash is readonly, and may only contain string values.

METHODS

make_file

Construct a new file from a given 'source_hash' argument. The constructed buffer is written to the file specified by the 'file' argument. A comment may be added to the file via the 'comment' argument, note that comments may not contain null characters, although keys and value may. A predetermined seed may be provided to the hash function (16 bytes) via the 'seed' argument, however note that if it does not produce hash values that allow for the construction of a valid two level perfect hash then a different seed will be automatically selected (this will not affect the ability to use the constructed hash, it just may not be deterministic). The 'debug' argument outputs some basic status infromation about the construction process.

validate_file

Validate the file specified by the 'file' argument. Returns a list of two values, 'version' and 'message'. If the file fails validation the 'version' will be undef and the 'message' will contain an error message. If the file passes validation the 'version' will specify the version of the file (currently only 0 is valid), and 'message' will contain some basic information about the file, such as how many keys it contains, the comment it was created with, etc.

EXPORT

None by default.

SEE ALSO

Algorithm::MinPerfHashTwoLevel

AUTHOR

Yves Orton

COPYRIGHT AND LICENSE

Copyright (C) 2019 by Yves Orton

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.4 or, at your option, any later version of Perl 5 you may have available.