~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/index.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-11-14 19:13:49 UTC
  • mfrom: (2979.1.1 index)
  • Revision ID: pqm@pqm.ubuntu.com-20071114191349-wkdpsuhhbogisob8
(robertc) Use the GraphIndex header to answer key_count queries rather than parsing the entire index unnecessarily. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
""")
37
37
from bzrlib import debug, errors
38
38
 
 
39
_HEADER_READV = (0, 200)
39
40
_OPTION_KEY_ELEMENTS = "key_elements="
40
41
_OPTION_LEN = "len="
41
42
_OPTION_NODE_REFS = "node_ref_lists="
555
556
        For GraphIndex the estimate is exact.
556
557
        """
557
558
        if self._key_count is None:
558
 
            # really this should just read the prefix
559
 
            self._buffer_all()
 
559
            self._read_and_parse([_HEADER_READV])
560
560
        return self._key_count
561
561
 
562
562
    def _lookup_keys_via_location(self, location_keys):
612
612
                readv_ranges.append((location, length))
613
613
        # read the header if needed
614
614
        if self._bisect_nodes is None:
615
 
            readv_ranges.append((0, 200))
 
615
            readv_ranges.append(_HEADER_READV)
616
616
        self._read_and_parse(readv_ranges)
617
617
        # generate results:
618
618
        #  - figure out <, >, missing, present