📄 get_bulk.so
字号:
m4_comment([$Id: get_bulk.so,v 10.7 2004/09/03 19:47:57 mjc Exp $])define(BDB_LOC, ..)m4_ref_title(Access Methods, Retrieving records in bulk, @retrieving records in bulk, am_misc/align, am_misc/partial)m4_p([dnlWhen retrieving large numbers of records from the database, the numberof method calls can often dominate performance. m4_db offers bulk getinterfaces which can significantly increase performance for someapplications. To retrieve records in bulk, an application buffer mustbe specified to the m4_ref(dbh_get) or m4_refT(dbc_get)s. This is donein the C API by setting the m4_arg(data) and m4_arg(ulen) fields of them4_arg(data) m4_ref(Dbt) to reference an application buffer, and them4_arg(flags) field of that structure to m4_ref(DB_DBT_USERMEM). Inthe m4_db C++ and Java APIs, the actions are similar, although thereare API-specific methods to set the m4_ref(Dbt) values. Then, them4_ref(DB_MULTIPLE) or m4_ref(DB_MULTIPLE_KEY) flags are specified tothe m4_ref(dbh_get) or m4_refT(dbc_get)s, which cause multiple recordsto be returned in the specified buffer.])m4_p([dnlThe difference between m4_ref(DB_MULTIPLE) and m4_ref(DB_MULTIPLE_KEY)is as follows: m4_ref(DB_MULTIPLE) returns multiple data items for asingle key. For example, the m4_ref(DB_MULTIPLE) flag would be used toretrieve all of the duplicate data items for a single key in a singlecall. The m4_ref(DB_MULTIPLE_KEY) flag is used to retrieve multiplekey/data pairs, where each returned key may or may not have duplicatedata items.])m4_p([dnlOnce the m4_ref(dbh_get) or m4_refT(dbc_get) has returned, theapplication will walk through the buffer handling the returned records.This is implemented for the C and C++ APIs using four macros:m4_ref(DB_MULTIPLE_INIT), m4_ref(DB_MULTIPLE_NEXT),m4_ref(DB_MULTIPLE_KEY_NEXT), and m4_ref(DB_MULTIPLE_RECNO_NEXT). Forthe Java API, this is implemented as three iterator classes:m4_linkjavadoc(com.sleepycat.db, MultipleDataEntry),m4_linkjavadoc(com.sleepycat.db, MultipleKeyDataEntry), andm4_linkjavadoc(com.sleepycat.db, MultipleRecnoDataEntry).])m4_p([dnlThe m4_ref(DB_MULTIPLE_INIT) macro is always called first. Itinitializes a local application variable and the m4_arg(data)m4_ref(Dbt) for stepping through the set of returned records. Then,the application calls one of the remaining three macros:m4_ref(DB_MULTIPLE_NEXT), m4_ref(DB_MULTIPLE_KEY_NEXT), andm4_ref(DB_MULTIPLE_RECNO_NEXT).])m4_p([dnlIf the m4_ref(DB_MULTIPLE) flag was specified to the m4_ref(dbh_get) orm4_refT(dbc_get), the application will always call them4_ref(DB_MULTIPLE_NEXT) macro. If the m4_ref(DB_MULTIPLE_KEY) flagwas specified to the m4_ref(dbh_get) or m4_refT(dbc_get), and, theunderlying database is a Btree or Hash database, the application willalways call the m4_ref(DB_MULTIPLE_KEY_NEXT) macro. If them4_ref(DB_MULTIPLE_KEY) flag was specified to the m4_ref(dbh_get) orm4_refT(dbc_get), and, the underlying database is a Queue or Recnodatabase, the application will always call them4_ref(DB_MULTIPLE_RECNO_NEXT) macro. The m4_ref(DB_MULTIPLE_NEXT),m4_ref(DB_MULTIPLE_KEY_NEXT), and m4_ref(DB_MULTIPLE_RECNO_NEXT) macrosare called repeatedly, until the end of the returned records is reached.The end of the returned records is detected by the application's localpointer variable being set to NULL.])m4_p([dnlThe following is an example of a routine that displays the contents ofa Btree database using the bulk return interfaces.])include(ref/am_misc/get_bulk.cs)m4_page_footer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -