Class: Gonzui::BDBDBM
- Inherits:
-
AbstractDBM
- Object
- AbstractDBM
- Gonzui::BDBDBM
- Defined in:
- lib/gonzui/bdbdbm.rb
Constant Summary
Constants inherited from AbstractDBM
AbstractDBM::DBTable, AbstractDBM::IDTable
Instance Method Summary collapse
- #close ⇒ Object
- #find_all_by_prefix(pattern) ⇒ Object
-
#initialize(config, read_only = false) ⇒ BDBDBM
constructor
A new instance of BDBDBM.
Methods inherited from AbstractDBM
#binary_content?, #consistent?, #decrease_counter, #each_db_name, #each_format, #each_license, #each_package_name, #each_word, #find_all, #find_all_by_regexp, #find_word_info, #flush_cache, #get_all_word_info, #get_content, #get_content_hash, #get_content_info, #get_counter, #get_digest, #get_format_abbrev, #get_format_id, #get_format_id_from_path_id, #get_format_ids_from_package_id, #get_format_name, #get_license_abbrev, #get_license_id, #get_license_id_from_path_id, #get_license_ids_from_package_id, #get_license_name, #get_ncontents, #get_ncontents_by_format_id, #get_ncontents_by_license_id, #get_ncontents_in_package, #get_ncontents_indexed, #get_nformats, #get_nlines_indexed, #get_npackages, #get_nwords, #get_package_id, #get_package_id_from_path_id, #get_package_ids, #get_package_name, #get_package_names, #get_package_options, #get_path, #get_path_id, #get_path_ids, #get_path_ids_from_package_and_word_id, #get_source_uri, #get_type, #get_type_id, #get_word, #get_word_id, #get_word_ids, #has_format_abbrev?, #has_format_id?, #has_license_abbrev?, #has_license_id?, #has_package?, #has_path?, #has_type?, #has_word?, #increase_counter, #make_ncontents_by_format_key, #make_ncontents_by_license_key, #put_package_options, #put_pathid_wordids
Methods included from Util
assert, assert_equal, assert_equal_all, assert_non_nil, assert_not_reached, benchmark, command_exist?, commify, eprintf, format_bytes, program_name, protect_from_signals, require_command, set_verbosity, shell_escape, unix?, vprintf, windows?, wprintf
Constructor Details
#initialize(config, read_only = false) ⇒ BDBDBM
Returns a new instance of BDBDBM.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gonzui/bdbdbm.rb', line 16 def initialize(config, read_only = false) retried = false begin @db_mode = if read_only then BDB::RDONLY else BDB::CREATE end env_flags = BDB::CREATE | BDB::INIT_MPOOL | BDB::INIT_LOCK = {} ["set_cachesize"] = config.db_cache_size @db_env = BDB::Env.new(config.db_directory, env_flags, ) super(config, read_only) rescue BDB::Fatal => e raise e if retried retried = true # # "Lock table is out of available locker entries" # error ocasionally occurs if a process using # Gonzui::BDMDBM is killed by SIGKILL forcibly. In # that case, we can remove Berkeley DB Environment # to solve the error. # BDB::Env.remove(config.db_directory, BDB::FORCE) retry end end |
Instance Method Details
#close ⇒ Object
62 63 64 65 |
# File 'lib/gonzui/bdbdbm.rb', line 62 def close super @db_env.close end |
#find_all_by_prefix(pattern) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/gonzui/bdbdbm.rb', line 67 def find_all_by_prefix(pattern) results = [] self.word_wordid.each_by_prefix(pattern) {|word, word_id| results.concat(collect_all_results(word_id)) } return results end |