NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CBDB_PropertyDictionary< PropKey, PropValue > Class Template Reference

Search Toolkit Book for CBDB_PropertyDictionary

#include <db/bdb/bdb_bv_property_store.hpp>

+ Inheritance diagram for CBDB_PropertyDictionary< PropKey, PropValue >:
+ Collaboration diagram for CBDB_PropertyDictionary< PropKey, PropValue >:

Public Types

typedef pair< PropKey, PropValue > TKey
 
typedef Uint4 TKeyId
 
- Public Types inherited from CBDB_File
enum  EAfterWrite { eKeepData , eDiscardData }
 
typedef int TUnifiedFieldIndex
 CBDB_File keeps data in two buffers (key buffer and data buffer). More...
 
- Public Types inherited from CBDB_RawFile
enum  EOpenMode { eReadWrite , eReadOnly , eCreate , eReadWriteCreate }
 BDB file open mode. More...
 
enum  EDBType { eBtree , eQueue , eHash }
 Berkeley DB database type. More...
 
enum  EReallocMode { eReallocAllowed , eReallocForbidden }
 BLOB read mode, controld data buffer reallocation when there is not enough space in buffer. More...
 
enum  EDuplicateKeys { eDuplicatesDisable , eDuplicatesEnable }
 Control key duplicates in Btree. More...
 
enum  EIgnoreError { eIgnoreError , eThrowOnError }
 
enum  ECompact { eCompactNoFree , eCompactFreeExisting , eCompactFreeAll }
 BerkeleyDB compaction methods and flags. More...
 
enum  ECachePriority {
  eCache_Lowest , eCache_Low , eCache_Default , eCache_High ,
  eCache_Highest
}
 Set the priority for this database's pages in the buffer cache This is generally a temporary advisement, and works only if an environment is used. More...
 
typedef CSimpleBuffer TBuffer
 typedef for raw buffer operations More...
 
typedef bool(* FContinueCompact) (void)
 Extended version of compact This version performs iterative compacting and uses a callback to request an exit. More...
 

Public Member Functions

 CBDB_PropertyDictionary ()
 
TKey GetCurrentKey () const
 
TKeyId GetCurrentUid () const
 
TKeyId GetMaxUid () const
 
EBDB_ErrCode Read (TKeyId *key_idx)
 
EBDB_ErrCode Read (const TKey &key, TKeyId *key_idx)
 
EBDB_ErrCode Read (const PropKey &prop, const PropValue &value, TKeyId *key_idx)
 
EBDB_ErrCode Write (const TKey &key, TKeyId key_idx)
 
EBDB_ErrCode Write (const PropKey &prop, const PropValue &value, TKeyId key_idx)
 
Interface required for split dictionary store
Uint4 GetKey (const TKey &key)
 
Uint4 PutKey (const TKey &key)
 
- Public Member Functions inherited from CBDB_File
 CBDB_File (EDuplicateKeys dup_keys=eDuplicatesDisable, EDBType db_type=eBtree)
 
void Open (const string &filename, EOpenMode open_mode, bool support_dirty_read=false, unsigned rec_len=0)
 Open file with specified access mode. More...
 
void Open (const string &filename, const string &database, EOpenMode open_mode, bool support_dirty_read=false, unsigned rec_len=0)
 Open file with specified filename and database name. More...
 
void Reopen (EOpenMode open_mode, bool support_dirty_read=false)
 Reopen the db file. More...
 
void Attach (CBDB_File &db_file)
 Attach external Berkeley DB file. More...
 
EBDB_ErrCode Fetch ()
 Fetches the record corresponding to the current key value. More...
 
EBDB_ErrCode FetchForUpdate ()
 Fetche the record corresponding to the current key value. More...
 
EBDB_ErrCode Insert (EAfterWrite write_flag=eDiscardData)
 Insert new record. More...
 
unsigned Append (EAfterWrite write_flag=eDiscardData)
 Append record to the queue (works only for DB_QUEUE database type) More...
 
EBDB_ErrCode Delete (EIgnoreError on_error=eThrowOnError)
 Delete record corresponding to the current key value. More...
 
EBDB_ErrCode UpdateInsert (EAfterWrite write_flag=eDiscardData)
 Update record corresponding to the current key value. More...
 
