build/expand the index for this file.

    :param until: expand the index until the record with this hash has been
                  incorporated and then stop. If None, go until the iterator
                  is exhausted. Note that if this hash is already in the index,
                  no new items will be
    :param flush: if True, anything already in the index is discarded.

def __build_index(self, until=None, flush=False, verbose=False):
    """
    build/expand the index for this file.

    :param until: expand the index until the record with this hash has been
                  incorporated and then stop. If None, go until the iterator
                  is exhausted. Note that if this hash is already in the index,
                  no new items will be
    :param flush: if True, anything already in the index is discarded.
    """
    assert(self._indexed_file_handle is not None)
    if flush:
      self._index = {}

    file_loc = self._indexed_file_handle.tell()

    if verbose:
      self._indexed_file_handle.seek(0, 2)  # seek to end
      total = self._indexed_file_handle.tell() - file_loc
      self._indexed_file_handle.seek(file_loc)  # back to where we were
      pind = ProgressIndicator(totalToDo=total,
                               messagePrefix="completed",
                               messageSuffix="of building out index")

    for item in self.record_iterator(self._indexed_file_handle):
      hash_val = self.record_hash_function(item)
      self._index[hash_val] = file_loc
      file_loc = self._indexed_file_handle.tell()
      if until is not None and hash_val == until:
        break
      if verbose:
        pind.done = file_loc
        pind.showProgress()