diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-10-20 19:27:09 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-10-20 19:27:09 +0200 |
| commit | 133fb2a63c260a26730d44bf79d87eee360558c5 (patch) | |
| tree | 1751a4cf4eac8e647fbc7a378af165adc326231c | |
| parent | 81cdcfa9cac04031082d93bb9e7bf6c844b7b75b (diff) | |
DB_composed_op - optimize for empty n_add, l_add sets
| -rw-r--r-- | src-py/db_controller.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src-py/db_controller.py b/src-py/db_controller.py index bd085371..ddc25a85 100644 --- a/src-py/db_controller.py +++ b/src-py/db_controller.py @@ -125,28 +125,29 @@ class DB_composed_op(DB_op): class DBO_topo_diff_commit(DB_composed_op): """ - commit a + commit a Topo_Diff """ def __init__(self, topo_diff): super(DBO_topo_diff_commit, self).__init__() # TODO rm link set # TODO rm node set - assert not topo_diff.node_set_rm, 'unsupported' - assert not topo_diff.link_set_rm, 'unsupported' + assert 0 == len(topo_diff.node_set_rm), 'unsupported' + assert 0 == len(topo_diff.link_set_rm), 'unsupported' n_add_map = db_util.meta_attr_list_to_meta_attr_map(topo_diff.node_set_add) l_add_map = db_util.meta_attr_list_to_meta_attr_map(topo_diff.link_set_add) - op_n_add = DBO_add_node_set(n_add_map) - op_l_add = DBO_add_link_set(l_add_map) - + # # [!] order critical - self.add_sub_op(op_n_add) - self.add_sub_op(op_l_add) + # + if len(n_add_map) > 0: + op_n_add = DBO_add_node_set(n_add_map) + self.add_sub_op(op_n_add) - def on_completion(self, data): - pass + if len(l_add_map) > 0: + op_l_add = DBO_add_link_set(l_add_map) + self.add_sub_op(op_l_add) class DBO_attr_diff_commit(DB_op): """ |
