Berkeley DB Reference Guide:
Access Methods

PrevRefNext

Duplicate data items

The Btree and Hash access methods support the creation of multiple data items for a single key item. By default, multiple data items are not permitted, and each database store operation will overwrite any previous data item for that key. To configure Berkeley DB for duplicate data items, call the DB->set_flags method with the DB_DUP flag. Only one copy of the key will be stored for each set of duplicate data items. If the Btree access method comparison routine returns that two keys compare equally, it is undefined which of the two keys will be stored and returned from future database operations.

(Btree and Hash ´Â ´ÜÀÏÅ°¿¡ ´ëÇØ ¸ÖƼµ¥ÀÌŸ¾ÆÅÛÀÇ »ý¼ºÀ» Áö¿øÇÑ´Ù.µðÆúÆ®·Î ¸ÖƼµ¥ÀÌŸ ¾ÆÀÌÅÛÀº Çã¿ëµÇÁö¾Ê°í ÀúÀå¸í·ÉÀº Å°¿¡ ´ëÇÑ ÀÌÀü µ¥ÀÌŸ°ªÀ» ¿À¹ö¶óÀÌÆ®ÇÑ´Ù.Áï Å°Çϳª¿¡ ´ëÇØ ¿ÀÁ÷ ÇϳªÀÇ º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀÌ ÀְԵȴÙ.¸¸¾à BtreeÀÇ ºñ±³ ·çƾÀÌ ºñ±³µÈ µÎÅ°°¡ °°´Ù°í ¸®ÅÏÇÑ´Ù¸é µÎÅ°Áß ¾î¶²°ÍÀÌ ÀúÀåµÇ°í µðºñ¸í·ÉÀ» ÁÙ¶§ ¸®ÅϵÉÁö´Â Á¤ÀǵǾî ÀÖÁö ¾Ê´Ù.)

¡¡

By default, Berkeley DB stores duplicates in the order in which they were added, that is, each new duplicate data item will be stored after any already existing data items. This default behavior can be overridden by using the DBcursor->c_put method and one of the DB_AFTER, DB_BEFORE DB_KEYFIRST or DB_KEYLAST flags. Alternatively, Berkeley DB may be configured to sort duplicate data items.

(µðÆúÆ®·Î Ãß°¡µÈ ¼ø¼­·Î º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀ» ÀúÀåÇÑ´Ù.ÀÌ µðÆúÆ®ÇൿÀº  DBcursor->c_put (DB_AFTER, DB_BEFORE DB_KEYFIRST or DB_KEYLAST flags)·Î º¯°æ½Ãų¼ö ÀÖ´Ù.¶ÇÇÑ º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀº ¼ÒÆ®µÇµµ·Ï ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.)

¡¡

When stepping through the database sequentially, duplicate data items will be returned individually, as a key/data pair, where the key item only changes after the last duplicate data item has been returned. For this reason, duplicate data items cannot be accessed using the DB->get method, as it always returns the first of the duplicate data items. Duplicate data items should be retrieved using a Berkeley DB cursor interface such as the DBcursor->c_get method.

(µ¥ÀÌŸº£À̽º¸¦ ¿¬¼ÓÀûÀ¸·Î ¿î¿ëÇÒ¶§ º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀº key/data½ÖÀ¸·Î °¢°¢ ¸®ÅϵȴÙ.¿©±â¼­ Å°¾ÆÀÌÅÛÀº ¸¶Áö¸· º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀÌ ¸®ÅϵÈÈÄ ¿ÀÁ÷ º¯°æµÈ´Ù.ÀÌ·¯ÇÑ ÀÌÀ¯·Î º¹»çµÈ µ¥ÀÌŸ ¾ÆÀÌÅÛÀº DB->get À¸·Î Á¢±ÙÇÒ¼ö ¾ø´Ù.ÀÌ ÇÔ¼ö´Â Ç×»ó ù µ¥ÀÌŸ¾ÆÀÌÅÛÀ» ¸®ÅϽÃŲ´Ù.º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀº Ä¿¼­¸¦ »ç¿ëÇÏ´Â DBcursor->c_get ¸¦ »ç¿ëÇÏ¿© ¾ò¾î¿Í¾ß ÇÑ´Ù.)

¡¡

There is a flag that permits applications to request the following data item only if it is a duplicate data item of the current entry, see DB_NEXT_DUP for more information. There is a flag that permits applications to request the following data item only if it is not a duplicate data item of the current entry, see DB_NEXT_NODUP and DB_PREV_NODUP for more information.

(ÇöÀç ¿£Æ®¸®ÀÇ º¹»çµÈ µ¥ÀÌŸ°ªÀÎ ´ÙÀ½ µ¥ÀÌŸ¾ÆÀÌÅÛÀ» ¿äûÇÏ´Â Ç÷¡±×(DB_NEXT_DUP)°¡ ÀÖ´Ù.¶ÇÇÑ ÇöÀ翣Ʈ¸®ÀÇ º¹»çµÇÁö ¾Ê´Â °ªÀÎ ´ÙÀ½ ¾ÆÀÌÅÛÀ» ¿äûÇÏ´Â Ç÷¡±×(DB_NEXT_NODUP)°¡ ÀÖ´Ù.)

