File src/hash/hash-generate-cmph.c

Functions

local _compute_sizes () Determine how to allocate the bits of the 32 bits in the buckets.
local _output_buckets (L, ofile) Output the buckets table.
build_hash_table (L, ifile, ofile) Given the already generated hash function, read the list of keys and the associated value, and write the hash table.
local convert_funcnr (nr) Given a CMPH hash function number, convert that to the numbers used within LuaGnome.
local dump_bdz (f) Output the additional data fields specific for the BDZ algorithm.
local dump_fch (ofile) Output the data structure for fch.
local dump_mphf (L, f) Call the appropriate dump function to create C code containing the data of the cmph hash function.
generate_hash_cmph (L, datafile_name, _prefix, ofname) This function is called from gnomedev.c for the generate_hash call.
local get_hash_value (key, keylen) Calculate the first hash value - again, it already happened in cmph_search, but it doesn't return it anywhere.
special_strlen (s) Calculate the string length, but \[0-7]{1,3} is considered as just one character; this is how the C compiler sees it later.


Functions

local _compute_sizes ()
Determine how to allocate the bits of the 32 bits in the buckets. Lowest is the length of the data; this is zero when combining is off. Next is the offset, and lastly in the high bits the high part of the hash value.
local _output_buckets (L, ofile)
Output the buckets table. Each bucket is 32 bits long and contains part of the hash value, the offset of the associated data and the data length.

Parameters

  • L:
  • ofile:
build_hash_table (L, ifile, ofile)
Given the already generated hash function, read the list of keys and the associated value, and write the hash table. Each bucket contains exactly one entry: bytes contents 4 hash value of the name 2 offset of the data in the data string The data string contains the actual data.

Parameters

  • L:
  • ifile:
  • ofile:
local convert_funcnr (nr)
Given a CMPH hash function number, convert that to the numbers used within LuaGnome.

Parameters

  • nr:
local dump_bdz (f)
Output the additional data fields specific for the BDZ algorithm.

Parameters

  • f:
local dump_fch (ofile)
Output the data structure for fch. Required fields: h1, h2, m, b, p1, p2, g

Parameters

  • ofile:
local dump_mphf (L, f)
Call the appropriate dump function to create C code containing the data of the cmph hash function. It is written on stdout.

Parameters

  • L:
  • f:

Return value:

0 on success, 1 on error.
generate_hash_cmph (L, datafile_name, _prefix, ofname)
This function is called from gnomedev.c for the generate_hash call.

Parameters

  • L:
  • datafile_name:
  • _prefix:
  • ofname:
local get_hash_value (key, keylen)
Calculate the first hash value - again, it already happened in cmph_search, but it doesn't return it anywhere. This is an unfortunate intrusion into cmph internals!

Parameters

  • key:
  • keylen:
special_strlen (s)
Calculate the string length, but \[0-7]{1,3} is considered as just one character; this is how the C compiler sees it later. Note: \n, \t etc. is also detected, although no check for invalid escape sequences is done.

Parameters

  • s:

Valid XHTML 1.0!