2024-08-15 05:04:20 +00:00
|
|
|
--!df flags=disable-atomicity
|
2024-02-09 16:20:25 +00:00
|
|
|
--[[
|
|
|
|
Script for quickly computing single 64bit hash for keys of types specified in ARGV[].
|
|
|
|
Keys of every type are sorted lexicographically to ensure consistent order.
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- import:hashlib --
|
|
|
|
-- import:utillib --
|
|
|
|
|
|
|
|
-- inputs
|
2024-02-20 12:31:08 +00:00
|
|
|
local type = ARGV[1]
|
2024-02-09 16:20:25 +00:00
|
|
|
|
|
|
|
local OUT_HASH = 0
|
|
|
|
|
|
|
|
local function process(type)
|
|
|
|
local keys = LU_collect_keys('', type)
|
|
|
|
local hfunc = LH_funcs[type]
|
|
|
|
|
|
|
|
-- sort to provide consistent order
|
|
|
|
table.sort(keys)
|
|
|
|
for _, key in ipairs(keys) do
|
|
|
|
-- hand hash over to callback
|
|
|
|
OUT_HASH = hfunc(key, OUT_HASH)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-02-20 12:31:08 +00:00
|
|
|
process(string.lower(type))
|
2024-02-09 16:20:25 +00:00
|
|
|
|
|
|
|
return OUT_HASH
|