NCBI C++ ToolKit
Public Types | Public Member Functions | Private Attributes | List of all members
CAsnCache Class Reference

Search Toolkit Book for CAsnCache

CAsnCache is used by clients to access the ASN cache data. More...

#include <objtools/data_loaders/asn_cache/asn_cache.hpp>

+ Inheritance diagram for CAsnCache:
+ Collaboration diagram for CAsnCache:

Public Types

using TBuffer = vector< unsigned char >
 Type used to hold raw (unformatted) blob data. More...
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 
- Public Types inherited from IAsnCacheStore
using TEnumSeqidCallback = std::function< void(string, uint32_t, uint64_t, uint32_t)>
 
using TEnumIndexCallback = std::function< void(string, uint32_t, uint64_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t)>
 

Public Member Functions

 CAsnCache (const CAsnCache &)=delete
 
CAsnCacheoperator= (const CAsnCache &)=delete
 
 CAsnCache (const string &db_path)
 Pass in the path to the ASN cache to construct an object. More...
 
bool GetRaw (const objects::CSeq_id_Handle &id, TBuffer &buffer)
 Return the raw blob in an unformatted buffer. More...
 
bool GetMultipleRaw (const objects::CSeq_id_Handle &id, vector< TBuffer > &buffer)
 
bool GetBlob (const objects::CSeq_id_Handle &id, objects::CCache_blob &blob)
 Return the cache blob, packed and uninterpreted. More...
 
bool GetMultipleBlobs (const objects::CSeq_id_Handle &id, vector< CRef< objects::CCache_blob > > &blob)
 
bool GetSeqIds (const objects::CSeq_id_Handle &id, vector< objects::CSeq_id_Handle > &all_ids, bool cheap_only=true)
 Return the set of seq-ids associated with a given ID. More...
 
CRef< objects::CSeq_entry > GetEntry (const objects::CSeq_id_Handle &id)
 Return a blob as a CSeq_entry object. More...
 
vector< CRef< objects::CSeq_entry > > GetMultipleEntries (const objects::CSeq_id_Handle &id)
 
bool GetIdInfo (const objects::CSeq_id_Handle &id, CAsnIndex::TGi &gi, time_t &timestamp)
 Return the GI and timestamp for a given seq_id. More...
 
bool GetIdInfo (const objects::CSeq_id_Handle &id, objects::CSeq_id_Handle &accession, CAsnIndex::TGi &gi, time_t &timestamp, Uint4 &sequence_length, Uint4 &tax_id)
 Return the GI and timestamp for a given seq_id. More...
 
bool GetIndexEntry (const objects::CSeq_id_Handle &id, CAsnIndex::SIndexInfo &info)
 Get the full ASN cache index entry. More...
 
bool GetMultipleIndexEntries (const objects::CSeq_id_Handle &id, vector< CAsnIndex::SIndexInfo > &info)
 
size_t GetGiCount () const
 
void EnumSeqIds (IAsnCacheStore::TEnumSeqidCallback cb) const
 
void EnumIndex (IAsnCacheStore::TEnumIndexCallback cb) const
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 
- Public Member Functions inherited from IAsnCacheStore
virtual ~IAsnCacheStore ()
 
virtual bool GetRaw (const objects::CSeq_id_Handle &id, vector< unsigned char > &buffer)=0
 Return the raw blob in an unformatted buffer. More...
 
virtual bool GetMultipleRaw (const objects::CSeq_id_Handle &id, vector< vector< unsigned char >> &buffer)=0
 

Private Attributes

string m_DbPath
 
std::unique_ptr< IAsnCacheStorem_Store
 

Additional Inherited Members

- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 
- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Detailed Description

CAsnCache is used by clients to access the ASN cache data.

The ASN cache is a cache of the ID database that is designed for fast access and retrieval of CSeq_entry blobs.

Note
Data in the ASN cache can also be accessed via the object manager and the ASN cache data loader, CAsnCache_DataLoader.

Definition at line 59 of file asn_cache.hpp.

Member Typedef Documentation

◆ TBuffer

using CAsnCache::TBuffer = vector<unsigned char>

Type used to hold raw (unformatted) blob data.

Definition at line 64 of file asn_cache.hpp.

Constructor & Destructor Documentation

◆ CAsnCache() [1/2]

CAsnCache::CAsnCache ( const CAsnCache )
delete

◆ CAsnCache() [2/2]

CAsnCache::CAsnCache ( const string db_path)
explicit

Member Function Documentation

◆ EnumIndex()

void CAsnCache::EnumIndex ( IAsnCacheStore::TEnumIndexCallback  cb) const
virtual

Implements IAsnCacheStore.

Definition at line 189 of file asn_cache.cpp.

References m_Store.

Referenced by CAsnCacheStats::DumpIndex().

◆ EnumSeqIds()

void CAsnCache::EnumSeqIds ( IAsnCacheStore::TEnumSeqidCallback  cb) const
virtual

Implements IAsnCacheStore.

Definition at line 184 of file asn_cache.cpp.

References m_Store.

Referenced by CAsnCacheStats::DumpSeqIds(), and CAsnCacheStats::GetGICount().

◆ GetBlob()

bool CAsnCache::GetBlob ( const objects::CSeq_id_Handle &  id,
objects::CCache_blob &  blob 
)
virtual

Return the cache blob, packed and uninterpreted.

Implements IAsnCacheStore.

Definition at line 131 of file asn_cache.cpp.

References m_Store.

◆ GetEntry()

CRef< CSeq_entry > CAsnCache::GetEntry ( const objects::CSeq_id_Handle &  id)
virtual

Return a blob as a CSeq_entry object.

Implements IAsnCacheStore.

Definition at line 154 of file asn_cache.cpp.

References m_Store.

Referenced by CAsnCache_DataLoader::GetBlobById(), and CAsnCacheTestApplication::Run().

◆ GetGiCount()

size_t CAsnCache::GetGiCount ( ) const
virtual

Implements IAsnCacheStore.

Definition at line 179 of file asn_cache.cpp.

References m_Store.

Referenced by CAsnCacheStats::GetGICount().

◆ GetIdInfo() [1/2]

bool CAsnCache::GetIdInfo ( const objects::CSeq_id_Handle &  id,
CAsnIndex::TGi gi,
time_t &  timestamp 
)
virtual

Return the GI and timestamp for a given seq_id.

This can be a very fast way to look up the GI for an accession.version because only the index is queried – the blob is not retrieved.

Implements IAsnCacheStore.

Referenced by CAsnCache_DataLoader::GetGi(), CAsnCache_DataLoader::GetSequenceLength(), and CAsnCache_DataLoader::GetTaxId().

◆ GetIdInfo() [2/2]

bool CAsnCache::GetIdInfo ( const objects::CSeq_id_Handle &  id,
objects::CSeq_id_Handle &  accession,
CAsnIndex::TGi gi,
time_t &  timestamp,
Uint4 sequence_length,
Uint4 tax_id 
)
virtual

Return the GI and timestamp for a given seq_id.

This can be a very fast way to look up the GI for an accession.version because only the index is queried – the blob is not retrieved.

Implements IAsnCacheStore.

◆ GetIndexEntry()

bool CAsnCache::GetIndexEntry ( const objects::CSeq_id_Handle &  id,
CAsnIndex::SIndexInfo info 
)
virtual

Get the full ASN cache index entry.

This does not retrieve the full blob and is very fast.

Implements IAsnCacheStore.

Definition at line 164 of file asn_cache.cpp.

References info, and m_Store.

Referenced by CAsnCache_DataLoader::GetBlobId(), and CAsnCacheTestApplication::Run().

◆ GetMultipleBlobs()

bool CAsnCache::GetMultipleBlobs ( const objects::CSeq_id_Handle &  id,
vector< CRef< objects::CCache_blob > > &  blob 
)
virtual

Implements IAsnCacheStore.

Definition at line 137 of file asn_cache.cpp.

References m_Store.

◆ GetMultipleEntries()

vector< CRef< CSeq_entry > > CAsnCache::GetMultipleEntries ( const objects::CSeq_id_Handle &  id)
virtual

Implements IAsnCacheStore.

Definition at line 159 of file asn_cache.cpp.

References m_Store.

Referenced by CAsnCacheTestApplication::Run().

◆ GetMultipleIndexEntries()

bool CAsnCache::GetMultipleIndexEntries ( const objects::CSeq_id_Handle &  id,
vector< CAsnIndex::SIndexInfo > &  info 
)
virtual

Implements IAsnCacheStore.

Definition at line 170 of file asn_cache.cpp.

References info, and m_Store.

Referenced by CAsnCacheTestApplication::Run().

◆ GetMultipleRaw()

bool CAsnCache::GetMultipleRaw ( const objects::CSeq_id_Handle &  id,
vector< TBuffer > &  buffer 
)

Definition at line 149 of file asn_cache.cpp.

References buffer, and m_Store.

Referenced by CAsnCacheTestApplication::Run().

◆ GetRaw()

bool CAsnCache::GetRaw ( const objects::CSeq_id_Handle &  id,
TBuffer buffer 
)

Return the raw blob in an unformatted buffer.

Definition at line 143 of file asn_cache.cpp.

References buffer, and m_Store.

Referenced by CAsnCacheTestApplication::Run().

◆ GetSeqIds()

bool CAsnCache::GetSeqIds ( const objects::CSeq_id_Handle &  id,
vector< objects::CSeq_id_Handle > &  all_ids,
bool  cheap_only = true 
)
virtual

Return the set of seq-ids associated with a given ID.

By default, if the SeqId index is not available, and the SeqIds can't be retrieved cheaply, does nothing and return false. If cheap_only is set to false, will always retrieve the SeqIds, by retrieving the full blob if that is the only available way.

Implements IAsnCacheStore.

Definition at line 124 of file asn_cache.cpp.

References m_Store.

Referenced by CAsnCache_DataLoader::GetIds(), and CAsnCacheTestApplication::Run().

◆ operator=()

CAsnCache& CAsnCache::operator= ( const CAsnCache )
delete

Member Data Documentation

◆ m_DbPath

string CAsnCache::m_DbPath
private

Definition at line 134 of file asn_cache.hpp.

Referenced by CAsnCache().

◆ m_Store

std::unique_ptr<IAsnCacheStore> CAsnCache::m_Store
private

The documentation for this class was generated from the following files:
Modified on Wed Apr 17 13:09:35 2024 by modify_doxy.py rev. 669887