📄 odeum.3
字号:
.TH ODEUM 3 "2003-11-27" "Man Page" "Quick Database Manager".SH NAMEOdeum \- the inverted API of QDBM.SH SYNOPSIS.PP.B #include <depot.h>.br.B #include <cabin.h>.br.B #include <odeum.h>.br.B #include <stdlib.h>.PP.B typedef struct { int id; int score; } ODPAIR;.PP.B ODEUM *odopen(const char *name, int omode);.PP.B int odclose(ODEUM *odeum);.PP.B int odput(ODEUM *odeum, const ODDOC *doc, int wmax, int over);.PP.B int odout(ODEUM *odeum, const char *uri);.PP.B int odoutbyid(ODEUM *odeum, int id);.PP.B ODDOC *odget(ODEUM *odeum, const char *uri);.PP.B ODDOC *odgetbyid(ODEUM *odeum, int id);.PP.B ODPAIR *odsearch(ODEUM *odeum, const char *word, int max, int *np);.PP.B int odsearchdnum(ODEUM *odeum, const char *word);.PP.B int oditerinit(ODEUM *odeum);.PP.B ODDOC *oditernext(ODEUM *odeum);.PP.B int odsync(ODEUM *odeum);.PP.B int odoptimize(ODEUM *odeum);.PP.B char *odname(ODEUM *odeum);.PP.B int odfsiz(ODEUM *odeum);.PP.B int odbnum(ODEUM *odeum);.PP.B int oddnum(ODEUM *odeum);.PP.B int odwnum(ODEUM *odeum);.PP.B int odwritable(ODEUM *odeum);.PP.B int odfatalerror(ODEUM *odeum);.PP.B int odinode(ODEUM *odeum);.PP.B int odremove(const char *name);.PP.B ODDOC *oddocopen(const char *uri);.PP.B void oddocclose(ODDOC *doc);.PP.B void oddocaddattr(ODDOC *doc, const char *name, const char *value);.PP.B void oddocaddword(ODDOC *doc, const char *normal, const char *asis);.PP.B int oddocid(const ODDOC *doc);.PP.B const char *oddocuri(const ODDOC *doc);.PP.B const char *oddocgetattr(const ODDOC *doc, const char *name);.PP.B const CBLIST *oddocnwords(const ODDOC *doc);.PP.B const CBLIST *oddocawords(const ODDOC *doc);.PP.B CBMAP *oddocscores(const ODDOC *doc, int max, ODEUM *odeum);.PP.B CBLIST *odbreaktext(const char *text);.PP.B char *odnormalizeword(const char *asis);.PP.B ODPAIR *odpairsand(ODPAIR *apairs, int anum, ODPAIR *bpairs, int bnum, int *np);.PP.B ODPAIR *odpairsor(ODPAIR *apairs, int anum, ODPAIR *bpairs, int bnum, int *np);.PP.B ODPAIR *odpairsnotand(ODPAIR *apairs, int anum, ODPAIR *bpairs, int bnum, int *np);.PP.B void odpairssort(ODPAIR *pairs, int pnum);.PP.B double odlogarithm(double x);.PP.B double odvectorcosine(const int *avec, const int *bvec, int vnum);.SH DESCRIPTIONOdeum is the API which handles an inverted index. An inverted index is a data structure to retrieve a list of some documents that include one of words which were extracted from a population of documents. It is easy to realize a full\-text search system with an inverted index. Odeum provides an abstract data structure which consists of words and attributes of a document. It is used when an application stores a document into a database and when an application retrieves some documents from a database..PPOdeum does not provide methods to extract the text from the original data of a document. It should be implemented by applications. Although Odeum provides utilities to extract words from a text, it is oriented to such languages whose words are separated with space characters as English. If an application handles such languages which need morphological analysis or N\-gram analysis as Japanese, or if an application perform more such rarefied analysis of natural languages as stemming, its own analyzing method can be adopted. Result of search is expressed as an array contains elements which are structures composed of the ID number of documents and its score. In order to search with two or more words, Odeum provides utilities of set operations..PPOdeum is implemented, based on Curia, Cabin, and Villa. Odeum creates a database with a directory name. Some databases of Curia and Villa are placed in the specified directory. For example, `casket/docs', `casket/index', and `casket/rdocs' are created in the case that a database directory named as `casket'. `docs' is a database directory of Curia. The key of each record is the ID number of a document, and the value is such attributes as URI. `index' is a database directory of Curia. The key of each record is the normalized form of a word, and the value is an array whose element is a pair of the ID number of a document including the word and its score. `rdocs' is a database file of Villa. The key of each record is the URI of a document, and the value is its ID number..PPIn order to use Odeum, you should include `depot.h', `cabin.h', `odeum.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 <cabin.h>.br.B #include <odeum.h>.br.B #include <stdlib.h>.RE.PPA pointer to `ODEUM' is used as a database handle. A database handle is opened with the function `odopen' and closed with `odclose'. 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 `odclose' 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 file should not be used..PPA pointer to `ODDOC' is used as a document handle. A document handle is opened with the function `oddocopen' and closed with `oddocclose'. You should not refer directly to any member of the handle. A document consists of attributes and words. Each word is expressed as a pair of a normalized form and a appearance form..PPOdeum 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..PPStructures of `ODPAIR' type is used in order to handle results of search..TP.B typedef struct { int id; int score; } ODPAIR;`id' specifies the ID number of a document. `score' specifies the score calculated from the number of searching words in the document..PPThe function `odopen' is used in order to get a database handle..TP.B ODEUM *odopen(const char *name, int omode);`name' specifies the name of a database directory. `omode' specifies the connection mode: `OD_OWRITER' as a writer, `OD_OREADER' as a reader. If the mode is `OD_OWRITER', the following may be added by bitwise or: `OD_OCREAT', which means it creates a new database if not exist, `OD_OTRUNC', which means it creates a new database regardless if one exists. Both of `OD_OREADER' and `OD_OWRITER' can be added to by bitwise or: `OD_ONOLCK', which means it opens a database directory without file locking. 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 `OD_ONOLCK' is used, the application is responsible for exclusion control..PPThe function `odclose' is used in order to close a database handle..TP.B int odclose(ODEUM *odeum);`odeum' 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 `odput' is used in order to store a document..TP.B int odput(ODEUM *odeum, const ODDOC *doc, int wmax, int over);`odeum' specifies a database handle connected as a writer. `doc' specifies a document handle. `wmax' specifies the max number of words to be stored in the document database. If it is negative, the number is unlimited. `over' specifies whether the data of the duplicated document is overwritten or not. If it is false and the URI of the document is duplicated, the function returns as an error. If successful, the return value is true, else, it is false..PPThe function `odout' is used in order to delete a document specified by a URI..TP.B int odout(ODEUM *odeum, const char *uri);`odeum' specifies a database handle connected as a writer. `uri' specifies the string of the URI of a document. If successful, the return value is true, else, it is false. False is returned when no document corresponds to the specified URI..PPThe function `odoutbyid' is used in order to delete a document specified by an ID number..TP.B int odoutbyid(ODEUM *odeum, int id);`odeum' specifies a database handle connected as a writer. `id' specifies the ID number of a document. If successful, the return value is true, else, it is false. False is returned when no document corresponds to the specified ID number..PPThe function `odget' is used in order to retrieve a document specified by a URL..TP.B ODDOC *odget(ODEUM *odeum, const char *uri);`odeum' specifies a database handle. `uri' specifies the string of the URI of a document. If successful, the return value is the handle of the corresponding document, else, it is `NULL'. `NULL' is returned when no document corresponds to the specified URI. Because the handle of the return value is opened with the function `oddocopen', it should be closed with the function `oddocclose'..PPThe function `odgetbyid' is used in order to retrieve a document by an ID number..TP.B ODDOC *odgetbyid(ODEUM *odeum, int id);`odeum' specifies a database handle. `id' specifies the ID number of a document. If successful, the return value is the handle of the corresponding document, else, it is `NULL'. `NULL' is returned when no document corresponds to the specified ID number. Because the handle of the return value is opened with the function `oddocopen', it should be closed with the function `oddocclose'..PPThe function `odsearch' is used in order to search the inverted index for documents including a particular word..TP.B ODPAIR *odsearch(ODEUM *odeum, const char *word, int max, int *np);`odeum' specifies a database handle. `word' specifies a searching word. `max' specifies the max number of documents to be retrieve. `np' specifies the pointer to a variable to which the number of the elements of the return value is assigned. If successful, the return value is the pointer to an array, else, it is `NULL'. Each element of the array is a pair of the ID number and the score of a document, and sorted in descending order of their scores. Even if no document corresponds to the specified word, it is not error but returns an dummy array. 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. Note that each element of the array of the return value can be data of a deleted document..PPThe function `odsearchnum' is used in order to get the number of documents including a word..TP.B int odsearchdnum(ODEUM *odeum, const char *word);`odeum' specifies a database handle. `word' specifies a searching word. If successful, the return value is the number of documents including the word, else, it is \-1. Because this function does not read the entity of the inverted index, it is faster than `odsearch'.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -