Class: Estraier::Database
- Inherits:
-
Object
- Object
- Estraier::Database
- Defined in:
- lib/estraier/estraier-doc.rb
Overview
++ Abstraction of database.
Constant Summary collapse
- VERSION =
version of Hyper Estraier
"0.0.0"
- ERRNOERR =
error code: no error
0
- ERRINVAL =
error code: invalid argument
1
- ERRACCES =
error code: access forbidden
2
- ERRLOCK =
error code: lock failure
3
- ERRDB =
error code: database problem
4
- ERRIO =
error code: I/O problem
5
- ERRNOITEM =
error code: no item
6
- ERRMISC =
error code: miscellaneous
9999
- DBREADER =
open mode: open as a reader
1 << 0
- DBWRITER =
open mode: open as a writer
1 << 1
- DBCREAT =
open mode: a writer creating
1 << 2
- DBTRUNC =
open mode: a writer truncating
1 << 3
- DBNOLCK =
open mode: open without locking
1 << 4
- DBLCKNB =
open mode: lock without blocking
1 << 5
- DBPERFNG =
open mode: use perfect N-gram analyzer
1 << 10
- DBCHRCAT =
open mode: use character category analyzer
1 << 11
- DBSMALL =
open mode: small tuning
1 << 20
- DBLARGE =
open mode: large tuning
1 << 21
- DBHUGE =
open mode: huge tuning
1 << 22
- DBHUGE2 =
open mode: huge tuning second
1 << 23
- DBHUGE3 =
open mode: huge tuning third
1 << 24
- DBSCVOID =
open mode: store scores as void
1 << 25
- DBSCINT =
open mode: store scores as integer
1 << 26
- DBSCASIS =
open mode: refrain from adjustment of scores
1 << 27
- IDXATTRSEQ =
attribute index type: for multipurpose sequencial access method
0
- IDXATTRSTR =
attribute index type: for narrowing with attributes as strings
1
- IDXATTRNUM =
attribute index type: for narrowing with attributes as numbers
2
- OPTNOPURGE =
optimize option: omit purging dispensable region of deleted
1 << 0
- OPTNODBOPT =
optimize option: omit optimization of the database files
1 << 1
- MGCLEAN =
merge option: clean up dispensable regions
1 << 0
- PDCLEAN =
put_doc option: clean up dispensable regions
1 << 0
- PDWEIGHT =
put_doc option: weight scores statically when indexing
1 << 1
- ODCLEAN =
out_doc option: clean up dispensable regions
1 << 0
- GDNOATTR =
get_doc option: no attributes
1 << 0
- GDNOTEXT =
get_doc option: no text
1 << 1
- GDNOKWD =
get_doc option: no keywords
1 << 2
Class Method Summary collapse
-
.search_meta(dbs, cond) ⇒ Object
Search plural databases for documents corresponding a condition.
Instance Method Summary collapse
-
#add_attr_index(name, type) ⇒ Object
Add an index for narrowing or sorting with document attributes.
-
#add_pseudo_index(path) ⇒ Object
Add a pseudo index directory.
-
#close ⇒ Object
Close the database.
-
#doc_num ⇒ Object
Get the number of documents.
-
#edit_doc(doc) ⇒ Object
Edit attributes of a document.
-
#err_msg(ecode) ⇒ Object
Get the string of an error code.
-
#error ⇒ Object
Get the last happened error code.
-
#fatal ⇒ Object
Check whether the database has a fatal error.
-
#flush(max) ⇒ Object
Flush index words in the cache.
-
#get_doc(id, options) ⇒ Object
Retrieve a document.
-
#get_doc_attr(id, name) ⇒ Object
Retrieve the value of an attribute of a document.
-
#merge(name, options) ⇒ Object
Merge another database.
-
#name ⇒ Object
Get the name.
-
#open(name, omode) ⇒ Object
Open a database.
-
#optimize(options) ⇒ Object
Optimize the database.
-
#out_doc(id, options) ⇒ Object
Remove a document.
-
#put_doc(doc, options) ⇒ Object
Add a document.
-
#scan_doc(doc, cond) ⇒ Object
Check whether a document object matches the phrase of a search condition object definitely.
-
#search(cond) ⇒ Object
Search for documents corresponding a condition.
-
#set_cache_size(size, anum, tnum, rnum) ⇒ Object
Set the maximum size of the cache memory.
-
#set_informer(informer) ⇒ Object
Set the callback function to inform of database events.
-
#set_wildmax(num) ⇒ Object
Set the maximum number of expansion of wild cards.
-
#size ⇒ Object
Get the size.
-
#sync ⇒ Object
Synchronize updating contents.
-
#uri_to_id(uri) ⇒ Object
Get the ID of a document specified by URI.
-
#word_num ⇒ Object
Get the number of unique words.
Class Method Details
.search_meta(dbs, cond) ⇒ Object
Search plural databases for documents corresponding a condition. ‘dbs’ specifies an array whose elements are database objects. ‘cond’ specifies a condition object. The return value is a result object. On error, ‘nil’ is returned.
399 400 401 |
# File 'lib/estraier/estraier-doc.rb', line 399 def self.(dbs, cond) # native code ... end |
Instance Method Details
#add_attr_index(name, type) ⇒ Object
Add an index for narrowing or sorting with document attributes. ‘name’ specifies the name of an attribute. ‘type’ specifies the data type of attribute index; ‘Database::IDXATTRSEQ’ for multipurpose sequencial access method, ‘Database::IDXATTRSTR’ for narrowing with attributes as strings, ‘Database::IDXATTRNUM’ for narrowing with attributes as numbers. The return value is true if success, else it is false.
458 459 460 |
# File 'lib/estraier/estraier-doc.rb', line 458 def add_attr_index(name, type) # native code ... end |
#add_pseudo_index(path) ⇒ Object
Add a pseudo index directory. ‘path’ specifies the path of a pseudo index directory. The return value is true if success, else it is false.
583 584 585 |
# File 'lib/estraier/estraier-doc.rb', line 583 def add_pseudo_index(path) # native code ... end |
#close ⇒ Object
Close the database. The return value is true if success, else it is false.
439 440 441 |
# File 'lib/estraier/estraier-doc.rb', line 439 def close() # native code ... end |
#doc_num ⇒ Object
Get the number of documents. The return value is the number of documents in the database.
540 541 542 |
# File 'lib/estraier/estraier-doc.rb', line 540 def doc_num() # native code ... end |
#edit_doc(doc) ⇒ Object
Edit attributes of a document. ‘doc’ specifies a document object. The return value is true if success, else it is false.
508 509 510 |
# File 'lib/estraier/estraier-doc.rb', line 508 def edit_doc(doc) # native code ... end |
#err_msg(ecode) ⇒ Object
Get the string of an error code. ‘ecode’ specifies an error code. The return value is the string of the error code.
409 410 411 |
# File 'lib/estraier/estraier-doc.rb', line 409 def err_msg(ecode) # native code ... end |
#error ⇒ Object
Get the last happened error code. The return value is the last happened error code.
444 445 446 |
# File 'lib/estraier/estraier-doc.rb', line 444 def error() # native code ... end |
#fatal ⇒ Object
Check whether the database has a fatal error. The return value is true if the database has fatal erroor, else it is false.
449 450 451 |
# File 'lib/estraier/estraier-doc.rb', line 449 def fatal() # native code ... end |
#flush(max) ⇒ Object
Flush index words in the cache. ‘max’ specifies the maximum number of words to be flushed. If it not more than zero, all words are flushed. The return value is true if success, else it is false.
465 466 467 |
# File 'lib/estraier/estraier-doc.rb', line 465 def flush(max) # native code ... end |
#get_doc(id, options) ⇒ Object
Retrieve a document. ‘id’ specifies the ID number of a registered document. ‘options’ specifies options: ‘Database::GDNOATTR’ to ignore attributes, ‘Database::GDNOTEXT’ to ignore the body text, ‘Database::GDNOKWD’ to ignore keywords. The three can be specified at the same time by bitwise or. The return value is a document object. On error, ‘nil’ is returned.
517 518 519 |
# File 'lib/estraier/estraier-doc.rb', line 517 def get_doc(id, ) # native code ... end |
#get_doc_attr(id, name) ⇒ Object
Retrieve the value of an attribute of a document. ‘id’ specifies the ID number of a registered document. ‘name’ specifies the name of an attribute. The return value is the value of the attribute or ‘nil’ if it does not exist.
524 525 526 |
# File 'lib/estraier/estraier-doc.rb', line 524 def get_doc_attr(id, name) # native code ... end |
#merge(name, options) ⇒ Object
Merge another database. ‘name’ specifies the name of another database directory. ‘options’ specifies options: ‘Database::MGCLEAN’ to clean up dispensable regions of the deleted document. The return value is true if success, else it is false.
486 487 488 |
# File 'lib/estraier/estraier-doc.rb', line 486 def merge(name, ) # native code ... end |
#name ⇒ Object
Get the name. The return value is the name of the database.
535 536 537 |
# File 'lib/estraier/estraier-doc.rb', line 535 def name() # native code ... end |
#open(name, omode) ⇒ Object
Open a database. ‘name’ specifies the name of a database directory. ‘omode’ specifies open modes: ‘Database::DBWRITER’ as a writer, ‘Database::DBREADER’ as a reader. If the mode is ‘Database::DBWRITER’, the following may be added by bitwise or: ‘Database::DBCREAT’, which means it creates a new database if not exist, ‘Database::DBTRUNC’, which means it creates a new database regardless if one exists. Both of ‘Database::DBREADER’ and ‘Database::DBWRITER’ can be added to by bitwise or: ‘Database::DBNOLCK’, which means it opens a database file without file locking, or ‘Database::DBLCKNB’, which means locking is performed without blocking. If ‘Database::DBNOLCK’ is used, the application is responsible for exclusion control. ‘Database::DBCREAT’ can be added to by bitwise or: ‘Database::DBPERFNG’, which means N-gram analysis is performed against European text also, ‘Database::DBCHACAT’, which means character category analysis is performed instead of N-gram analysis, ‘Database::DBSMALL’, which means the index is tuned to register less than 50000 documents, ‘Database::DBLARGE’, which means the index is tuned to register more than 300000 documents, ‘Database::DBHUGE’, which means the index is tuned to register more than 1000000 documents, ‘Database::DBHUGE2’, which means the index is tuned to register more than 5000000 documents, ‘Database::DBHUGE3’, which means the index is tuned to register more than 10000000 documents, ‘Database::DBSCVOID’, which means scores are stored as void, ‘Database::DBSCINT’, which means scores are stored as 32-bit integer, ‘Database::DBSCASIS’, which means scores are stored as-is and marked not to be tuned when search. The return value is true if success, else it is false.
434 435 436 |
# File 'lib/estraier/estraier-doc.rb', line 434 def open(name, omode) # native code ... end |
#optimize(options) ⇒ Object
Optimize the database. ‘options’ specifies options: ‘Database::OPTNOPURGE’ to omit purging dispensable region of deleted documents, ‘Database::OPTNODBOPT’ to omit optimization of the database files. The two can be specified at the same time by bitwise or. The return value is true if success, else it is false.
478 479 480 |
# File 'lib/estraier/estraier-doc.rb', line 478 def optimize() # native code ... end |
#out_doc(id, options) ⇒ Object
Remove a document. ‘id’ specifies the ID number of a registered document. ‘options’ specifies options: ‘Database::ODCLEAN’ to clean up dispensable regions of the deleted document. The return value is true if success, else it is false.
502 503 504 |
# File 'lib/estraier/estraier-doc.rb', line 502 def out_doc(id, ) # native code ... end |
#put_doc(doc, options) ⇒ Object
Add a document. ‘doc’ specifies a document object. The document object should have the URI attribute. ‘options’ specifies options: ‘Database::PDCLEAN’ to clean up dispensable regions of the overwritten document. The return value is true if success, else it is false.
494 495 496 |
# File 'lib/estraier/estraier-doc.rb', line 494 def put_doc(doc, ) # native code ... end |
#scan_doc(doc, cond) ⇒ Object
Check whether a document object matches the phrase of a search condition object definitely. ‘doc’ specifies a document object. ‘cond’ specifies a search condition object. The return value is true if the document matches the phrase of the condition object definitely, else it is false.
564 565 566 |
# File 'lib/estraier/estraier-doc.rb', line 564 def scan_doc(doc, cond) # native code ... end |
#search(cond) ⇒ Object
Search for documents corresponding a condition. ‘cond’ specifies a condition object. The return value is a result object. On error, ‘nil’ is returned.
556 557 558 |
# File 'lib/estraier/estraier-doc.rb', line 556 def search(cond) # native code ... end |
#set_cache_size(size, anum, tnum, rnum) ⇒ Object
Set the maximum size of the cache memory. ‘size’ specifies the maximum size of the index cache. By default, it is 64MB. If it is not more than 0, the current size is not changed. ‘anum’ specifies the maximum number of cached records for document attributes. By default, it is 8192. If it is not more than 0, the current size is not changed. ‘tnum’ specifies the maximum number of cached records for document texts. By default, it is 1024. If it is not more than 0, the current size is not changed. ‘rnum’ specifies the maximum number of cached records for occurrence results. By default, it is 256. If it is not more than 0, the current size is not changed. The return value is always ‘nil’.
577 578 579 |
# File 'lib/estraier/estraier-doc.rb', line 577 def set_cache_size(size, anum, tnum, rnum) # native code ... end |
#set_informer(informer) ⇒ Object
Set the callback function to inform of database events. ‘informer’ specifies an arbitrary object with a method named as ‘inform’. The method should have one parameter for a string of a message of each event. The return value is always ‘nil’.
596 597 598 |
# File 'lib/estraier/estraier-doc.rb', line 596 def set_informer(informer) # native code ... end |
#set_wildmax(num) ⇒ Object
Set the maximum number of expansion of wild cards. ‘num’ specifies the maximum number of expansion of wild cards. The return value is always ‘nil’.
589 590 591 |
# File 'lib/estraier/estraier-doc.rb', line 589 def set_wildmax(num) # native code ... end |
#size ⇒ Object
Get the size. The return value is the size of the database.
550 551 552 |
# File 'lib/estraier/estraier-doc.rb', line 550 def size() # native code ... end |
#sync ⇒ Object
Synchronize updating contents. The return value is true if success, else it is false.
470 471 472 |
# File 'lib/estraier/estraier-doc.rb', line 470 def sync() # native code ... end |
#uri_to_id(uri) ⇒ Object
Get the ID of a document specified by URI. ‘uri’ specifies the URI of a registered document. The return value is the ID of the document. On error, -1 is returned.
530 531 532 |
# File 'lib/estraier/estraier-doc.rb', line 530 def uri_to_id(uri) # native code ... end |
#word_num ⇒ Object
Get the number of unique words. The return value is the number of unique words in the database.
545 546 547 |
# File 'lib/estraier/estraier-doc.rb', line 545 def word_num() # native code ... end |