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

Functions

local _bits_required (value) Compute how many bits are required to store the given value.
local _build_hash_table (L, ifile) Build the hash table with the data from the input file.
local _count_lines (f) Determine the number of lines in the file.
local _distribute (L) A hash table has been created.
local _output_buckets (L, ofile) Output the array of hash buckets, each one with a hash value, data offset, and an overflow bucket number.
local _output_values (L, ofile) For each bucket, output the value, and store the offsets into the buckets.
local _preprocess_line (s, key_len, data_ptr, data_len, line) Each line consists of a key and a data string, which are comma separated.
local _show_statistics () Show some statistics
generate_hash_simple (L, datafile_name, prefix1, ofname) Generate a hash table to map the key,value pairs found in the specified datafile, and write a compileable C file to the output file.
local special_strlen (s) This is a sort of strlen, but detects \ooo escape sequences and counts them as just one byte.


Functions

local _bits_required (value)
Compute how many bits are required to store the given value.

Parameters

  • value:
local _build_hash_table (L, ifile)
Build the hash table with the data from the input file.

Parameters

  • L:
  • ifile:
local _count_lines (f)
Determine the number of lines in the file.

Parameters

  • f:
local _distribute (L)
A hash table has been created. There are now empty buckets as well as overfilled buckets (i.e. more than one entry). Distribute entries into the empty buckets.

Parameters

  • L:
local _output_buckets (L, ofile)
Output the array of hash buckets, each one with a hash value, data offset, and an overflow bucket number.

Parameters

  • L:
  • ofile:
local _output_values (L, ofile)
For each bucket, output the value, and store the offsets into the buckets. Duplicates of values can appear. Store just one copy and use the same value in multiple buckets. Keep a sorted list of already seen values; do a binary search for each new value. New values are appended and qsort is called.

Parameters

  • L:
  • ofile:
local _preprocess_line (s, key_len, data_ptr, data_len, line)
Each line consists of a key and a data string, which are comma separated. Both key and data could contain non-printable characters encoded as \nnn; they are written as-is in the output, but for offset calculation the byte count required for it will be needed.

Parameters

  • s: Input line (starting with the key)
  • key_len: (output) Byte count of the key
  • data_ptr: (output) Start of data part of the line
  • data_len: (output) Byte count of the data
  • line:

Return value:

0 on success, -1 otherwise
local _show_statistics ()
Show some statistics
generate_hash_simple (L, datafile_name, prefix1, ofname)
Generate a hash table to map the key,value pairs found in the specified datafile, and write a compileable C file to the output file.

Parameters

  • L:
  • datafile_name:
  • prefix1:
  • ofname:
local special_strlen (s)
This is a sort of strlen, but detects \ooo escape sequences and counts them as just one byte.

Parameters

  • s:

Return value:

Length of the string

Valid XHTML 1.0!