-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New DelKey.lua, and initial smax / dsm function libs
- Loading branch information
Showing
6 changed files
with
445 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
-- keys: [1+] SMA-X keywords | ||
-- arguments: (none) | ||
-- returns: (integer) the total number of fields deleted, including in sub-structures, and in parent structures. | ||
|
||
local metas = { '<timestamps>', '<types>', '<dims>', '<origins>', '<writes>', '<reads>', '<descriptions>', '<units>', '<coords>' } | ||
local n = 0 | ||
|
||
local function DelKey (table) | ||
-- Recursively delete table entries | ||
for f in redis.call('hkeys', table) do | ||
DelKey(table..':'..field) | ||
end | ||
|
||
-- Delete metadata for the table | ||
for m in metas do | ||
redis.call("hdel", m, table) | ||
end | ||
|
||
-- Delete the table itself | ||
if redis.call('del', table) == 1 then | ||
n = n + 1 | ||
end | ||
end | ||
|
||
-- Process each input keyword | ||
for key in KEYS do | ||
-- Delete the table (if any) recuresively | ||
DelKey(key) | ||
|
||
-- match the substring starting with the last : | ||
local tail = key:gmatch(':(?:.(?!:))+') | ||
|
||
-- If the keyword can be split... | ||
if tail ~= nil and tail ~= '' then | ||
-- Delete reference from parent table | ||
local parent = table:sub(1, -tail:len()) | ||
local ref = tail:sub(2) | ||
if redis.call('hdel', parent, ref) == 1 then | ||
n = n + 1 | ||
end | ||
end | ||
end | ||
|
||
return n |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!lua name=dsm | ||
|
||
local function dsm_get_key(KEYS, ARGS) | ||
-- keys: <none> | ||
-- arguments: host target key | ||
-- returns name SMA-X table name under which the data can be found | ||
|
||
local table = "DSM:"..ARGV[2] | ||
local key = ARGV[3] | ||
|
||
-- If the data is stored under the target name, use that | ||
if redis.call('hexists', table, key) == 1 then | ||
return table | ||
end | ||
|
||
-- If the data is stored under the caller's name, use that | ||
table = "DSM:"..ARGV[1] | ||
if redis.call('hexists', table, key) == 1 then | ||
return table | ||
end | ||
|
||
-- LUA false maps to Redis nil | ||
return false | ||
end | ||
|
||
|
||
redis.register_function { | ||
function_name='dsm_het_key', | ||
callback=dsm_get_key, | ||
flags={ 'no-writes' }, | ||
description='(|host, target, key) Returns the SMA-X table for the given host and target machine and DSM key' | ||
} |
Oops, something went wrong.