1 #ifndef BDB__RANGE_MAP_HPP
2 #define BDB__RANGE_MAP_HPP
94 bool add_to_free_list);
104 unsigned Remap(
unsigned id,
bool ignore_free_list=
false);
118 bool ignore_free_list=
false);
147 catch (exception& ex)
149 ERR_POST_XX(Db_Bdb_RangeMap, 2,
"Exception in ~CBDB_RangeMap()" << ex.
what());
167 m_FreeList->clear(
true);
179 return UpdateInsert(
buf);
186 bool add_to_free_list)
188 if (from == 0 && to == 0) {
189 BDB_THROW(eInvalidValue,
"0-0 range is reserved.");
192 BDB_THROW(eInvalidValue,
"Incorrect range values.");
204 unsigned from_db = this->FromId;
205 unsigned to_db = this->ToId;
209 if (from >= from_db && from <= to_db) {
211 "Range overlaps with the previous range.");
219 unsigned from_db = this->FromId;
220 unsigned to_db = this->ToId;
224 if (to >= from_db && to <= to_db) {
226 "Range overlaps with the next range.");
237 if (add_to_free_list) {
238 m_FreeList->set_range(from, to,
true);
247 if (!ignore_free_list) {
248 if (m_FreeList->test(
id)) {
262 unsigned from_id = this->FromId;
263 unsigned to_id = this->ToId;
264 if (from_id <=
id &&
id <= to_id) {
265 return dst + (
id - from_id);
275 bool ignore_free_list)
278 unsigned from_id, to_id, dst;
279 from_id = to_id = dst = 0;
281 typename TBV::enumerator en(bv_src.first());
282 for ( ;en.valid(); ++en) {
284 if (!ignore_free_list) {
285 if (m_FreeList->test(
id)) {
290 if (from_id <=
id &&
id <= to_id) {
291 bv_dst->set(dst + (
id - from_id));
293 bv_remapped->set(
id);
300 cur.
FetchFirst(&ptr,
sizeof(dst), eReallocForbidden);
302 from_id = this->FromId;
304 if (from_id <=
id &&
id <= to_id) {
305 bv_dst->set(dst + (
id - from_id));
307 bv_remapped->set(
id);
BDB library BLOB support.
Berkeley BDB file cursor.
Berkeley DB BLOB File class.
Berkeley DB file cursor class.
Range map class, stores unsigned integer range mappings like 10 to 15 maps into 100 to 115.
TBitVector & GetFreeList()
EBDB_ErrCode AddRange(unsigned from, unsigned to, unsigned dest, bool add_to_free_list)
Add remapping range.
unsigned Remap(unsigned id, bool ignore_free_list=false)
Remap one single id.
CBDB_FieldUint4 FromId
From id.
const TBitVector & GetFreeList() const
Get list of free ids.
void LoadFreeList()
Load free list (Storage should be open first)
CBDB_FieldUint4 ToId
To id.
EBDB_ErrCode Save()
Save free list.
Reallocable memory buffer (no memory copy overhead) Mimics vector<>, without the overhead of explicit...
Include a standard set of the NCBI C++ Toolkit most basic headers.
EBDB_ErrCode ReadRealloc(TBuffer &buffer)
Read BLOB into vector.
void SetCondition(ECondition cond_from, ECondition cond_to=eNotSet)
Set search condition(type of interval)
EBDB_ErrCode FetchFirst()
void BindKey(const char *field_name, CBDB_Field *key_field, size_t buf_size=0)
EBDB_ErrCode
BDB Return codes.
CBDB_ConditionHandle From
#define BDB_THROW(errcode, message)
#define ERR_POST_XX(error_name, err_subcode, message)
Error posting with error code having given name and with given error subcode.
const string & GetMsg(void) const
Get message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
@ BM_GAP
GAP compression is ON.
size_t deserialize(BV &bv, const unsigned char *buf, bm::word_t *temp_block=0, const bm::bv_ref_vector< BV > *ref_vect=0)
Bitvector deserialization from a memory BLOB.
Definition of all error codes used in bdb library (bdb.lib and ncbi_xcache_bdb.lib).
Compressed bitset (entry point to bm.h)
Bitset relates utilities.
void BV_Serialize(const TBV &bv, TBuffer &buf, bm::word_t *tmp_block=0, bool optimize_bv=false)
Serialize bitset into a vector<char> compatible buffer.
Defines NCBI C++ exception handling.