diff --git a/libs/CodernityDB/__init__.py b/libs/CodernityDB/__init__.py index 8399a60..c059538 100644 --- a/libs/CodernityDB/__init__.py +++ b/libs/CodernityDB/__init__.py @@ -16,5 +16,5 @@ # limitations under the License. -__version__ = '0.4.2' +__version__ = '0.5.0' __license__ = "Apache 2.0" diff --git a/libs/CodernityDB/database.py b/libs/CodernityDB/database.py index 064836f..7aa177a 100644 --- a/libs/CodernityDB/database.py +++ b/libs/CodernityDB/database.py @@ -339,7 +339,7 @@ class Database(object): self.__set_main_storage() self.__compat_things() for patch in getattr(ind_obj, 'patchers', ()): # index can patch db object - patch(self) + patch(self, ind_obj) return name def edit_index(self, index, reindex=False, ind_kwargs=None): diff --git a/libs/CodernityDB/database_safe_shared.py b/libs/CodernityDB/database_safe_shared.py index e31100f..72290e8 100644 --- a/libs/CodernityDB/database_safe_shared.py +++ b/libs/CodernityDB/database_safe_shared.py @@ -59,8 +59,7 @@ class SafeDatabase(Database): def __init__(self, path, *args, **kwargs): super(SafeDatabase, self).__init__(path, *args, **kwargs) - self.indexes_locks = defaultdict( - lambda: cdb_environment['rlock_obj']()) + self.indexes_locks = defaultdict(cdb_environment['rlock_obj']) self.close_open_lock = cdb_environment['rlock_obj']() self.main_lock = cdb_environment['rlock_obj']() self.id_revs = {} @@ -94,7 +93,6 @@ class SafeDatabase(Database): def initialize(self, *args, **kwargs): with self.close_open_lock: - self.close_open_lock.acquire() res = super(SafeDatabase, self).initialize(*args, **kwargs) for name in self.indexes_names.iterkeys(): self.indexes_locks[name] = cdb_environment['rlock_obj']() diff --git a/libs/CodernityDB/debug_stuff.py b/libs/CodernityDB/debug_stuff.py index 76cdedf..2dce695 100644 --- a/libs/CodernityDB/debug_stuff.py +++ b/libs/CodernityDB/debug_stuff.py @@ -92,7 +92,7 @@ class DebugTreeBasedIndex(TreeBasedIndex): + nr_of_elements * (self.key_size + self.pointer_size)) node = struct.unpack('<' + self.node_heading_format + self.pointer_format + nr_of_elements * ( - self.key_format + self.pointer_format), + self.key_format + self.pointer_format), data) print node print diff --git a/libs/CodernityDB/sharded_hash.py b/libs/CodernityDB/sharded_hash.py index 08a8c2f..3cf76ac 100644 --- a/libs/CodernityDB/sharded_hash.py +++ b/libs/CodernityDB/sharded_hash.py @@ -40,7 +40,7 @@ from CodernityDB.sharded_index import ShardedIndex self.patchers.append(self.wrap_insert_id_index) @staticmethod - def wrap_insert_id_index(db_obj, clean=False): + def wrap_insert_id_index(db_obj, ind_obj, clean=False): def _insert_id_index(_rev, data): """ Performs insert on **id** index. diff --git a/libs/CodernityDB/tree_index.py b/libs/CodernityDB/tree_index.py index b79805d..4257b44 100644 --- a/libs/CodernityDB/tree_index.py +++ b/libs/CodernityDB/tree_index.py @@ -1565,13 +1565,13 @@ class IU_TreeBasedIndex(Index): def update(self, doc_id, key, u_start=0, u_size=0, u_status='o'): containing_leaf_start, element_index, old_doc_id, old_key, old_start, old_size, old_status = self._find_key_to_update(key, doc_id) + if u_start: + old_start = u_start + if u_size: + old_size = u_size + if u_status: + old_status = u_status new_data = (old_doc_id, old_start, old_size, old_status) - if not u_start: - new_data[1] = u_start - if not u_size: - new_data[2] = u_size - if not u_status: - new_data[3] = u_status self._update_element(containing_leaf_start, element_index, new_data) self._find_key.delete(key)