188
188
defined order for the result iteration - it will be in the most
189
189
efficient order for the index.
191
stream = self._transport.get(self._name)
192
self._read_prefix(stream)
197
for line in stream.readlines():
201
key, absent, references, value = line[:-1].split('\0')
202
keys_by_offset[pos] = (key, absent, references, value)
203
for key, absent, references, value in keys_by_offset.values():
204
yield (key, (), value)
206
# there must be one line - the empty trailer line.
207
raise errors.BadIndexData(self)
209
def _read_prefix(self, stream):
210
signature = stream.read(len(self._signature()))
211
if not signature == self._signature():
212
raise errors.BadIndexFormatSignature(self._name, GraphIndex)
213
options_line = stream.readline()
214
if not options_line.startswith(_OPTION_NODE_REFS):
215
raise errors.BadIndexOptions(self)
217
self.node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1])
219
raise errors.BadIndexOptions(self)
193
221
def iter_entries(self, keys):
194
222
"""Iterate over keys within the index.
211
239
def validate(self):
212
240
"""Validate that everything in the index can be accessed."""
213
stream = self._transport.get(self._name)
214
signature = stream.read(len(self._signature()))
215
if not signature == self._signature():
216
raise errors.BadIndexFormatSignature(self._name, GraphIndex)
217
options_line = stream.readline()
218
if not options_line.startswith(_OPTION_NODE_REFS):
219
raise errors.BadIndexOptions(self)
221
node_ref_lists = int(options_line[len(_OPTION_NODE_REFS):-1])
223
raise errors.BadIndexOptions(self)
225
for line in stream.readlines():
229
# there must be one line - the empty trailer line.
230
raise errors.BadIndexData(self)
241
# iter_all validates completely at the moment, so just do that.
242
for node in self.iter_all_entries():