📄 curia.3
字号:
.TH CURIA 3 "2003-11-27" "Man Page" "Quick Database Manager".SH NAMECuria \- the extended API of QDBM.SH SYNOPSIS.PP.B #include <depot.h>.br.B #include <curia.h>.br.B #include <stdlib.h>.PP.B CURIA *cropen(const char *name, int omode, int bnum, int dnum);.PP.B int crclose(CURIA *curia);.PP.B int crput(CURIA *curia, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode);.PP.B int crout(CURIA *curia, const char *kbuf, int ksiz);.PP.B char *crget(CURIA *curia, const char *kbuf, int ksiz, int start, int max, int *sp);.PP.B int crvsiz(CURIA *curia, const char *kbuf, int ksiz);.PP.B int criterinit(CURIA *curia);.PP.B char *criternext(CURIA *curia, int *sp);.PP.B int crsetalign(CURIA *curia, int align);.PP.B int crsync(CURIA *curia);.PP.B int croptimize(CURIA *curia, int bnum);.PP.B char *crname(CURIA *curia);.PP.B int crfsiz(CURIA *curia);.PP.B int crbnum(CURIA *curia);.PP.B int crbusenum(CURIA *curia);.PP.B int crrnum(CURIA *curia);.PP.B int crwritable(CURIA *curia);.PP.B int crfatalerror(CURIA *curia);.PP.B int crinode(CURIA *curia);.PP.B int crremove(const char *name);.PP.B int crputlob(CURIA *curia, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode);.PP.B int croutlob(CURIA *curia, const char *kbuf, int ksiz);.PP.B char *crgetlob(CURIA *curia, const char *kbuf, int ksiz, int start, int max, int *sp);.PP.B int crvsizlob(CURIA *curia, const char *kbuf, int ksiz);.PP.B int crrnumlob(CURIA *curia);.SH DESCRIPTION.PPCuria is the extended API of QDBM. It provides routines for managing multiple database files in a directory. Restrictions of some file systems that the size of each file is limited are escaped by dividing a database file into two or more. If the database files deploy on multiple devices, the scalability is improved..PPAlthough Depot creates a database with a file name, Curia creates a database with a directory name. A database file named as `depot' is placed in the specified directory. Although it keeps the attribute of the database, it does not keep the entities of the records. Besides, sub directories are created by the number of division of the database, named with 4 digits. The database files are placed in the subdirectories. The entities of the records are stored in the database file. For example, in the case that a database directory named as `casket' and the number of division is 3, `casket/depot', `casket/0001/depot', `casket/0002/depot' and `casket/0003/depot' are created. No error occurs even if the namesake directory exists when creating a database. So, if sub directories exists and some devices are mounted on the sub directories, the database files deploy on the multiple devices. It is possible for the database files to deploy on multiple file servers using NFS and so on..PPCuria features managing large objects. Although usual records are stored in some database files, records of large objects are stored in individual files. Because the files of large objects are deployed in different directories named with the hash values, the access speed is part\-way robust although it is slower than the speed of usual records. Large and not often accessed data should be secluded as large objects. By doing this, the access speed of usual records are improved. the directory hierarchies of large objects are placed in the directory named as `lob' in the sub directories of the database. Because the key spaces of the usual records and the large objects are different, the operations keep out of each other..PPIn order to use Curia, you should include `depot.h', `curia.h' and `stdlib.h' in the source files. Usually, the following description will be near the beginning of a source file..PP.RS.B #include <depot.h>.br.B #include <curia.h>.br.B #include <stdlib.h>.RE.PPA pointer to `CURIA' is used as a database handle. It is like that some file I/O routines of `stdio.h' use a pointer to `FILE'. A database handle is opened with the function `cropen' and closed with `crclose'. You should not refer directly to any member of the handle. If a fatal error occurs in a database, any access method via the handle except `crclose' will not work and return error status. Although a process is allowed to use multiple database handles at the same time, handles of the same database directory should not be used..PPCuria also assign the external variable `dpecode' with the error code. The function `dperrmsg' is used in order to get the message of the error code..PPThe function `cropen' is used in order to get a database handle..TP.B CURIA *cropen(const char *name, int omode, int bnum, int dnum);`name' specifies the name of a database directory. `omode' specifies the connection mode: `CR_OWRITER' as a writer, `CR_OREADER' as a reader. If the mode is `CR_OWRITER', the following may be added by bitwise or: `CR_OCREAT', which means it creates a new database if not exist, `CR_OTRUNC', which means it creates a new database regardless if one exists. Both of `CR_OREADER' and `CR_OWRITER' can be added to by bitwise or: `CR_ONOLCK', which means it opens a database directory without file locking. `bnum' specifies the number of elements of each bucket array. If it is not more than 0, the default value is specified. The size of each bucket array is determined on creating, and can not be changed except for by optimization of the database. Suggested size of each bucket array is about from 0.5 to 4 times of the number of all records to store. `dnum' specifies the number of division of the database. If it is not more than 0, the default value is specified. The number of division can not be changed from the initial value. The max number of division is 512. The return value is the database handle or `NULL' if it is not successful. While connecting as a writer, an exclusive lock is invoked to the database directory. While connecting as a reader, a shared lock is invoked to the database directory. The thread blocks until the lock is achieved. If `CR_ONOLCK' is used, the application is responsible for exclusion control..PPThe function `crclose' is used in order to close a database handle..TP.B int crclose(CURIA *curia);`curia' specifies a database handle. If successful, the return value is true, else, it is false. Because the region of a closed handle is released, it becomes impossible to use the handle. Updating a database is assured to be written when the handle is closed. If a writer opens a database but does not close it appropriately, the database will be broken..PPThe function `crput' is used in order to store a record..TP.B int crput(CURIA *curia, const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode);`curia' specifies a database handle connected as a writer. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. `vbuf' specifies the pointer to the region of a value. `vsiz' specifies the size of the region of the value. If it is negative, the size is assigned with `strlen(vbuf)'. `dmode' specifies behavior when the key overlaps, by the following values: `CR_DOVER', which means the specified value overwrites the existing one, `CR_DKEEP', which means the existing value is kept, `CR_DCAT', which means the specified value is concatenated at the end of the existing value. If successful, the return value is true, else, it is false..PPThe function `crout' is used in order to delete a record..TP.B int crout(CURIA *curia, const char *kbuf, int ksiz);`curia' specifies a database handle connected as a writer. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. If successful, the return value is true, else, it is false. false is returned when no record corresponds to the specified key..PPThe function `crget' is used in order to retrieve a record..TP.B char *crget(CURIA *curia, const char *kbuf, int ksiz, int start, int max, int *sp);`curia' specifies a database handle. `kbuf' specifies the pointer to the region of a key. `ksiz' specifies the size of the region of the key. If it is negative, the size is assigned with `strlen(kbuf)'. `start' specifies the offset address of the beginning of the region of the value to be read. `max' specifies the max size to be read. If it is negative, the size to read is unlimited. `sp' specifies the pointer to a variable to which the size of the region of the return value is assigned. If it is `NULL', it is not used. If successful, the return value is the pointer to the region of the value of the corresponding record, else, it is `NULL'. `NULL' is returned when no record corresponds to the specified key or the size of the value of the corresponding record is less than `start'. Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call if it is no longer in use..PPThe function `crvsiz' is used in order to get the size of the value of a record..TP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -