Browse Source

Update DB lib

pull/5287/head
Ruud 10 years ago
parent
commit
54224bd851
  1. 2
      libs/CodernityDB/__init__.py
  2. 2
      libs/CodernityDB/database.py
  3. 4
      libs/CodernityDB/database_safe_shared.py
  4. 2
      libs/CodernityDB/debug_stuff.py
  5. 2
      libs/CodernityDB/sharded_hash.py
  6. 12
      libs/CodernityDB/tree_index.py

2
libs/CodernityDB/__init__.py

@ -16,5 +16,5 @@
# limitations under the License.
__version__ = '0.4.2'
__version__ = '0.5.0'
__license__ = "Apache 2.0"

2
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):

4
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']()

2
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

2
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.

12
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)

Loading…
Cancel
Save