Class | TokyoCabinet::ADB |
In: |
tokyocabinet.c
tokyocabinet-doc.rb |
Parent: | Object |
Abstract database is a set of interfaces to use on-memory hash database, on-memory tree database, hash database, B+ tree database, fixed-length database, and table database with the same API. Before operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one. The method `open’ is used to open a concrete database and the method `close’ is used to close the database. To avoid data missing or corruption, it is important to close every database instance when it is no longer in use. It is forbidden for multible database objects in a process to open the same database at the same time.%% Except for the interface below, methods compatible with the `Hash’ class are also provided; `[]’, `[]=’, `store’, `delete’, `fetch’, `has_key?’, `has_value?’, `key’, `clear’, `length’, `empty?’, `each’, `each_key’, `each_value’, and `keys’.%%
Add a real number to a record.%% `key’ specifies the key.%% `num’ specifies the additional value.%% If successful, the return value is the summation value, else, it is `nil’.%% If the corresponding record exists, the value is treated as a real number and is added to. If no record corresponds, a new record of the additional value is stored. Because records are stored in binary format, they should be processed with the `unpack’ method with the `d’ operator after retrieval.%%
# File tokyocabinet-doc.rb, line 1471 1471: def adddouble(key, num) 1472: # (native code) 1473: end
Add an integer to a record.%% `key’ specifies the key.%% `num’ specifies the additional value.%% If successful, the return value is the summation value, else, it is `nil’.%% If the corresponding record exists, the value is treated as an integer and is added to. If no record corresponds, a new record of the additional value is stored. Because records are stored in binary format, they should be processed with the `unpack’ method with the `i’ operator after retrieval.%%
# File tokyocabinet-doc.rb, line 1463 1463: def addint(key, num) 1464: # (native code) 1465: end
Close the database.%% If successful, the return value is true, else, it is false.%% Update of a database is assured to be written when the database is closed. If a writer opens a database but does not close it appropriately, the database will be broken.%%
# File tokyocabinet-doc.rb, line 1393 1393: def close() 1394: # (native code) 1395: end
Copy the database file.%% `path’ specifies the path of the destination file. If it begins with `@’, the trailing substring is executed as a command line.%% If successful, the return value is true, else, it is false. False is returned if the executed command returns non-zero code.%% The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress. So, this method is useful to create a backup file of the database file.%%
# File tokyocabinet-doc.rb, line 1495 1495: def copy(path) 1496: # (native code) 1497: end
Get forward matching keys.%% `prefix’ specifies the prefix of the corresponding keys.%% `max’ specifies the maximum number of keys to be fetched. If it is not defined or negative, no limit is specified.%% The return value is a list object of the keys of the corresponding records. This method does never fail. It returns an empty list even if no record corresponds.%% Note that this method may be very slow because every key in the database is scanned.%%
# File tokyocabinet-doc.rb, line 1455 1455: def fwmkeys(prefix, max) 1456: # (native code) 1457: end
Retrieve a record.%% `key’ specifies the key.%% If successful, the return value is the value of the corresponding record. `nil’ is returned if no record corresponds.%%
# File tokyocabinet-doc.rb, line 1429 1429: def get(key) 1430: # (native code) 1431: end
Initialize the iterator.%% If successful, the return value is true, else, it is false.%% The iterator is used in order to access the key of every record stored in a database.%%
# File tokyocabinet-doc.rb, line 1441 1441: def iterinit() 1442: # (native code) 1443: end
Get the next key of the iterator.%% If successful, the return value is the next key, else, it is `nil’. `nil’ is returned when no record is to be get out of the iterator.%% It is possible to access every record by iteration of calling this method. It is allowed to update or remove records whose keys are fetched while the iteration. However, it is not assured if updating the database is occurred while the iteration. Besides, the order of this traversal access method is arbitrary, so it is not assured that the order of storing matches the one of the traversal access.%%
# File tokyocabinet-doc.rb, line 1447 1447: def iternext() 1448: # (native code) 1449: end
Call a versatile function for miscellaneous operations.%% `name’ specifies the name of the function.%% `args’ specifies an array of arguments. If it is not defined, no argument is specified.%% If successful, the return value is an array of the result. `nil’ is returned on failure.%%
# File tokyocabinet-doc.rb, line 1535 1535: def misc(name, args) 1536: # (native code) 1537: end
Open a database.%% `name’ specifies the name of the database. If it is "*", the database will be an on-memory hash database. If it is "+", the database will be an on-memory tree database. If its suffix is ".tch", the database will be a hash database. If its suffix is ".tcb", the database will be a B+ tree database. If its suffix is ".tcf", the database will be a fixed-length database. If its suffix is ".tct", the database will be a table database. Otherwise, this method fails. Tuning parameters can trail the name, separated by "#". Each parameter is composed of the name and the value, separated by "=". On-memory hash database supports "bnum", "capnum", and "capsiz". On-memory tree database supports "capnum" and "capsiz". Hash database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", and "xmsiz". B+ tree database supports "mode", "lmemb", "nmemb", "bnum", "apow", "fpow", "opts", "lcnum", "ncnum", and "xmsiz". Fixed-length database supports "mode", "width", and "limsiz". Table database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", "lcnum", "ncnum", "xmsiz", and "idx".%% If successful, the return value is true, else, it is false.%% The tuning parameter "capnum" specifies the capacity number of records. "capsiz" specifies the capacity size of using memory. Records spilled the capacity are removed by the storing order. "mode" can contain "w" of writer, "r" of reader, "c" of creating, "t" of truncating, "e" of no locking, and "f" of non-blocking lock. The default mode is relevant to "wc". "opts" can contains "l" of large option, "d" of Deflate option, "b" of BZIP2 option, and "t" of TCBS option. "idx" specifies the column name of an index and its type separated by ":". For example, "casket.tch#bnum=1000000#opts=ld" means that the name of the database file is "casket.tch", and the bucket number is 1000000, and the options are large and Deflate.%%
# File tokyocabinet-doc.rb, line 1387 1387: def open(name) 1388: # (native code) 1389: end
Optimize the storage.%% `params’ specifies the string of the tuning parameters, which works as with the tuning of parameters the method `open’. If it is not defined, it is not used.%% If successful, the return value is true, else, it is false.%%
# File tokyocabinet-doc.rb, line 1483 1483: def optimize(params) 1484: # (native code) 1485: end
Remove a record.%% `key’ specifies the key.%% If successful, the return value is true, else, it is false.%%
# File tokyocabinet-doc.rb, line 1423 1423: def out(key) 1424: # (native code) 1425: end
Get the path of the database file.%% The return value is the path of the database file or `nil’ if the object does not connect to any database instance. "*" stands for on-memory hash database. "+" stands for on-memory tree database.%%
# File tokyocabinet-doc.rb, line 1518 1518: def path() 1519: # (native code) 1520: end
Store a record.%% `key’ specifies the key.%% `value’ specifies the value.%% If successful, the return value is true, else, it is false.%% If a record with the same key exists in the database, it is overwritten.%%
# File tokyocabinet-doc.rb, line 1401 1401: def put(key, value) 1402: # (native code) 1403: end
Concatenate a value at the end of the existing record.%% `key’ specifies the key.%% `value’ specifies the value.%% If successful, the return value is true, else, it is false.%% If there is no corresponding record, a new record is created.%%
# File tokyocabinet-doc.rb, line 1417 1417: def putcat(key, value) 1418: # (native code) 1419: end
Store a new record.%% `key’ specifies the key.%% `value’ specifies the value.%% If successful, the return value is true, else, it is false.%% If a record with the same key exists in the database, this method has no effect.%%
# File tokyocabinet-doc.rb, line 1409 1409: def putkeep(key, value) 1410: # (native code) 1411: end
Get the number of records.%% The return value is the number of records or 0 if the object does not connect to any database instance.%%
# File tokyocabinet-doc.rb, line 1523 1523: def rnum() 1524: # (native code) 1525: end
Synchronize updated contents with the file and the device.%% If successful, the return value is true, else, it is false.%% This method is useful when another process connects the same database file.%%
# File tokyocabinet-doc.rb, line 1477 1477: def sync() 1478: # (native code) 1479: end
Abort the transaction.%% If successful, the return value is true, else, it is false.%% Update in the transaction is discarded when it is aborted. The state of the database is rollbacked to before transaction.%%
# File tokyocabinet-doc.rb, line 1513 1513: def tranabort() 1514: # (native code) 1515: end
Begin the transaction.%% If successful, the return value is true, else, it is false.%% The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time. Thus, the serializable isolation level is assumed if every database operation is performed in the transaction. All updated regions are kept track of by write ahead logging while the transaction. If the database is closed during transaction, the transaction is aborted implicitly.%%
# File tokyocabinet-doc.rb, line 1501 1501: def tranbegin() 1502: # (native code) 1503: end
Commit the transaction.%% If successful, the return value is true, else, it is false.%% Update in the transaction is fixed when it is committed successfully.%%
# File tokyocabinet-doc.rb, line 1507 1507: def trancommit() 1508: # (native code) 1509: end