Clear descendants when a parameter is deleted
This commit is contained in:
1 parent
0b70658cd3
commit
ac759e1d04
1 file changed
+26
-7
+26
-7
@@ -224,7 +224,22 @@ function unpack(deviceData, path, revision) {
|
|||||||
|
|
||||||
|
|
||||||
function invalidateSuperset(deviceData, path, attributes) {
|
function invalidateSuperset(deviceData, path, attributes) {
|
||||||
throw new Error('Not implemented');
|
let depth = 0;
|
||||||
|
if (attributes.exist != null)
|
||||||
|
depth = 99;
|
||||||
|
|
||||||
|
for (let sup of deviceData.paths.superset(path, 99)) {
|
||||||
|
if (sup.wildcard == path.wildcard && sup.length == path.length)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (let attrName in deviceData.timestamps) {
|
||||||
|
let t = deviceData.timestamps[attrName].get(sup);
|
||||||
|
if (t <= attributes[attrName] || t <= attributes.exist) {
|
||||||
|
deviceData.timestamps[attrName].delete(sup);
|
||||||
|
deviceData.values[attrName].delete(sup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -263,6 +278,9 @@ function normalizeAttributes(timestamps, values) {
|
|||||||
function set(deviceData, path, timestamps, values) {
|
function set(deviceData, path, timestamps, values) {
|
||||||
// TODO Optimize
|
// TODO Optimize
|
||||||
// TODO Allow overwriting attribute value with same timestamp
|
// TODO Allow overwriting attribute value with same timestamp
|
||||||
|
if (values == null)
|
||||||
|
values = {};
|
||||||
|
|
||||||
path = deviceData.paths.add(path);
|
path = deviceData.paths.add(path);
|
||||||
|
|
||||||
if (!path.wildcard) {
|
if (!path.wildcard) {
|
||||||
@@ -281,7 +299,7 @@ function set(deviceData, path, timestamps, values) {
|
|||||||
|
|
||||||
if (timestamps.exist != null) {
|
if (timestamps.exist != null) {
|
||||||
deviceData.timestamps.exist.set(path, timestamps.exist);
|
deviceData.timestamps.exist.set(path, timestamps.exist);
|
||||||
if (values != null && values.exist != null)
|
if (values.exist != null)
|
||||||
deviceData.values.exist.set(path, values.exist);
|
deviceData.values.exist.set(path, values.exist);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,22 +345,23 @@ function set(deviceData, path, timestamps, values) {
|
|||||||
deviceData.values[attrName].set(path, values[attrName]);
|
deviceData.values[attrName].set(path, values[attrName]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (deviceData.values[attrName].has(path))
|
if (deviceData.values[attrName].has(path)) {
|
||||||
invalidate = true;
|
invalidate = true;
|
||||||
deviceData.values[attrName].delete(path)
|
deviceData.values[attrName].delete(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalidate) {
|
if (invalidate) {
|
||||||
let inv = toInvalidate.get(path) || {};
|
let inv = toInvalidate.get(path) || {};
|
||||||
if (!timestamps[attrName] <= inv[attrName]) {
|
if (!(timestamps[attrName] <= inv[attrName])) {
|
||||||
inv[attrName] = timestamps[attrName];
|
inv[attrName] = timestamps[attrName];
|
||||||
toInvalidate.set(sub, inv);
|
toInvalidate.set(path, inv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toInvalidate.forEach(function(p, a) {
|
toInvalidate.forEach(function(a, p) {
|
||||||
invalidateSuperset(deviceData, p, a);
|
invalidateSuperset(deviceData, p, a);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user