1 #ifndef BDB___BV_DICT_IDX__HPP
2 #define BDB___BV_DICT_IDX__HPP
45 template <
typename Key,
117 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
126 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
137 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
151 template<
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
158 if ( !m_STmpBlock ) {
202 "Deserialize(): unknown op");
211 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
229 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
234 return ReadVector(
key, bv, eOp_Or);
238 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
243 return ReadVector(
key, bv, eOp_And);
251 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
260 err = TParent::ReadById(
key, m_Buffer);
269 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
274 return ReadVectorById(
key, bv, eOp_Or);
278 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
283 return ReadVectorById(
key, bv, eOp_And);
290 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
296 if ( !m_STmpBlock ) {
301 typename TBitVector::statistics st1;
302 if (compact == eCompact) {
303 m_TmpVec.clear(
true);
305 m_TmpVec.optimize(0, BV::opt_compress, &st1);
306 bv_to_store = &m_TmpVec;
308 bv_to_store->calc_stat(&st1);
311 if (st1.max_serialize_mem > m_Buffer.size()) {
312 m_Buffer.resize(st1.max_serialize_mem);
316 m_Buffer.resize(
size);
320 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
326 x_SerializeBitVector(bv, m_Buffer, compact);
331 template <
typename Key,
typename Dictionary,
typename BvStore,
typename BV>
337 x_SerializeBitVector(bv, m_Buffer, compact);
338 return TParent::WriteById(key_id, m_Buffer);
Templatized candidate for dictionaries This template defines the basic interface that must be support...
CBDB_RawFile::TBuffer m_Buffer
private data buffer
EBDB_ErrCode ReadVectorAndById(TKeyId key, TBitVector *bv)
EBDB_ErrCode WriteVectorById(TKeyId key_id, const TBitVector &bv, ECompact compact)
EBDB_ErrCode ReadVectorOrById(TKeyId key, TBitVector *bv)
void Deserialize(TBitVector *bv, CBDB_RawFile::TBuffer::value_type *buf, EReadOp op)
Fetch, deserialize bvector.
EBDB_ErrCode ReadVectorAnd(const TKey &key, TBitVector *bv)
TBitVector m_TmpVec
temporary bit-vector for write operations
CBDB_BlobDictStore< Key, Dictionary, BvStore > TParent
bm::word_t * m_STmpBlock
temp block for bitvector serialization
EBDB_ErrCode WriteVector(const TKey &key, const TBitVector &bv, ECompact compact)
EBDB_ErrCode ReadVectorById(TKeyId key, TBitVector *bv, EReadOp op=eOp_Replace)
read a vector by the relevant key ID, performing a logical operation these are useful in situations i...
EBDB_ErrCode ReadVectorOr(const TKey &key, TBitVector *bv)
CBDB_BvSplitDictStore(const string &demux_path=kEmptyStr)
CBDB_BvSplitDictStore(Dictionary &dict, BvStore &store, EOwnership own=eTakeOwnership)
void x_SerializeBitVector(const TBitVector &bv, CBDB_RawFile::TBuffer &buffer, ECompact compact)
Public write interface.
EBDB_ErrCode ReadVector(const TKey &key, TBitVector *bv, EReadOp op=eOp_Replace)
read a vector by the relevant key, performing a logical operation
Reallocable memory buffer (no memory copy overhead) Mimics vector<>, without the overhead of explicit...
size_type deserialize(bvector_type &bv, const unsigned char *buf, set_operation op, bool exit_on_one=false)
Deserialize bvector using buffer as set operation argument.
@ eTakeOwnership
An object can take ownership of another.
EBDB_ErrCode
BDB Return codes.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
uint32_t Uint4
4-byte (32-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
size_t serialize(const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
Saves bitvector into memory.
@ BM_NO_BYTE_ORDER
save no byte-order info (save some space)
void aligned_free(void *ptr) BMNOEXCEPT
Aligned free.
void * aligned_new_malloc(size_t size)
Aligned malloc (unlike classic malloc it throws bad_alloc exception)
const unsigned set_block_alloc_size
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
Compressed bitset (entry point to bm.h)
static CSafeStatic< map< string, string > > Dictionary
void Deserialize(CNcbiIstream &istr, CRawScoreVector< Key, Score > &)