void BindKey (const char *field_name, CBDB_Field *key_field, size_t buf_size=0)
 
void BindData (const char *field_name, CBDB_Field *data_field, size_t buf_size=0, ENullable is_null=eNullable)
 
void DuplicateStructure (const CBDB_File &dbf)
 Create the same fieldset as in dbf and bind them to the current file. More...
 
const CBDB_BufferManagerGetKeyBuffer () const
 Get Buffer manager for key section of the file. More...
 
const CBDB_BufferManagerGetDataBuffer () const
 Get Buffer manager for data section of the file. More...
 
CBDB_BufferManagerGetKeyBuffer ()
 Get Buffer manager for key section of the file. More...
 
CBDB_BufferManagerGetDataBuffer ()
 Get Buffer manager for data section of the file. More...
 
void SetFieldCompareLimit (unsigned int n_fields)
 Sets maximum number of key fields participating in comparison Should be less than total number of key fields. More...
 
DBTCloneDBT_Key ()
 Create new copy of m_DBT_Key. More...
 
void SetLegacyStringsCheck (bool value)
 Set C-str detection. More...
 
TUnifiedFieldIndex GetFieldIdx (const string &name) const
 Get field index by name. More...
 
const CBDB_FieldGetField (TUnifiedFieldIndex idx) const
 Return field by field index. More...
 
CBDB_FieldGetField (TUnifiedFieldIndex idx)
 
void SetFieldOwnership (bool own_fields)
 Fields deletion is managed by the class when own_fields is TRUE. More...
 
bool IsOwnFields () const
 Return fields ownership flag. More...
 
void CopyFrom (const CBDB_File &dbf)
 Copy record (fields) from another BDB file (MUST have the same structure) More...
 
void Verify (const char *filename, const char *database, FILE *backup)
 Run database verification (DB->verify) More...
 
void EnablePrefixCompression ()
 Turn ON prefix compression. More...
 
- Public Member Functions inherited from CBDB_RawFile
 CBDB_RawFile (EDuplicateKeys dup_keys=eDuplicatesDisable, EDBType db_type=eBtree)
 
virtual ~CBDB_RawFile ()
 
void SetEnv (CBDB_Env &env)
 Associate file with environment. More...
 
CBDB_EnvGetEnv ()
 Get pointer on file environment Return NULL if no environment has been set. More...
 
void Open (const string &filename, EOpenMode open_mode, bool support_dirty_read=false, unsigned rec_len=0)
 Open file with specified access mode. More...
 
void Open (const string &filename, const string &database, EOpenMode open_mode, bool support_dirty_read=false, unsigned rec_len=0)
 Open file with specified filename and database name. More...
 
void Attach (CBDB_RawFile &bdb_file)
 Attach class to external BerkeleyDB file instance. More...
 
void Close ()
 Close file. More...
 
void Reopen (EOpenMode open_mode, bool support_dirty_read=false, unsigned rec_len=0)
 Reopen database file. (Should be already open). More...
 
void Remove (const string &filename, const string &database=kEmptyStr)
 Remove the database specified by the filename and database arguments. More...
 
unsigned int Truncate ()
 Empty the database. Return number of records removed. More...
 
unsigned int SafeTruncate ()
 Workaround for truncate of large databases. More...
 
void Rename (const string &fname, const string &old_name, const string &new_name)
 Rename a database. NOTE: This cannot be called on an opened file. More...
 
void Compact (ECompact compact_type=eCompactNoFree, int target_fill_pct=0)
 Compact the database. More...
 
void CompactEx (FContinueCompact compact_callback, ECompact compact_type=eCompactNoFree, int target_fill_pct=0)
 
void SetPageSize (unsigned int page_size)
 
unsigned int GetPageSize ()
 
void SetCacheSize (unsigned int cache_size)
 Set Berkeley DB memory cache size for the file (default is 256K). More...
 
void RevSplitOff ()
 Turn OFF reverse splitting. More...
 
void DisableCmpOverride ()
 Disable BTREE comparison override. More...
 
void SetCachePriority (ECachePriority priority)
 
const stringFileName () const
 
const stringDatabase () const
 
virtual void SetHash (DB *)
 Set hash function. More...
 
bool IsOpen () const
 Return TRUE if the file is open. More...
 
bool IsAttached () const
 
bool IsByteSwapped () const
 Return TRUE if the if the underlying database files were created on an architecture of the different byte order. More...
 
bool DuplicatesAllowed () const
 Return TRUE if file can contain duplicate keys. More...
 
EDuplicateKeys GetDupKeysMode () const
 Return the key duplicate mode value. More...
 
const stringGetFileName () const
 Return file name. More...
 
EOpenMode GetOpenMode () const
 Return the file open mode. More...
 
void Sync ()
 Flush any cached information to disk. More...
 
unsigned CountRecs (bool bFast=false)
 Compute database statistic, return number of records. More...
 
void PrintStat (CNcbiOstream &out)
 Print database statistics. More...
 
virtual void SetTransaction (ITransaction *trans)
 Establish transaction association. More...
 
virtual void RemoveTransaction (ITransaction *trans)
 Remove transaction association (must be established by SetTransaction. More...
 
virtual ITransactionGetTransaction ()
 Get current transaction. More...
 
CBDB_TransactionGetBDBTransaction ()
 Get current transaction. More...
 
unsigned GetRecLen () const
 Get record length Works for fixed length record DBs only (Queue) More...
 
void SetHashFillFactor (unsigned h_ffactor)
 Set hash table density (fill factor) More...
 
void SetHashNelem (unsigned h_nelem)
 Set an estimate of hash table final size. More...
 
void DisableHashOverride ()
 Disable hash method override (Berkeley DB will use it's own default hashing method) More...
 
void SetBtreeMinKeysPerPage (unsigned int keys_per_page)
 Set the minimum number of keys per page (BTREE access methods only) More...
 
unsigned int GetBtreeMinKeysPerPage ()
 
void SetCompressor (ICompression *compressor, EOwnership own=eTakeOwnership)
 Set record compressor. More...
 
- Public Member Functions inherited from ITransactional
virtual ~ITransactional ()
 

Protected Attributes

TKeyId m_MaxUid
 
- Protected Attributes inherited from CBDB_RawFile
EDBType m_DB_Type
 
DBm_DB
 
DBTm_DBT_Key
 
DBTm_DBT_Data
 
CBDB_Envm_Env
 
CBDB_Transactionm_Trans
 
int m_TransAssociation
 
unsigned m_RecLen
 
unsigned m_H_ffactor
 
unsigned m_H_nelem
 
unsigned m_BT_minkey
 
AutoPtr< ICompressionm_Compressor
 Record compressor. More...
 
TBuffer m_CompressBuffer
 

Private Member Functions

 CBDB_PropertyDictionary (const CBDB_PropertyDictionary< PropKey, PropValue > &)
 forbidden More...
 
CBDB_PropertyDictionaryoperator= (const CBDB_PropertyDictionary< PropKey, PropValue > &)
 

Private Attributes

SBDB_TypeTraits< PropKey >::TFieldType m_PropKey
 
SBDB_TypeTraits< PropValue >::TFieldType m_PropVal
 
SBDB_TypeTraits< TKeyId >::TFieldType m_Uid
 

Additional Inherited Members

- Static Public Member Functions inherited from CBDB_File
static void DestroyDBT_Clone (DBT *dbt)
 Free the DBT structure created by CloneDBT_Key. More...
 
- Static Public Attributes inherited from CBDB_RawFile
static const char kDefaultDatabase [] = "_table"
 
- Protected Member Functions inherited from CBDB_File
void Discard ()
 Unpack internal record buffers. More...
 
virtual void SetCmp (DB *)
 Set comparison function. More...
 
EBDB_ErrCode ReadCursor (DBC *dbc, unsigned int bdb_flag)
 Read DB cursor. More...
 
EBDB_ErrCode ReadCursor (DBC *dbc, unsigned int bdb_flag, void **buf, size_t buf_size, EReallocMode allow_realloc)
 Read DB cursor (BLOB) More...
 
EBDB_ErrCode ReadCursor (DBC *dbc, unsigned int bdb_flag, TBuffer *buf)
 Read DB cursor (BLOB) More...
 
EBDB_ErrCode ReadCursor (DBC *dbc, unsigned int bdb_flag, CBDB_MultiRowBuffer *multirow_buf, bool multirow_only)
 Multiple-row read into a buffer Buffer is to be traversed using DB_MULTIPLE_KEY_NEXT (BerkeleyDB) More...
 
EBDB_ErrCode WriteCursor (DBC *dbc, unsigned int bdb_flag, EAfterWrite write_flag)
 Write DB cursor. More...
 
EBDB_ErrCode WriteCursor (const void *data, size_t size, DBC *dbc, unsigned int bdb_flag, EAfterWrite write_flag)
 Write BLOB to DB cursor. More...
 
EBDB_ErrCode DeleteCursor (DBC *dbc, EIgnoreError)
 Delete DB cursor. More...
 
void CheckNullDataConstraint () const
 Check if all NOT NULL fields are assigned. More...
 
void DisableDataBufProcessing ()
 Function disables processing of m_DBT_data. More...
 
void DisableNull ()
 Disable NULL/not NULL in data fields (Performance tweak, call before BindData) More...
 
void DisableDataPacking ()
 Disable packing of variable length fields in the data buffer (Call after BindData) More...
 
EBDB_ErrCode x_Fetch (unsigned int flags)
 Wrapper around get operation. More...
 
virtual void x_SetByteSwapped (bool bswp)
 Set byte order swapping. More...
 
- Protected Member Functions inherited from CBDB_RawFile
void x_Open (const char *filename, const char *database, EOpenMode open_mode, bool support_dirty_read, unsigned rec_len)
 
void x_Create (const char *filename, const char *database)
 
void x_Close (EIgnoreError close_mode)
 
void x_CreateDB (unsigned rec_len)
 Create m_DB member, set page, cache parameters. More...
 
void x_SetTransaction (CBDB_Transaction *trans)
 Set current transaction. More...
 
void x_RemoveTransaction (CBDB_Transaction *trans)
 
DB_TXNGetTxn ()
 Get transaction handler. More...
 
DBCCreateCursor (CBDB_Transaction *trans=0, unsigned int flags=0) const
 Create DB cursor. More...
 
int x_DB_Fetch (DBT *key, DBT *data, unsigned flags)
 Internal override for DB->get(...) This method overrides destination buffer and uses compressor: Should only be used with DB_DBT_USERMEM flag. More...
 
int x_DBC_Fetch (DBC *dbc, DBT *key, DBT *data, unsigned flags)
 Internal override for DBC->c_get(...) This method overrides destination buffer and uses compressor: Should only be used with DB_DBT_USERMEM flag. More...
 
int x_DB_Put (DBT *key, DBT *data, unsigned flags)
 Override for DB->put(...) Handles compression. More...
 
int x_DB_CPut (DBC *dbc, DBT *key, DBT *data, unsigned flags)
 Override for DBC->c_put(...) Handles compression. More...
 
int x_FetchBufferDecompress (DBT *data, void *usr_data)
 

Detailed Description

template<class PropKey, class PropValue>
class CBDB_PropertyDictionary< PropKey, PropValue >

Definition at line 46 of file bdb_bv_property_store.hpp.

Member Typedef Documentation

◆ TKey

template<class PropKey , class PropValue >
typedef pair<PropKey, PropValue> CBDB_PropertyDictionary< PropKey, PropValue >::TKey

Definition at line 49 of file bdb_bv_property_store.hpp.

◆ TKeyId

template<class PropKey , class PropValue >
typedef Uint4 CBDB_PropertyDictionary< PropKey, PropValue >::TKeyId

Definition at line 50 of file bdb_bv_property_store.hpp.

Constructor & Destructor Documentation

◆ CBDB_PropertyDictionary() [1/2]

template<class PropKey , class PropValue >
CBDB_PropertyDictionary< PropKey, PropValue >::CBDB_PropertyDictionary
inline

◆ CBDB_PropertyDictionary() [2/2]

template<class PropKey , class PropValue >
CBDB_PropertyDictionary< PropKey, PropValue >::CBDB_PropertyDictionary ( const CBDB_PropertyDictionary< PropKey, PropValue > &  )
private

forbidden

Member Function Documentation

◆ GetCurrentKey()

template<class PropKey , class PropValue >
CBDB_PropertyDictionary< PropKey, PropValue >::TKey CBDB_PropertyDictionary< PropKey, PropValue >::GetCurrentKey
inline

◆ GetCurrentUid()

template<class PropKey , class PropValue >
CBDB_PropertyDictionary< PropKey, PropValue >::TKeyId CBDB_PropertyDictionary< PropKey, PropValue >::GetCurrentUid
inline

Definition at line 149 of file bdb_bv_property_store.hpp.

◆ GetKey()

template<class PropKey , class PropValue >
Uint4 CBDB_PropertyDictionary< PropKey, PropValue >::GetKey ( const TKey key)
inline

Definition at line 166 of file bdb_bv_property_store.hpp.

References ncbi::grid::netcache::search::fields::key, and Read().

◆ GetMaxUid()

template<class PropKey , class PropValue >
CBDB_PropertyDictionary< PropKey, PropValue >::TKeyId CBDB_PropertyDictionary< PropKey, PropValue >::GetMaxUid
inline

Definition at line 158 of file bdb_bv_property_store.hpp.

◆ operator=()

template<class PropKey , class PropValue >
CBDB_PropertyDictionary& CBDB_PropertyDictionary< PropKey, PropValue >::operator= ( const CBDB_PropertyDictionary< PropKey, PropValue > &  )
private

◆ PutKey()

template<class PropKey , class PropValue >
Uint4 CBDB_PropertyDictionary< PropKey, PropValue >::PutKey ( const TKey key)
inline

◆ Read() [1/3]

template<class PropKey , class PropValue >
EBDB_ErrCode CBDB_PropertyDictionary< PropKey, PropValue >::Read ( const PropKey &  prop,
const PropValue &  value,
TKeyId key_idx 
)
inline

Definition at line 221 of file bdb_bv_property_store.hpp.

References Read(), and rapidjson::value.

◆ Read() [2/3]

template<class PropKey , class PropValue >
EBDB_ErrCode CBDB_PropertyDictionary< PropKey, PropValue >::Read ( const TKey key,
TKeyId key_idx 
)
inline

Definition at line 210 of file bdb_bv_property_store.hpp.

References ncbi::grid::netcache::search::fields::key, and Read().

◆ Read() [3/3]

template<class PropKey , class PropValue >
EBDB_ErrCode CBDB_PropertyDictionary< PropKey, PropValue >::Read ( TKeyId key_idx)
inline

Definition at line 197 of file bdb_bv_property_store.hpp.

References eBDB_Ok, and max().

◆ Write() [1/2]

template<class PropKey , class PropValue >
EBDB_ErrCode CBDB_PropertyDictionary< PropKey, PropValue >::Write ( const PropKey &  prop,
const PropValue &  value,
TKeyId  key_idx 
)
inline

Definition at line 246 of file bdb_bv_property_store.hpp.

References max(), and rapidjson::value.

◆ Write() [2/2]

template<class PropKey , class PropValue >
EBDB_ErrCode CBDB_PropertyDictionary< PropKey, PropValue >::Write ( const TKey key,
TKeyId  key_idx 
)
inline

Definition at line 233 of file bdb_bv_property_store.hpp.

References ncbi::grid::netcache::search::fields::key, and max().

Member Data Documentation

◆ m_MaxUid

template<class PropKey , class PropValue >
TKeyId CBDB_PropertyDictionary< PropKey, PropValue >::m_MaxUid
protected

Definition at line 76 of file bdb_bv_property_store.hpp.

◆ m_PropKey

template<class PropKey , class PropValue >
SBDB_TypeTraits<PropKey>::TFieldType CBDB_PropertyDictionary< PropKey, PropValue >::m_PropKey
private

◆ m_PropVal

template<class PropKey , class PropValue >
SBDB_TypeTraits<PropValue>::TFieldType CBDB_PropertyDictionary< PropKey, PropValue >::m_PropVal
private

◆ m_Uid

template<class PropKey , class PropValue >
SBDB_TypeTraits<TKeyId>::TFieldType CBDB_PropertyDictionary< PropKey, PropValue >::m_Uid
private

The documentation for this class was generated from the following file:
Modified on Fri Sep 20 14:57:34 2024 by modify_doxy.py rev. 669887