📄 faq.so
字号:
m4_comment([$Id: faq.so,v 10.26 2005/10/20 16:10:15 bostic Exp $])m4_ref_title(Access Methods, Access method FAQ, @access method FAQ, am_misc/tune, java/conf)m4_nlistbeginm4_nlist([dnlm4_bold([Is a m4_db database the same as a "table"?])m4_p([dnlYes; "tables" are databases, "rows" are key/data pairs, and "columns"are application-encapsulated fields within a data item (to which m4_dbdoes not directly provide access).])])m4_nlist([dnlm4_bold([I'm getting an error return in my application, but I can'tfigure out what the library is complaining about.])m4_p([dnlSee m4_ref(dbenv_set_errcall), m4_ref(dbenv_set_errfile) andm4_ref(dbh_set_errfile) for ways to get additional information abouterror returns from m4_db.])])m4_nlist([dnlm4_bold([Are m4_db databases portable between architectures?])m4_p([dnlYes. See m4_link(M4RELDIR/ref/am_conf/byteorder, [Selecting a byteorder]) for more information.])])m4_nlist([dnlm4_bold([I'm seeing database corruption when creating multiple databasesin a single physical file.])m4_p([dnlThis problem is usually the result of m4_ref(Db) handles not sharing anunderlying database environment. See m4_link(M4RELDIR/ref/am/opensub,[Opening multiple databases in a single file]) for more information.])])m4_nlist([dnlm4_bold([I'm using integers as keys for a Btree database, and eventhough the key/data pairs are entered in sorted order, the page-fillfactor is low.])m4_p([dnlThis is usually the result of using integer keys on little-endianarchitectures such as the x86. m4_db sorts keys as byte strings, andlittle-endian integers don't sort well when viewed as byte strings.For example, take the numbers 254 through 257. Their byte patterns ona little-endian system are:])m4_indent([dnl254 fe 0 0 0255 ff 0 0 0256 0 1 0 0257 1 1 0 0])m4_p([dnlIf you treat them as strings, then they sort badly:])m4_indent([dnl256257254255])m4_p([dnlOn a big-endian system, their byte patterns are:])m4_indent([dnl254 0 0 0 fe255 0 0 0 ff256 0 0 1 0257 0 0 1 1])m4_p([dnland so, if you treat them as strings they sort nicely. Which means, ifyou use steadily increasing integers as keys on a big-endian systemm4_db behaves well and you get compact trees, but on a little-endiansystem m4_db produces much less compact trees. To avoid this problem,you may want to convert the keys to flat text or big-endianrepresentations, or provide your ownm4_link(M4RELDIR/ref/am_conf/bt_compare, [Btree comparison function.])])])m4_idefz(double buffering)m4_nlist([dnlm4_bold([Is there any way to avoid double buffering in the m4_db system?])m4_p([dnlWhile you cannot avoid double buffering entirely, there are a few thingsyou can do to address this issue:])m4_p([dnlFirst, the m4_db cache size can be explicitly set. Rather than allocateadditional space in the m4_db cache to cover unexpectedly heavy load orlarge table sizes, double buffering may suggest you size the cache tofunction well under normal conditions, and then depend on the filebuffer cache to cover abnormal conditions. Obviously, this is atrade-off, as m4_db may not then perform as well as usual under abnormalconditions.])m4_p([dnlSecond, depending on the underlying operating system you're using, youmay be able to alter the amount of physical memory devoted to thesystem's file buffer cache. Altering this type of resourceconfiguration may require appropriate privileges, or even operatingsystem reboots and/or rebuilds, on some systems.])m4_p([dnlThird, changing the size of the m4_db environment regions can changethe amount of space the operating system makes available for the filebuffer cache, and it's often worth considering exactly how the operatingsystem is dividing up its available memory. Further, moving the m4_dbdatabase environment regions from filesystem backed memory into systemmemory (or heap memory), can often make additional system memoryavailable for the file buffer cache, especially on systems without aunified buffer cache and VM system.])m4_p([dnlFinally, for operating systems that allow buffering to be turned off,specifying the m4_ref(DB_DIRECT_DB) and m4_ref(DB_DIRECT_LOG) flagswill attempt to do so.])])m4_nlist([dnlm4_bold([I'm seeing database corruption when I run out of disk space.])m4_p([dnlm4_db can continue to run when when out-of-disk-space errors occur, butit requires the application to be transaction protected. Applicationswhich do not enclose update operations in transactions cannot recoverfrom out-of-disk-space errors, and the result of running out of diskspace may be database corruption.])])m4_nlist([dnlm4_bold([How can I associate application information with a m4_ref(Db)or m4_ref(DbEnv) handle?])m4_p([dnlIn the C API, the m4_ref(Db) and m4_ref(DbEnv) structures each containan "app_private" field intended to be used to referenceapplication-specific information. See the m4_ref(dbh_create) andm4_ref(dbenv_create) documentation for more information.])m4_p([dnlIn the C++ or Java APIs, the easiest way to associateapplication-specific data with a handle is to subclass the m4_refcxx(Db)or m4_refcxx(DbEnv), for example subclassing m4_refcxx(Db) to get MyDb.Objects of type MyDb will still have the m4_db API methods available onthem, and you can put any extra data or methods you want into the MyDbclass. If you are using "callback" APIs that take m4_refcxx(Db) orm4_refcxx(DbEnv) arguments (for example, m4_refcxx(dbh_set_bt_compare))these will always be called with the m4_refcxx(Db) or m4_refcxx(DbEnv)objects you create. So if you always use MyDb objects, you will be ableto take the first argument to the callback function and cast it to aMyDb (in C++, cast it to (MyDb*)). That will allow you to access yourdata members or methods.])])m4_nlistendm4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -