itacart.serialization.data_tree_blob.update_data_tree
- itacart.serialization.data_tree_blob.update_data_tree(buffer, cell, values)[source]
Write values at one node in place, and refresh the aggregates above it.
Values have fixed widths and fixed places, so an update rewrites a slot per level of the path and nothing else. A pyramid value is written at a leaf; a level value at any node that has values at its resolution. Adding or removing a node changes the structure, and is a new encoding.
- Parameters:
- Raises:
InvalidIndexError – If the cell is malformed.
NonExistentCellError – If it names no cell.
NonAtomicIndexError – If it holds more than one cell.
SerializationError – If the buffer is read-only, the blob holds no node for the cell, a name is unknown or has no values at the cell’s resolution, a pyramid value targets a node with daughters, or a value is invalid. Nothing is written when anything is refused.
MalformedBlobError – If the frame is malformed.
- Return type:
Example
>>> n = DataVariable("n", "u32", op="sum", leaf_max=1) >>> blob = bytearray(encode_data_tree({"NE(0625/0451(3))": {"n": 0}}, [n])) >>> update_data_tree(blob, "NE(0625/0451(3))", {"n": 1}) >>> read_data_cell(blob, "NE(0625/0451)") {'n': 1}