class Tkrzw::Index
Secondary index interface. All operations except for “open” and “close” are thread-safe; Multiple threads can access the same file concurrently. You can specify a data structure when you call the “open” method. Every opened index must be closed explicitly by the “close” method to avoid data corruption.
Public Class Methods
Does nothing especially.
# File tkrzw.rb, line 1207 def initialize() # (native code) end
Public Instance Methods
Adds a record.
-
@param key The key of the record. This can be an arbitrary expression to search the index.
-
@param value The value of the record. This should be a primary value of another database.
-
@return The result status.
# File tkrzw.rb, line 1252 def add(key, value) # (native code) end
Removes all records.
-
@return The result status.
# File tkrzw.rb, line 1278 def clear() # (native code) end
Closes the index file.
-
@return The result status.
# File tkrzw.rb, line 1229 def close() # (native code) end
Gets the number of records.
-
@return The number of records, or 0 on failure.
# File tkrzw.rb, line 1266 def count() # (native code) end
Releases the resource explicitly. The index is closed implicitly if it has not been closed. As long as you close the index explicitly, you don't have to call this method.
# File tkrzw.rb, line 1213 def destruct() # (native code) end
Calls the given block with the key and the value of each record
# File tkrzw.rb, line 1333 def each(&block) # (native code) end
Gets the path of the index file.
-
@return The file path of the index, or an empty string on failure.
# File tkrzw.rb, line 1272 def file_path() # (native code) end
Gets all values of records of a key.
-
@param key The key to look for.
-
@param max The maximum number of values to get. 0 means unlimited.
-
@return A list of all values of the key. An empty list is returned on failure.
# File tkrzw.rb, line 1244 def get_values(key, max=0) # (native code) end
Checks if a record exists or not.
-
@param key The key of the record.
-
@return True if the record exists, or false if not.
# File tkrzw.rb, line 1236 def include?(key) # (native code) end
Returns a string representation of the object.
-
@return The string representation of the object.
# File tkrzw.rb, line 1328 def inspect() # (native code) end
Makes an iterator for each record.
-
@return The iterator for each record.
Every iterator should be destructed explicitly by the “destruct” method.
# File tkrzw.rb, line 1310 def make_iterator() # (native code) end
Opens an index file.
-
@param path A path of the file.
-
@param writable If true, the file is writable. If false, it is read-only.
-
@param params Optional keyword parameters.
@:return The result status. If the path is empty, BabyDBM is used internally, which is equivalent to using the MemIndex class. If the path ends with “.tkt”, TreeDBM is used internally, which is equivalent to using the FileIndex class. If the key comparator of the tuning parameter is not set, PairLexicalKeyComparator is set implicitly. Other compatible key comparators are PairLexicalCaseKeyComparator, PairDecimalKeyComparator, PairHexadecimalKeyComparator, PairRealNumberKeyComparator, PairSignedBigEndianKeyComparator, and PairFloatBigEndianKeyComparator. Other options can be specified as with DBM#open
.
# File tkrzw.rb, line 1223 def open(path, writable, **params) # (native code) end
Checks whether the index is open.
-
@return True if the index is open, or false if not.
# File tkrzw.rb, line 1297 def open?() # (native code) end
Rebuilds the entire index.
-
@return The result status.
# File tkrzw.rb, line 1284 def rebuild() # (native code) end
Removes a record.
-
@param key The key of the record.
-
@param value The value of the record.
-
@return The result status.
# File tkrzw.rb, line 1260 def remove(key, value) # (native code) end
Synchronizes the content of the index to the file system.
-
@param hard True to do physical synchronization with the hardware or false to do only logical synchronization with the file system.
-
@return The result status.
# File tkrzw.rb, line 1291 def synchronize(hard) # (native code) end
Gets the number of records.
-
@return The number of records on success, or 0 on failure.
# File tkrzw.rb, line 1322 def to_i() # (native code) end
Returns a string representation of the content.
-
@return The string representation of the content.
# File tkrzw.rb, line 1316 def to_s() # (native code) end
Checks whether the index is writable.
-
@return True if the index is writable, or false if not.
# File tkrzw.rb, line 1303 def writable?() # (native code) end