¡¡

It is also possible to maintain duplicate records in sorted order. Sorting duplicates will significantly increase performance when searching them and performing equality joins, common operations when using secondary indices. To configure Berkeley DB to sort duplicate data items, the application must call the DB->set_flags method with the DB_DUPSORT flag (in addition to the DB_DUP flag). In addition, a custom comparison function may be specified using the DB->set_dup_compare method. If the DB_DUPSORT flag is given, but no comparison routine is specified, then Berkeley DB defaults to the same lexicographical sorting used for Btree keys, with shorter items collating before longer items.

(º¹¼ÒµÈ ·¹Äڵ带 Á¤·ÄµÇ°Ô À¯ÁöÇÏ´Â °ÍÀÌ °¡´ÉÇÑ´Ù.º¹»ç°ªÀÇ ¼ÒÆÃÀº °Ë»ö,µ¿ÀÏÀû Á¶ÀÎ,¼¼ÄÁ´õ¸® ÀÎÅؽº¿¡ ´ëÇÑ µ¿ÀÛ¿¡ ´ëÇÑ ¼Óµµ¸¦ Å©°Ô Çâ»ó½ÃŲ´Ù.Ãß°¡ÀûÀ¸·Î Ä¿½ºÅÒ ºñ±³ÇÔ¼ö´Â DB->set_dup_compare¸¦ »ç¿ëÇÏ¿© ¼³Á¤°¡´ÉÇÏ´Ù.¸¸¾à  DB_DUPSORT Ç÷¡±×°¡ ÁÖ¾îÁö°í ºñ±³ÇÔ¼ö°¡ ¼³Á¤µÇÁö ¾ÊÀ¸¸é BtreeÅ°ÀÇ ¼ÒÆÿ¡»ç »ç¿ëµÇ´Â ¾Ë°í¸®ÁòÀ» µðÆúÆ®·Ñ »ç¿ëÇÑ´Ù.)

¡¡

If the duplicate data items are unsorted, applications may store identical duplicate data items, or, for those that just like the way it sounds, duplicate duplicates.

(¸¸¾à º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀÌ ¼ÒÆõÇÁö ¾ÊÀ¸¸é ¾ÖÇø®ÄÉÀ̼ÇÀº µ¿ÀÏÇÏ°Ô º¹»çµÈ µ¥ÀÌŸ ¾ÆÀÌÅÛÀ» ÀúÀåÇÒ°ÍÀÌ´Ù.Áï º¹»ç°ªÀÇ º¹»ç°ª Á¤µµ·Î »ý°¢Çصµ µÈ´Ù.)

¡¡

In this release it is an error to attempt to store identical duplicate data items when duplicates are being stored in a sorted order. This restriction is expected to be lifted in a future release. There is a flag that permits applications to disallow storing duplicate data items when the database has been configured for sorted duplicates, see DB_NODUPDATA for more information. Applications not wanting to permit duplicate duplicates in databases configured for sorted duplicates should begin using the DB_NODUPDATA flag immediately.

(ÇöÀç¹öÀü¿¡¼­´Â º¹»ç°ªÀÌ Á¤·Ä¼ø¼­·Î ÀúÀåµÇ¾úÀ»¶§ µ¿ÀÏÇÏ°Ô º¹»çµÈ µ¥ÀÌŸ¾ÆÀÌÅÛÀ» ¶Ç ÀúÀåÇÏ´Â °ÍÀº ¿¡·¯´Ù.Á¤·Äº¹»ç°ªÀ¸·Î ¼³Á¤µÇ¾úÀ»¶§ º¹»çµÈ °ªÀÌ ÀúÀåµÇÁö ¾Êµµ·Ï ÇÏ´Â Ç÷¡±×°¡ ÀÖ´Ù. DB_NODUPDATA ÂüÁ¶.Á¤·Äº¹»ç°ªÀ¸·Î ¼³Á¤µÇ¾úÀ»¶§ º¹»ç°ªÀÇ º¹»ç°ªÀ» Çã¿ëÇÏÁö ¾Ê±â¸¦ ¿øÇÏ´Â ¾ÖÇø®ÄÉÀ̼ÇÀº DB_NODUPDATA¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù.)

¡¡

For further information on how searching and insertion behaves in the presence of duplicates (sorted or not), see the DB->get, DB->put, DBcursor->c_get and DBcursor->c_put documentation.

(º¹»ç°ªÀÌ Á¸ÀçÇÒ¶§ °Ë»ö,»ðÀÔ¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ ³»¿ëÀº DB->get, DB->put, DBcursor->c_get and DBcursor->c_put documentation¸¦ ÂüÁ¶Ç϶ó)


PrevRefNext

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.