113 "CIntDeltaSumCache::GetDeltaSum4(): "
114 "Int8 value doesn't fit in Int4");
127 #define USE_DELTA_CACHE
137 : m_Blocks(new
TValue[(
size+kBlockSize-1)/kBlockSize]),
140 m_CacheBlockInfo(new
TValue[kBlockSize]),
142 m_CacheBlockIndex(size_t(0)-1)
157 #ifdef USE_DELTA_CACHE
164 _ASSERT(block_offset < block_size);
166 for (
size_t i = 0;
i < block_size; ++
i ) {
185 _ASSERT(block_offset < block_size);
187 for (
size_t i = 0;
i <= block_offset; ++
i ) {
195 for (
size_t i = block_offset+1;
i < block_size; ++
i ) {
230 : m_Blocks(new
TValue[(
size+kBlockSize-1)/kBlockSize]),
233 m_CacheBlockInfo(new
TValue[kBlockSize]),
235 m_CacheBlockIndex(size_t(0)-1)
250 #ifdef USE_DELTA_CACHE
257 _ASSERT(block_offset < block_size);
259 for (
size_t i = 0;
i < block_size; ++
i ) {
278 _ASSERT(block_offset < block_size);
280 for (
size_t i = 0;
i <= block_offset; ++
i ) {
288 for (
size_t i = block_offset+1;
i < block_size; ++
i ) {
417 return GetId().size();
435 template<
class DstInt>
442 "CSeqTable_multi_data::TryGet"<<
type_name<<
"(): "
443 "value is too big for requested type: "<<
value);
449 template<
class DstInt>
457 static constexpr
double kMaxPlusOne
461 range_error =
value >= kMaxPlusOne;
476 template<
class Arr,
class Row,
class Int>
480 if (
row >=
arr.size() ) {
528 if (
i >= bits.size() ) {
533 v = ((
bb<<j)&0x80) != 0;
561 "CSeqTable_multi_data::TryGet"<<
type_name<<
"(): "
562 "value cannot be converted to requested type");
585 v = double(value_int8);
602 if (
row < indexes.size() ) {
604 size_t arr_index = indexes[
row];
605 if ( arr_index <
arr.size() ) {
606 return &
arr[arr_index];
612 "CSeqTable_multi_data::GetStringPtr() "
613 "data cannot be converted to string");
625 "CSeqTable_multi_data::TryGetInt1WithRounding(): "
626 "real value doesn't fit in Int1");
638 "CSeqTable_multi_data::TryGetInt2WithRounding(): "
639 "real value doesn't fit in Int2");
651 "CSeqTable_multi_data::TryGetInt4WithRounding(): "
652 "real value doesn't fit in Int4");
664 "CSeqTable_multi_data::TryGetInt8WithRounding(): "
665 "real value doesn't fit in Int8");
682 if (
row < indexes.size() ) {
684 size_t arr_index = indexes[
row];
685 if ( arr_index <
arr.size() ) {
686 return arr[arr_index];
692 "CSeqTable_multi_data::GetBytesPtr() "
693 "data cannot be converted to OCTET STRING");
740 data->SetCommon_string().SetIndexes().reserve(
size);
743 data->SetCommon_bytes().SetIndexes().reserve(
size);
761 catch ( bad_alloc& ) {
812 "CSeqTable_multi_data::ChangeTo(e_Int_scaled): "
813 "scaling parameters are unknown");
816 "CSeqTable_multi_data::ChangeTo(e_Real_scaled): "
817 "scaling parameters are unknown");
820 "CSeqTable_multi_data::ChangeTo(): "
821 "requested multi-data type is invalid");
834 size_t size = indexes.size();
840 if ( index < src.size() ) {
841 arr.push_back(src[index]);
843 else if ( omitted_value ) {
844 arr.push_back(*omitted_value);
848 "CSeqTable_multi_data::ChangeToString(): "
849 "common string table is sparse");
856 "CSeqTable_multi_data::ChangeToString(): "
857 "requested mult-data type is invalid");
871 indexes.reserve(src.size());
876 index_map[*omit_value] = -1;
879 const string&
key = *it;
880 TIndexMap::iterator iter = index_map.lower_bound(
key);
881 if ( iter == index_map.end() || iter->first !=
key ) {
885 indexes.push_back(iter->second);
891 "CSeqTable_multi_data::ChangeToCommon_string(): "
892 "requested mult-data type is invalid");
904 size_t size = indexes.size();
911 if ( index < src.size() ) {
914 else if ( omitted_value ) {
915 value = omitted_value;
919 "CSeqTable_multi_data::ChangeToBytes(): "
920 "common bytes table is sparse");
928 "CSeqTable_multi_data::ChangeToBytes(): "
929 "requested mult-data type is invalid");
943 indexes.reserve(src.size());
949 index_map[omit_value] = -1;
953 TIndexMap::iterator iter = index_map.lower_bound(
key);
954 if ( iter == index_map.end() || *iter->first != *
key ) {
958 indexes.push_back(iter->second);
964 "CSeqTable_multi_data::ChangeToBytes(): "
965 "requested mult-data type is invalid");
985 for (
size_t row = 0; ; ++
row ) {
1003 int min_v = 0, max_v = 0;
1011 if (
value % mul != 0 ) {
1013 while ( it !=
arr.begin() ) {
1015 *it =
value*mul+add;
1019 "CSeqTable_multi_data::ChangeToInt_scaled(): "
1020 "value is not round for scaling");
1023 if (
value < min_v ) {
1026 else if (
value > max_v ) {
1035 for (
size_t row = 0; ; ++
row ) {
1041 if (
value % mul != 0 ) {
1043 "CSeqTable_multi_data::ChangeToInt_scaled(): "
1044 "value is not round for scaling");
1047 if (
value > max_v ) {
1050 else if (
value < min_v ) {
1059 Int8 min_v8 = 0, max_v8 = 0;
1060 for (
size_t row = 0; ; ++
row ) {
1066 if (
value % mul != 0 ) {
1068 "CSeqTable_multi_data::ChangeToInt_scaled(): "
1069 "value is not round for scaling");
1072 if (
value > max_v8 ) {
1075 else if (
value < min_v8 ) {
1082 bool is_int8 =
false;
1094 min_v =
int(min_v8);
1095 max_v =
int(max_v8);
1098 if ( min_v == 0 && max_v <= 1 ) {
1125 *it =
value - prev_value;
1131 for (
size_t row = 0; ; ++
row ) {
1165 for (
size_t row = 0; ; ++
row ) {
1183 for (
size_t row = 0; ; ++
row ) {
1201 for (
size_t row = 0; ; ++
row ) {
1219 for (
size_t row = 0; ; ++
row ) {
1237 for (
size_t row = 0; ; ++
row ) {
1259 size_t last_byte_index = 0;
1260 Uint1 last_byte = 0;
1263 size_t byte_index =
i / 8;
1264 if ( byte_index != last_byte_index ) {
1265 arr.resize(last_byte_index);
1266 arr.push_back(last_byte);
1267 last_byte_index = byte_index;
1270 size_t bit_index =
i % 8;
1271 last_byte |= 0x80 >> bit_index;
1274 arr.resize(last_byte_index);
1275 arr.push_back(last_byte);
1283 for (
size_t i = 0;
i <
size; ++
i ) {
1287 "CSeqTable_multi_data::ChangeToBit(): "
1288 "multi-data value cannot be converted to int");
1290 if ( v < 0 || v > 1 ) {
1292 "CSeqTable_multi_data::ChangeToBit(): "
1293 "multi-data value is not 0 or 1");
1296 arr[
i/8] |= 0x80 >>
i%8;
1302 "CSeqTable_multi_data::ChangeToBit(): "
1303 "requested mult-data type is invalid");
1320 for ( TBVSize
i = 0;
i <
size;
i += 8 ) {
1321 for (
Uint1 b = src[
i/8], j = 0;
b & 0xff; ++j,
b <<= 1 ) {
1329 for ( TBVSize
i = 0;
i <
size; ++
i ) {
1333 "CSeqTable_multi_data::ChangeToBit_bvector(): "
1334 "multi-data value cannot be converted to int");
1336 if ( v < 0 || v > 1 ) {
1338 "CSeqTable_multi_data::ChangeToBit_bvector(): "
1339 "multi-data value is not 0 or 1");
1348 "CSeqTable_multi_data::ChangeToBit_bvector(): "
1349 "requested multi-data type is invalid");
User-defined methods of the data storage class.
User-defined methods of the data storage class.
NCBI_PARAM_DEF_EX(bool, OBJECTS, SEQ_TABLE_RESERVE, true, eParam_NoThread, OBJECTS_SEQ_TABLE_RESERVE)
DEFINE_STATIC_MUTEX(sx_PrepareMutex_multi_data)
static bool sx_TryGet(const Arr &arr, Row row, Int &v)
static bool sx_Round(DstInt &v, double value, const char *cast_error)
static bool sx_DownCastInt8(DstInt &v, const Int8 &value, const char *type_name)
NCBI_PARAM_DECL(bool, OBJECTS, SEQ_TABLE_RESERVE)
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static char * s_Reserve(size_t size, CSimpleBufferT< char > &buffer)
const bm::bvector & GetBitVector(void) const
void SetBitVector(const bm::bvector<> *bv)
~CInt4DeltaSumCache(void)
static const size_t kBlockSize
AutoArray< TValue > m_CacheBlockInfo
AutoArray< TValue > m_Blocks
TValue GetDeltaSum4(const TDeltas &deltas, size_t index)
TValue x_GetDeltaSum2(const TDeltas &deltas, size_t block_index, size_t block_offset)
CInt4DeltaSumCache(size_t size)
TValue x_GetDeltaSum2(const TDeltas &deltas, size_t block_index, size_t block_offset)
CInt8DeltaSumCache(size_t size)
TValue GetDeltaSum8(const TDeltas &deltas, size_t index)
~CInt8DeltaSumCache(void)
AutoArray< TValue > m_Blocks
AutoArray< TValue > m_CacheBlockInfo
static const size_t kBlockSize
virtual Int8 GetDeltaSum8(const TDeltas &deltas, size_t index)
virtual ~CIntDeltaSumCache(void)
virtual Int4 GetDeltaSum4(const TDeltas &deltas, size_t index)
size_t GetIntSize(void) const
bool TryGetInt8(size_t row, Int8 &v) const
bool TryGetReal(size_t row, double &v) const
Seq-loc and seq-align mapper exceptions.
virtual void PreReadChoiceVariant(CObjectIStream &in, const CObjectInfoCV &variant)
Return true to invoke default reading method afterwards.
bool TryGetInt8(size_t row, Int8 &v) const
bool TryGetInt4(size_t row, Int4 &v) const
bool TryGetInt1(size_t row, Int1 &v) const
void ChangeToCommon_bytes(const TBytesValue *omit_value=0)
bool TryGetInt1WithRounding(size_t row, Int1 &v) const
bool TryGetReal(size_t row, double &v) const
CIntDeltaSumCache & x_GetIntDeltaCache(void) const
void ChangeToString(const string *omitted_value=0)
const string * GetStringPtr(size_t row) const
bool TryGetInt(size_t row, int &v) const
size_t GetIntSize(void) const
E_Choice GetValueType(void) const
void ChangeTo(E_Choice type)
bool TryGetInt8WithRounding(size_t row, Int8 &v) const
vector< char > TBytesValue
bool x_TryGetInt8(size_t row, Int8 &v, const char *type_name) const
const TBytesValue * GetBytesPtr(size_t row) const
bool TryGetInt2WithRounding(size_t row, Int2 &v) const
~CSeqTable_multi_data(void)
void ChangeToCommon_string(const string *omit_value=0)
CRef< CIntDeltaSumCache > m_Cache
bool CanGetInt(void) const
void ChangeToBit_bvector(void)
size_t GetSize(void) const
bool TryGetBool(size_t row, bool &v) const
bool TryGetInt2(size_t row, Int2 &v) const
bool TryGetIntWithRounding(size_t row, int &v) const
void ChangeToReal_scaled(double mul, double add)
bool TryGetValue(size_t row, Int1 &v) const
bool CanGetReal(void) const
void ChangeToInt_delta(void)
void ChangeToBytes(const TBytesValue *omitted_value=0)
bool TryGetInt4WithRounding(size_t row, Int4 &v) const
CSeqTable_multi_data(void)
void ChangeToInt_scaled(int mul, int add)
bool any() const noexcept
Returns true if any bits in this bitset are set, and otherwise returns false.
size_type size() const noexcept
Returns bvector's capacity (number of bits it can store)
bvector_size_type size_type
size_type get_next(size_type prev) const noexcept
Finds the number of the next bit ON.
size_type get_first() const noexcept
find first 1 bit in vector. Function may return 0 and this requires an extra check if bit 0 is actual...
static vector< string > arr
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
element_type * release(void)
Release will release ownership of pointer to caller.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
static C * Get(const CTypesIterator &it)
const CObjectInfo & GetChoiceObject(void) const
Get containing choice.
TMemberIndex GetVariantIndex(void) const
Get index of the variant in the choice.
TObjectType * GetNCPointerOrNull(void) const THROWS_NONE
Get pointer value.
void Reset(void)
Reset reference object.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
uint8_t Uint1
1-byte (8-bit) unsigned integer
int16_t Int2
2-byte (16-bit) signed integer
int32_t Int4
4-byte (32-bit) signed integer
int64_t Int8
8-byte (64-bit) signed integer
int8_t Int1
1-byte (8-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
bool IsBit(void) const
Check if variant Bit is selected.
const TData & GetData(void) const
Get the Data member data.
void SetData(TData &value)
Assign a value to Data data member.
TReal & SetReal(void)
Select the variant.
void SetMin(TMin value)
Assign a value to Min data member.
const TReal_scaled & GetReal_scaled(void) const
Get the variant data.
TString & SetString(void)
Select the variant.
bool IsString(void) const
Check if variant String is selected.
const TInt2 & GetInt2(void) const
Get the variant data.
const TIndexes & GetIndexes(void) const
Get the Indexes member data.
const TInt1 & GetInt1(void) const
Get the variant data.
bool IsInt_delta(void) const
Check if variant Int_delta is selected.
const TInterval & GetInterval(void) const
Get the variant data.
void SetMax(TMax value)
Assign a value to Max data member.
const TBit & GetBit(void) const
Get the variant data.
bool IsInt1(void) const
Check if variant Int1 is selected.
const TIndexes & GetIndexes(void) const
Get the Indexes member data.
const TInt_delta & GetInt_delta(void) const
Get the variant data.
bool IsBit_bvector(void) const
Check if variant Bit_bvector is selected.
TInt2 & SetInt2(void)
Select the variant.
TBit_bvector & SetBit_bvector(void)
Select the variant.
const TCommon_string & GetCommon_string(void) const
Get the variant data.
bool IsReal(void) const
Check if variant Real is selected.
const TBit_bvector & GetBit_bvector(void) const
Get the variant data.
const TInt_scaled & GetInt_scaled(void) const
Get the variant data.
const TReal & GetReal(void) const
Get the variant data.
bool IsInt8(void) const
Check if variant Int8 is selected.
bool IsInt_scaled(void) const
Check if variant Int_scaled is selected.
bool IsInt(void) const
Check if variant Int is selected.
bool IsBytes(void) const
Check if variant Bytes is selected.
const TLoc & GetLoc(void) const
Get the variant data.
TInt8 & SetInt8(void)
Select the variant.
vector< vector< char > * > TBytes
const TInt8 & GetInt8(void) const
Get the variant data.
vector< CStringUTF8 > TString
bool IsReal_scaled(void) const
Check if variant Real_scaled is selected.
TInt1 & SetInt1(void)
Select the variant.
TReal_scaled & SetReal_scaled(void)
Select the variant.
TInt & SetInt(void)
Select the variant.
bool IsCommon_bytes(void) const
Check if variant Common_bytes is selected.
TInt_delta & SetInt_delta(void)
Select the variant.
const TInt & GetInt(void) const
Get the variant data.
virtual void Reset(void)
Reset the whole object.
TBit & SetBit(void)
Select the variant.
const TBytes & GetBytes(void) const
Get the Bytes member data.
TInt_scaled & SetInt_scaled(void)
Select the variant.
const TData & GetData(void) const
Get the Data member data.
const TCommon_bytes & GetCommon_bytes(void) const
Get the variant data.
vector< CStringUTF8 > TStrings
TCommon_string & SetCommon_string(void)
Select the variant.
TCommon_bytes & SetCommon_bytes(void)
Select the variant.
vector< vector< char > * > TBytes
const TBytes & GetBytes(void) const
Get the variant data.
const TString & GetString(void) const
Get the variant data.
bool IsInt2(void) const
Check if variant Int2 is selected.
TSize GetSize(void) const
Get the Size member data.
E_Choice Which(void) const
Which variant is currently selected.
bool IsCommon_string(void) const
Check if variant Common_string is selected.
const TId & GetId(void) const
Get the variant data.
const TStrings & GetStrings(void) const
Get the Strings member data.
TBytes & SetBytes(void)
Select the variant.
@ e_Int8
a set of signed 8-byte integers
@ e_Int_scaled
scaled data (int/bit -> int)
@ e_Real
a set of reals, one per row
@ e_Int1
a set of signed 1-byte integers encoded as sequential octets
@ e_Loc
a set of locations, one per row
@ e_Common_bytes
a set of byte arrays with small set of possible values
@ e_Int_delta
delta-encoded data (int/bit -> int)
@ e_Bytes
a set of byte arrays, one per row
@ e_String
a set of strings, one per row
@ e_Bit
a set of bits, one per row Most-significant bit in each octet comes first.
@ e_Int2
a set of signed 2-byte integers
@ e_Int
a set of 4-byte integers, one per row
@ e_Common_string
a set of string with small set of possible values
@ e_Real_scaled
scaled data (int/bit -> real)
@ e_Bit_bvector
a set of bit, represented as serialized bvector, see include/util/bitset/bm.h
unsigned int
A callback function used to compare two keys in a database.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Compressed bitset (entry point to bm.h)
std::istream & in(std::istream &in_, double &x_)
#define row(bind, expected)
Compare objects pointed to by (smart) pointer.
static const char * type_name(CS_INT value)