Ejemplo n.º 1
0
        def _read_input_indexes(self, directory):
                """ Opens all index files using consistent_open and reads all
                of them into memory except the main dictionary file to avoid
                inefficient memory usage."""

                res = ss.consistent_open(self._data_dict.values(), directory,
                    self._file_timeout_secs)
                pt = self._progtrack
                if res == None:
                        self.file_version_number = INITIAL_VERSION_NUMBER
                        self.empty_index = True
                        return None
                self.file_version_number = res

                try:
                        pt.job_start(pt.JOB_READ_SEARCH)
                        try:
                                for d in self._data_dict.values():
                                        if (d == self._data_main_dict or
                                                d == self._data_token_offset):
                                                pt.job_add_progress(
                                                    pt.JOB_READ_SEARCH)
                                                continue
                                        d.read_dict_file()
                                        pt.job_add_progress(pt.JOB_READ_SEARCH)
                        except:
                                self._data_dict["main_dict"].close_file_handle()
                                raise
                finally:
                        for d in self._data_dict.values():
                                if d == self._data_main_dict:
                                        continue
                                d.close_file_handle()
                        pt.job_done(pt.JOB_READ_SEARCH)
Ejemplo n.º 2
0
 def check_index_has_exactly_fmris(self, fmri_names):
         """Checks to see if the fmris given are the ones indexed.
         """
         try:
                 res = \
                     ss.consistent_open(self._data_dict.values(),
                         self._index_dir, self._file_timeout_secs)
                 if res is not None and \
                     not self._data_full_fmri_hash.check_against_file(
                     fmri_names):
                         res = None
         finally:
                 for d in self._data_dict.values():
                         d.close_file_handle()
         return res is not None
Ejemplo n.º 3
0
        def check_index_existence(self):
                """ Returns a boolean value indicating whether a consistent
                index exists. If an index exists but is inconsistent, an
                exception is raised."""

                try:
                        try:
                                res = \
                                    ss.consistent_open(self._data_dict.values(),
                                        self._index_dir,
                                        self._file_timeout_secs)
                        except (KeyboardInterrupt,
                            search_errors.InconsistentIndexException):
                                raise
                        except Exception:
                                return False
                finally:
                        for d in self._data_dict.values():
                                d.close_file_handle()
                assert res is not 0
                return res
Ejemplo n.º 4
0
        def check_index_existence(self):
                """ Returns a boolean value indicating whether a consistent
                index exists. If an index exists but is inconsistent, an
                exception is raised."""

                try:
                        try:
                                res = \
                                    ss.consistent_open(self._data_dict.values(),
                                        self._index_dir,
                                        self._file_timeout_secs)
                        except (KeyboardInterrupt,
                            search_errors.InconsistentIndexException):
                                raise
                        except Exception:
                                return False
                finally:
                        for d in self._data_dict.values():
                                d.close_file_handle()
                assert res is not 0
                return res
Ejemplo n.º 5
0
        def _read_input_indexes(self, directory):
                """ Opens all index files using consistent_open and reads all
                of them into memory except the main dictionary file to avoid
                inefficient memory usage."""

                res = ss.consistent_open(self._data_dict.values(), directory,
                    self._file_timeout_secs)
                if self._progtrack is not None:
                        self._progtrack.index_set_goal(
                            _("Reading Existing Index"), len(self._data_dict))
                if res == None:
                        self.file_version_number = INITIAL_VERSION_NUMBER
                        self.empty_index = True
                        return None
                self.file_version_number = res

                try:
                        try:
                                for d in self._data_dict.values():
                                        if (d == self._data_main_dict or
                                                d == self._data_token_offset):
                                                if self._progtrack is not None:
                                                        self._progtrack.index_add_progress()
                                                continue
                                        d.read_dict_file()
                                        if self._progtrack is not None:
                                                self._progtrack.index_add_progress()
                        except:
                                self._data_dict["main_dict"].close_file_handle()
                                raise
                finally:
                        for d in self._data_dict.values():
                                if d == self._data_main_dict:
                                        continue
                                d.close_file_handle()
                if self._progtrack is not None:
                        self._progtrack.index_done()