Yang model:
container a {
list b {
key id; // 1~8192
...
list c {
key num; // 1~8192
leaf name;
leaf funcion {
type string; // enable or disable
must "(current() = 'enable' and count(/a/b/c[name=current()/../name]) <=1)"
+" or current() = 'disable'" {
error-message "xxxxx";
}
}
}
}
}
It takes a long time to complete validation, when count(b) = 8192 and count© = 8192.
The following is what i did to improve the validation performance.
1st attempt --> tailf:sencondary-index
the leaf of /a/b/c/function is defined mandatory false. Suppose that the function could be changed to mandatory true, it still have to iterate the list b at least.
2nd attempt --> talif:unique-selector
My thought is that could confd add a unique-selector when the function leaf valued enable. I did try tailf:annotate and when to make unique-selector work even if i known this could not work.
3rd attempt --> hook handler and hidden leaf
container a {
list enabled-functions { // hidden
key name;
leaf enabled-funcion-counter;
}
list b {
key id; // 1~8192
...
list c {
key num; // 1~8192
leaf name;
leaf funcion {
type string; // enable or disable
must "(boolean(/a/enabled-functions[name = ../name]) "
+"and /a/enabled-functions[name = ../name]/enabled-funcion-counter = 0) "
+"or not(/a/enabled-functions[name = ../name])" {
error-message "xxxxx";
}
}
}
}
}
I add a set-hook to the path /a/b/c/function and do the things below.
set /a/b/c/function enable enabled-funcion-counter++
when the function value is enable in running cdb:
delete /a/b/c/function enabled-funcion-counter--
delete /a/b/c enabled-funcion-counter--
this is complicated but i have no other ways to make sure there is no performance problem.
I hope i have discribed my annoyance clearly and i am looking forward to your help.