CodernityDB updates

This commit is contained in:
Ruud
2014-10-06 23:00:50 +02:00
parent 4ae02a8764
commit e1eb68e226
2 changed files with 26 additions and 2 deletions
+7 -2
View File
@@ -952,8 +952,8 @@ you should check index code.""" % (index.name, ex), RuntimeWarning)
storage = ind.storage storage = ind.storage
data = storage.get(start, size, status) data = storage.get(start, size, status)
else: else:
data = {} data = {}
if with_doc and index_name != 'id': if with_doc and index_name != 'id':
storage = ind.storage storage = ind.storage
doc = self.get('id', l_key, False) doc = self.get('id', l_key, False)
@@ -966,6 +966,7 @@ you should check index code.""" % (index.name, ex), RuntimeWarning)
data['_rev'] = _unk data['_rev'] = _unk
else: else:
data['key'] = _unk data['key'] = _unk
return data return data
def get_many(self, index_name, key=None, limit=-1, offset=0, with_doc=False, with_storage=True, start=None, end=None, **kwargs): def get_many(self, index_name, key=None, limit=-1, offset=0, with_doc=False, with_storage=True, start=None, end=None, **kwargs):
@@ -1010,6 +1011,8 @@ you should check index code.""" % (index.name, ex), RuntimeWarning)
else: else:
data = {} data = {}
doc_id = ind_data[0] doc_id = ind_data[0]
doc_id = doc_id.decode()
if with_doc: if with_doc:
doc = self.get('id', doc_id, False) doc = self.get('id', doc_id, False)
if data: if data:
@@ -1045,13 +1048,15 @@ you should check index code.""" % (index.name, ex), RuntimeWarning)
except StopIteration: except StopIteration:
break break
else: else:
doc_id = doc_id.decode()
if index_name == 'id': if index_name == 'id':
if with_storage and size: if with_storage and size:
data = storage.get(start, size, status) data = storage.get(start, size, status)
else: else:
data = {} data = {}
data['_id'] = doc_id data['_id'] = doc_id
data['_rev'] = unk data['_rev'] = unk.decode()
else: else:
data = {} data = {}
if with_storage and size: if with_storage and size:
+19
View File
@@ -632,6 +632,10 @@ class IU_TreeBasedIndex(Index):
return buffer_start, (buffer_start + tree_buffer_size) return buffer_start, (buffer_start + tree_buffer_size)
def _find_first_key_occurence_in_node(self, node_start, key, nr_of_elements): def _find_first_key_occurence_in_node(self, node_start, key, nr_of_elements):
if isinstance(key, str):
key = key.encode()
if nr_of_elements == 1: if nr_of_elements == 1:
return self._find_key_in_node_with_one_element(key, node_start, mode=MODE_FIRST) return self._find_key_in_node_with_one_element(key, node_start, mode=MODE_FIRST)
else: else:
@@ -1914,14 +1918,29 @@ class IU_TreeBasedIndex(Index):
def get(self, key): def get(self, key):
## print("------", type(key)) # TODO ## print("------", type(key)) # TODO
## print(self) # TODO ## print(self) # TODO
# Fix types
if isinstance(key, str):
key = key.encode()
k = self.make_key(key) k = self.make_key(key)
## print("K:" * 10, k) # TODO ## print("K:" * 10, k) # TODO
return self._find_key(k) return self._find_key(k)
def get_many(self, key, limit=1, offset=0): def get_many(self, key, limit=1, offset=0):
# Fix types
if isinstance(key, str):
key = key.encode()
return self._find_key_many(self.make_key(key), limit, offset) return self._find_key_many(self.make_key(key), limit, offset)
def get_between(self, start, end, limit=1, offset=0, inclusive_start=True, inclusive_end=True): def get_between(self, start, end, limit=1, offset=0, inclusive_start=True, inclusive_end=True):
# Fix types
if isinstance(start, str):
start = start.encode()
if isinstance(end, str):
end = end.encode()
if start is None: if start is None:
end = self.make_key(end) end = self.make_key(end)
if inclusive_end: if inclusive_end: