Class TokyoCabinet::FDB
In: tokyocabinet.c
tokyocabinet-doc.rb
Parent: Object
BDB\n[tokyocabinet-doc.rb\ntokyocabinet.c] FDB\n[tokyocabinet-doc.rb\ntokyocabinet.c] BDBCUR\n[tokyocabinet-doc.rb\ntokyocabinet.c] HDB\n[tokyocabinet-doc.rb\ntokyocabinet.c] TDB\n[tokyocabinet-doc.rb\ntokyocabinet.c] TDBQRY\n[tokyocabinet-doc.rb\ntokyocabinet.c] ADB\n[tokyocabinet-doc.rb\ntokyocabinet.c] BDBCUR_data ADB_data TDB_data HDB_data TDBQRY_data FDB_data BDB_data tokyocabinet-doc.rb tokyocabinet.c TokyoCabinet dot/m_19_0.png

Fixed-Length database is a file containing a fixed-length table and is handled with the fixed-length database API. Before operations to store or retrieve records, it is necessary to open a database file and connect the fixed-length database object to it. To avoid data missing or corruption, it is important to close every database file 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’.%%

Methods

adddouble   addint   close   copy   ecode   errmsg   fsiz   get   iterinit   iternext   new   open   optimize   out   path   put   putcat   putkeep   range   rnum   sync   tranabort   tranbegin   trancommit   tune   vanish   vsiz  

Constants

ESUCCESS = INT2NUM(TCESUCCESS)
ETHREAD = INT2NUM(TCETHREAD)
EINVALID = INT2NUM(TCEINVALID)
ENOFILE = INT2NUM(TCENOFILE)
ENOPERM = INT2NUM(TCENOPERM)
EMETA = INT2NUM(TCEMETA)
ERHEAD = INT2NUM(TCERHEAD)
EOPEN = INT2NUM(TCEOPEN)
ECLOSE = INT2NUM(TCECLOSE)
ETRUNC = INT2NUM(TCETRUNC)
ESYNC = INT2NUM(TCESYNC)
ESTAT = INT2NUM(TCESTAT)
ESEEK = INT2NUM(TCESEEK)
EREAD = INT2NUM(TCEREAD)
EWRITE = INT2NUM(TCEWRITE)
EMMAP = INT2NUM(TCEMMAP)
ELOCK = INT2NUM(TCELOCK)
EUNLINK = INT2NUM(TCEUNLINK)
ERENAME = INT2NUM(TCERENAME)
EMKDIR = INT2NUM(TCEMKDIR)
ERMDIR = INT2NUM(TCERMDIR)
EKEEP = INT2NUM(TCEKEEP)
ENOREC = INT2NUM(TCENOREC)
EMISC = INT2NUM(TCEMISC)
OREADER = INT2NUM(FDBOREADER)
OWRITER = INT2NUM(FDBOWRITER)
OCREAT = INT2NUM(FDBOCREAT)
OTRUNC = INT2NUM(FDBOTRUNC)
ONOLCK = INT2NUM(FDBONOLCK)
OLCKNB = INT2NUM(FDBOLCKNB)
ESUCCESS = 0   error code: success
ETHREAD = 1   error code: threading error
EINVALID = 2   error code: invalid operation
ENOFILE = 3   error code: file not found
ENOPERM = 4   error code: no permission
EMETA = 5   error code: invalid meta data
ERHEAD = 6   error code: invalid record header
EOPEN = 7   error code: open error
ECLOSE = 8   error code: close error
ETRUNC = 9   error code: trunc error
ESYNC = 10   error code: sync error
ESTAT = 11   error code: stat error
ESEEK = 12   error code: seek error
EREAD = 13   error code: read error
EWRITE = 14   error code: write error
EMMAP = 15   error code: mmap error
ELOCK = 16   error code: lock error
EUNLINK = 17   error code: unlink error
ERENAME = 18   error code: rename error
EMKDIR = 19   error code: mkdir error
ERMDIR = 20   error code: rmdir error
EKEEP = 21   error code: existing record
ENOREC = 22   error code: no record found
EMISC = 9999   error code: miscellaneous error
OREADER = 1 << 0   open mode: open as a reader
OWRITER = 1 << 1   open mode: open as a writer
OCREAT = 1 << 2   open mode: writer creating
OTRUNC = 1 << 3   open mode: writer truncating
ONOLCK = 1 << 4   open mode: open without locking
OLCKNB = 1 << 5   open mode: lock without blocking

Public Class methods

Create a fixed-length database object.%% The return value is the new fixed-length database object.%%

[Source]

     # File tokyocabinet-doc.rb, line 762
762:     def initialize()
763:       # (native code)
764:     end

Public Instance methods

Add a real number to a record.%% `key’ specifies the key. It should be more than 0. If it is "min", the minimum ID number of existing records is specified. If it is "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified.%% `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.%%

[Source]

     # File tokyocabinet-doc.rb, line 871
871:     def adddouble(key, num)
872:       # (native code)
873:     end

Add an integer to a record.%% `key’ specifies the key. It should be more than 0. If it is "min", the minimum ID number of existing records is specified. If it is "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified.%% `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.%%

[Source]

     # File tokyocabinet-doc.rb, line 863
863:     def addint(key, num)
864:       # (native code)
865:     end

Close the database file.%% 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.%%

[Source]

     # File tokyocabinet-doc.rb, line 794
794:     def close()
795:       # (native code)
796:     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.%%

[Source]

     # File tokyocabinet-doc.rb, line 896
896:     def copy(path)
897:       # (native code)
898:     end

Get the last happened error code.%% The return value is the last happened error code.%% The following error codes are defined: `TokyoCabinet::FDB::ESUCCESS’ for success, `TokyoCabinet::FDB::ETHREAD’ for threading error, `TokyoCabinet::FDB::EINVALID’ for invalid operation, `TokyoCabinet::FDB::ENOFILE’ for file not found, `TokyoCabinet::FDB::ENOPERM’ for no permission, `TokyoCabinet::FDB::EMETA’ for invalid meta data, `TokyoCabinet::FDB::ERHEAD’ for invalid record header, `TokyoCabinet::FDB::EOPEN’ for open error, `TokyoCabinet::FDB::ECLOSE’ for close error, `TokyoCabinet::FDB::ETRUNC’ for trunc error, `TokyoCabinet::FDB::ESYNC’ for sync error, `TokyoCabinet::FDB::ESTAT’ for stat error, `TokyoCabinet::FDB::ESEEK’ for seek error, `TokyoCabinet::FDB::EREAD’ for read error, `TokyoCabinet::FDB::EWRITE’ for write error, `TokyoCabinet::FDB::EMMAP’ for mmap error, `TokyoCabinet::FDB::ELOCK’ for lock error, `TokyoCabinet::FDB::EUNLINK’ for unlink error, `TokyoCabinet::FDB::ERENAME’ for rename error, `TokyoCabinet::FDB::EMKDIR’ for mkdir error, `TokyoCabinet::FDB::ERMDIR’ for rmdir error, `TokyoCabinet::FDB::EKEEP’ for existing record, `TokyoCabinet::FDB::ENOREC’ for no record found, and `TokyoCabinet::FDB::EMISC’ for miscellaneous error.%%

[Source]

     # File tokyocabinet-doc.rb, line 774
774:     def ecode()
775:       # (native code)
776:     end

Get the message string corresponding to an error code.%% `ecode’ specifies the error code. If it is not defined or negative, the last happened error code is specified.%% The return value is the message string of the error code.%%

[Source]

     # File tokyocabinet-doc.rb, line 768
768:     def errmsg(ecode)
769:       # (native code)
770:     end

Get the size of the database file.%% The return value is the size of the database file or 0 if the object does not connect to any database file.%%

[Source]

     # File tokyocabinet-doc.rb, line 929
929:     def fsiz()
930:       # (native code)
931:     end

Retrieve a record.%% `key’ specifies the key. It should be more than 0. If it is `FDBIDMIN’, the minimum ID number of existing records is specified. If it is `FDBIDMAX’, the maximum ID number of existing records is specified.%% If successful, the return value is the value of the corresponding record. `nil’ is returned if no record corresponds.%%

[Source]

     # File tokyocabinet-doc.rb, line 830
830:     def get(key)
831:       # (native code)
832:     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.%%

[Source]

     # File tokyocabinet-doc.rb, line 842
842:     def iterinit()
843:       # (native code)
844:     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. The order of this traversal access method is ascending of the ID number.%%

[Source]

     # File tokyocabinet-doc.rb, line 848
848:     def iternext()
849:       # (native code)
850:     end

Open a database file.%% `path’ specifies the path of the database file.%% `omode’ specifies the connection mode: `TokyoCabinet::FDB::OWRITER’ as a writer, `TokyoCabinet::FDB::OREADER’ as a reader. If the mode is `TokyoCabinet::FDB::OWRITER’, the following may be added by bitwise-or: `TokyoCabinet::FDB::OCREAT’, which means it creates a new database if not exist, `TokyoCabinet::FDB::OTRUNC’, which means it creates a new database regardless if one exists. Both of `TokyoCabinet::FDB::OREADER’ and `TokyoCabinet::FDB::OWRITER’ can be added to by bitwise-or: `TokyoCabinet::FDB::ONOLCK’, which means it opens the database file without file locking, or `TokyoCabinet::FDB::OLCKNB’, which means locking is performed without blocking. If it is not defined, `TokyoCabinet::FDB::OREADER’ is specified.%% If successful, the return value is true, else, it is false.%%

[Source]

     # File tokyocabinet-doc.rb, line 788
788:     def open(path, omode)
789:       # (native code)
790:     end

Optimize the database file.%% `width’ specifies the width of the value of each record. If it is not defined or not more than 0, the current setting is not changed.%% `limsiz’ specifies the limit size of the database file. If it is not defined or not more than 0, the current setting is not changed.%% If successful, the return value is true, else, it is false.%%

[Source]

     # File tokyocabinet-doc.rb, line 884
884:     def optimize(bnum, width, limsiz)
885:       # (native code)
886:     end

Remove a record.%% `key’ specifies the key. It should be more than 0. If it is `FDBIDMIN’, the minimum ID number of existing records is specified. If it is `FDBIDMAX’, the maximum ID number of existing records is specified.%% If successful, the return value is true, else, it is false.%%

[Source]

     # File tokyocabinet-doc.rb, line 824
824:     def out(key)
825:       # (native code)
826:     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 file.%%

[Source]

     # File tokyocabinet-doc.rb, line 919
919:     def path()
920:       # (native code)
921:     end

Store a record.%% `key’ specifies the key. It should be more than 0. If it is "min", the minimum ID number of existing records is specified. If it is "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified.%% `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.%%

[Source]

     # File tokyocabinet-doc.rb, line 802
802:     def put(key, value)
803:       # (native code)
804:     end

Concatenate a value at the end of the existing record.%% `key’ specifies the key. It should be more than 0. If it is "min", the minimum ID number of existing records is specified. If it is "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified.%% `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.%%

[Source]

     # File tokyocabinet-doc.rb, line 818
818:     def putcat(key, value)
819:       # (native code)
820:     end

Store a new record.%% `key’ specifies the key. It should be more than 0. If it is "min", the minimum ID number of existing records is specified. If it is "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified.%% `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.%%

[Source]

     # File tokyocabinet-doc.rb, line 810
810:     def putkeep(key, value)
811:       # (native code)
812:     end

Get keys with an interval notation.%% `interval’ specifies the interval notation.%% `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.%%

[Source]

     # File tokyocabinet-doc.rb, line 855
855:     def range(interval, max)
856:       # (native code)
857:     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 file.%%

[Source]

     # File tokyocabinet-doc.rb, line 924
924:     def rnum()
925:       # (native code)
926:     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.%%

[Source]

     # File tokyocabinet-doc.rb, line 877
877:     def sync()
878:       # (native code)
879:     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.%%

[Source]

     # File tokyocabinet-doc.rb, line 914
914:     def tranabort()
915:       # (native code)
916:     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.%%

[Source]

     # File tokyocabinet-doc.rb, line 902
902:     def tranbegin()
903:       # (native code)
904:     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.%%

[Source]

     # File tokyocabinet-doc.rb, line 908
908:     def trancommit()
909:       # (native code)
910:     end

Set the tuning parameters.%% `width’ specifies the width of the value of each record. If it is not defined or not more than 0, the default value is specified. The default value is 255.%% `limsiz’ specifies the limit size of the database file. If it is not defined or not more than 0, the default value is specified. The default value is 268435456.%% If successful, the return value is true, else, it is false. Note that the tuning parameters of the database should be set before the database is opened.%%

[Source]

     # File tokyocabinet-doc.rb, line 781
781:     def tune(width, limsiz)
782:       # (native code)
783:     end

Remove all records.%% If successful, the return value is true, else, it is false.%%

[Source]

     # File tokyocabinet-doc.rb, line 889
889:     def vanish()
890:       # (native code)
891:     end

Get the size of the value of a record.%% `key’ specifies the key. It should be more than 0. If it is `FDBIDMIN’, the minimum ID number of existing records is specified. If it is `FDBIDMAX’, the maximum ID number of existing records is specified.%% If successful, the return value is the size of the value of the corresponding record, else, it is -1.%%

[Source]

     # File tokyocabinet-doc.rb, line 836
836:     def vsiz(key)
837:       # (native code)
838:     end

[Validate]