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.