40 #include <klib/text.h>
41 #include <klib/sra-release-version.h>
42 #include <kfg/config.h>
43 #include <kdb/manager.h>
44 #include <kdb/database.h>
45 #include <kdb/kdb-priv.h>
46 #include <kns/manager.h>
50 #include <vfs/manager-priv.h>
51 #include <vfs/manager.h>
53 #include <vfs/resolver.h>
55 #include <sra/sradb-priv.h>
57 #include <vdb/vdb-priv.h>
58 #include <vdb/manager.h>
59 #include <vdb/database.h>
60 #include <vdb/schema.h>
61 #include <vdb/table.h>
62 #include <vdb/cursor.h>
83 #define NCBI_USE_ERRCODE_X VDBReader
125 auto old_level = var;
150 #define FAILS_VAR(name, suffix) NCBI_NAME3(VDB_, name, suffix)
152 #define VDB_RESOLVE_RANDOM_FAILS 1
153 #define VDB_OPEN_RANDOM_FAILS 1
154 #define VDB_SCHEMA_RANDOM_FAILS 1
155 #define VDB_READ_RANDOM_FAILS 1
157 #define VDB_RESOLVE_RANDOM_FAILS_FREQUENCY 20
158 #define VDB_RESOLVE_RANDOM_FAILS_RECOVER 10
159 #define VDB_OPEN_RANDOM_FAILS_FREQUENCY 10
160 #define VDB_OPEN_RANDOM_FAILS_RECOVER 5
161 #define VDB_SCHEMA_RANDOM_FAILS_FREQUENCY 50
162 #define VDB_SCHEMA_RANDOM_FAILS_RECOVER 100
163 #define VDB_READ_RANDOM_FAILS_FREQUENCY 20000
164 #define VDB_READ_RANDOM_FAILS_RECOVER 1000
166 #if defined(VDB_RANDOM_FAILS)
167 static bool s_Fails(
unsigned frequency)
170 return s_Random->GetRandIndex(frequency) == 0;
172 # define SIMULATE_ERROR(name) \
173 if ( !(FAILS_VAR(name, _RANDOM_FAILS)) ) { \
176 static thread_local unsigned recover_counter = 0; \
177 if ( recover_counter > 0 ) { \
181 if ( s_Fails(FAILS_VAR(name, _RANDOM_FAILS_FREQUENCY)) ) { \
182 recover_counter = (FAILS_VAR(name, _RANDOM_FAILS_RECOVER)); \
183 ERR_POST("VDB: Simulated " #name " failure: "<<CStackTrace()); \
184 NCBI_THROW(CSraException, eOtherError, \
185 "Simulated " #name " failure"); \
190 # define SIMULATE_ERROR(name) ((void)0)
193 #define SIMULATE_RESOLVE_ERROR() SIMULATE_ERROR(RESOLVE)
194 #define SIMULATE_OPEN_ERROR() SIMULATE_ERROR(OPEN)
195 #define SIMULATE_SCHEMA_ERROR() SIMULATE_ERROR(SCHEMA)
196 #define SIMULATE_READ_ERROR() SIMULATE_ERROR(READ)
205 if (
rc_t rc = KConfigMake(&cfg, 0) ) {
208 "Cannot create KConfig", rc);
217 if (
rc_t rc = KConfigAddRef(*
this) ) {
220 "Cannot get reference to KConfig", rc);
229 "Cannot create KConfig singleton", rc);
236 if (
rc_t rc = KConfigCommit(
const_cast<KConfig*
>(
GetPointer())) ) {
238 "CKConfig: Cannot commit config changes", rc);
263 "Cannot create VFSManager", rc);
273 "Cannot get VFSManager", rc);
284 if (
rc_t rc = VDBManagerGetKDBManagerRead(mgr,
x_InitPtr()) ) {
287 "Cannot get KDBManager", rc);
301 "Cannot make KNSManager", rc);
311 "Cannot get KNSManager", rc);
335 if (
rc_t rc = VFSManagerMakeSysPath(mgr, &vpath, path.c_str()) ) {
338 "Cannot create sys VPath: "<<path, rc);
342 if (
rc_t rc = VFSManagerMakeAccPath(mgr, &vpath, path.c_str()) ) {
345 "Cannot create acc VPath: "<<path, rc);
349 if (
rc_t rc = VFSManagerMakePath(mgr, &vpath, path.c_str()) ) {
352 "Cannot create VPath: "<<path, rc);
366 if (
size == 4 && memcmp(
buffer,
"file", 4) == 0 ) {
369 if (
size == 9 && memcmp(
buffer,
"ncbi-file", 9) == 0 ) {
378 const String*
str = 0;
380 if (
rc_t rc = VPathMakeSysPath(*
this, &
str)) {
382 "Cannot get path from VPath", rc);
386 if (
rc_t rc = VPathMakeString(*
this, &
str)) {
388 "Cannot get path from VPath", rc);
391 string ret(
str->addr,
str->size);
402 return s.length() >= 2 &&
isalpha(s[0]&0xff) && s[1] ==
':';
411 acc_or_path.find_first_of(
"/\\") ==
NPOS;
413 return acc_or_path.find(
'/') ==
NPOS;
423 if ( sys_path[0] ==
'h' &&
430 replace(path.begin(), path.end(),
'\\',
'/');
433 path[1] =
toupper(path[0] & 0xff);
464 "Cannot get VResolver", rc);
472 if (
rc_t rc = VFSManagerMakeResolver(mgr,
x_InitPtr(), cfg) ) {
475 "Cannot create VResolver", rc);
489 rc_t rc = VResolverLocal(*
this, acc, &path);
491 if ( GetRCObject(rc) == rcName &&
492 GetRCState(rc) == rcNotFound &&
493 GetRCContext(rc) == rcResolving ) {
498 "VResolverLocal("<<acc_or_path<<
") failed", rc);
500 rc = VResolverRemote(*
this, eProtocolNone, acc, &path);
504 if ( GetRCObject(rc) == rcName &&
505 GetRCState(rc) == rcNotFound &&
506 GetRCContext(rc) == rcResolving ) {
511 "VResolverRemote("<<acc_or_path<<
") failed", rc);
519 "Cannot find acc path: "<<acc_or_path, rc);
562 LOG_POST_X(6,
"CVDBMgr: resolving VDB accession: " << acc_or_path);
566 LOG_POST_X(4,
"CVDBMgr: resolved VDB accession: " << acc_or_path <<
" -> " << path);
576 LOG_POST_X(7,
"CVDBMgr: checking file symbolic link: " << acc_or_path <<
" -> " << path);
584 LOG_POST_X(5,
"CVDBMgr: resolved file symbolic link: " << acc_or_path <<
" -> " << path);
595 if ( path[0] ==
'h' &&
603 if ( !
CDirEntry(path).GetTime(×tamp) ) {
605 "Cannot get timestamp of local path: " << path);
612 LOG_POST_X(3,
"CVDBMgr: timestamp of " << path <<
": " <<
CTime(timestamp).ToLocalTime());
625 :
public CSraRef<KClientHttpRequest>
630 const ver_t kHTTP_1_1 = 0x01010000;
633 "%s", path.c_str()) ) {
637 "Cannot create http client request", rc);
646 :
public CSraRef<KClientHttpResult>
655 if (
rc_t rc = KClientHttpRequestHEAD(request,
x_InitPtr()) ) {
659 "Cannot get http HEAD", rc);
675 if (
rc_t rc = KClientHttpResultGetHeader(
result,
"Last-Modified",
679 "No Last-Modified header in HEAD response", rc);
688 #ifdef NCBI_COMPILER_MSVC
693 # define DECLARE_SDK_GUARD() CFastMutexGuard guard(sx_SDKMutex)
695 # define DECLARE_SDK_GUARD()
699 # define DECLARE_SDK_GET_GUARD() CFastMutexGuard guard(sx_SDKMutex)
701 # define DECLARE_SDK_GET_GUARD()
720 SraReleaseVersion release_version;
721 SraReleaseVersionGet(&release_version);
722 s << (release_version.version>>24) <<
'.'
723 << ((release_version.version>>16)&0xff) <<
'.'
724 << (release_version.version&0xffff);
725 if ( release_version.revision != 0 ||
726 release_version.type != SraReleaseVersion::eSraReleaseVersionTypeFinal ) {
727 const char*
type =
"";
728 switch ( release_version.type ) {
729 case SraReleaseVersion::eSraReleaseVersionTypeDev:
type =
"dev";
break;
730 case SraReleaseVersion::eSraReleaseVersionTypeAlpha:
type =
"a";
break;
731 case SraReleaseVersion::eSraReleaseVersionTypeBeta:
type =
"b";
break;
732 case SraReleaseVersion::eSraReleaseVersionTypeRC:
type =
"RC";
break;
733 default:
type =
"";
break;
735 s <<
'-' <<
type << release_version.revision;
764 if ( !token.
empty() && token[token.
size()-1] ==
':' ) {
766 if ( token ==
tag.tag ) {
775 static thread::id s_DiagCheckThreadID;
781 s_DiagCheckThreadID = this_thread::get_id();
788 return s_DiagCheckThreadID == this_thread::get_id();
802 for (
SIZE_TYPE token_pos = 0, token_end; token_pos <
msg.size(); token_pos = token_end + 1 ) {
803 token_end =
msg.find(
' ', token_pos);
804 if ( token_end ==
NPOS ) {
805 token_end =
msg.size();
808 sev_manip =
tag->manip;
812 if ( sev_manip ==
Trace ) {
831 string host = app->GetConfig().GetString(
"CONN",
"HTTP_PROXY_HOST",
kEmptyStr);
832 int port = app->GetConfig().GetInt(
"CONN",
"HTTP_PROXY_PORT", 0);
833 if ( !host.empty() && port != 0 ) {
837 "/http/proxy/path", path.c_str()) ) {
839 "Cannot set KConfig proxy path", rc);
842 "/http/proxy/enabled",
true) ) {
844 "Cannot set KConfig proxy enabled", rc);
875 if ( &req_ctx == s_LastRequestContext && req_ctx_version == s_LastRequestContextVersion ) {
878 _TRACE(
"CVDBMgr: Updating request context with version: "<<req_ctx_version);
879 s_LastRequestContext = &req_ctx;
880 s_LastRequestContextVersion = req_ctx_version;
884 KNSManagerSetSessionID(kns_mgr, req_ctx.
GetSessionID().c_str());
888 KNSManagerSetClientIP(kns_mgr, req_ctx.
GetClientIP().c_str());
892 KNSManagerSetPageHitID(kns_mgr, req_ctx.
GetHitID().c_str());
901 if (
rc_t rc = KNSManagerSetAllowAllCerts(kns_mgr,
true) ) {
903 "Cannot enable all HTTPS certificates in KNSManager", rc);
916 #ifdef NCBI_PRODUCTION_VER
917 str << NCBI_PRODUCTION_VER <<
"/";
919 #ifdef NCBI_DEVELOPMENT_VER
923 KNSManagerSetUserAgent(kns_mgr,
"%s; VDB %s",
945 static bool initialized =
false;
946 if ( !initialized ) {
953 ask_level = klogDebug;
955 ask_level = klogInfo;
958 KLogLevelSet(ask_level);
962 const char*
msg =
"info: VDB initialized";
981 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
995 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
996 size_t r = s_RequestContextUpdaterRecursion;
997 s_RequestContextUpdaterRecursion =
r+1;
1009 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
1010 size_t r = s_RequestContextUpdaterRecursion;
1011 s_RequestContextUpdaterRecursion =
r+1;
1023 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
1024 size_t r = s_RequestContextUpdaterRecursion;
1025 s_RequestContextUpdaterRecursion =
r-1;
1032 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
1033 size_t r = s_RequestContextUpdaterRecursion;
1034 s_RequestContextUpdaterRecursion =
r-1;
1045 "Cannot open VDBManager", rc);
1048 VFSManagerLogNamesServiceErrors(vfs_mgr,
false);
1051 VDBManagerDisablePagemapThread(*
this);
1059 if (
rc_t rc = VDBManagerGetCacheRoot(*
this, &ret) ) {
1060 if ( GetRCObject(rc) == RCObject(rcPath) &&
1061 GetRCState(rc) == rcNotFound ) {
1065 "CVDBMgr: Cannot get cache root", rc);
1074 if (
rc_t rc = VDBManagerSetCacheRoot(*
this, vpath) ) {
1076 "CVDBMgr: Cannot set cache root", rc);
1083 if (
rc_t rc = VDBManagerDeleteCacheOlderThan(*
this, days) ) {
1085 "CVDBMgr: Cannot delete old cache files", rc);
1100 : m_Name(acc_or_path)
1103 LOG_POST_X(8,
"CVDBMgr: opening VDB: " << acc_or_path);
1109 if (
rc_t rc = VDBManagerOpenDBRead(mgr,
x_InitPtr(), 0,
"%.*s",
1110 int(path.size()), path.data()) ) {
1112 string msg =
"Cannot open VDB: "+acc_or_path;
1114 if ( (GetRCObject(rc) == RCObject(rcDirectory) ||
1115 GetRCObject(rc) == RCObject(rcPath) ||
1116 GetRCObject(rc) == RCObject(rcFile)) &&
1117 GetRCState(rc) == rcNotFound ) {
1121 else if ( GetRCObject(rc) == rcName &&
1122 GetRCState(rc) == rcNotFound &&
1123 GetRCContext(rc) == rcResolving ) {
1127 else if ( GetRCObject(rc) == RCObject(rcFile) &&
1128 GetRCState(rc) == rcUnauthorized ) {
1132 else if ( GetRCObject(rc) == RCObject(rcDatabase) &&
1133 GetRCState(rc) == rcIncorrect ) {
1143 LOG_POST_X(9,
"CVDBMgr: opened VDB: " << acc_or_path <<
" (" << path <<
")");
1146 const KDatabase* kdb = 0;
1147 if (
rc_t rc = VDatabaseOpenKDatabaseRead(*
this, &kdb) ) {
1150 const char* kdb_path = 0;
1151 if (
rc_t rc = KDatabaseGetPath(kdb, &kdb_path) ) {
1154 LOG_POST(
"CVDB("<<acc_or_path<<
") -> "<<path<<
" -> "<<kdb_path);
1155 if (
rc_t rc = KDatabaseRelease(kdb) ) {
1191 RCState rc_state = GetRCState(rc);
1192 int rc_object = GetRCObject(rc);
1193 if ( rc_state == rcNotFound &&
1194 (rc_object == rcParam ||
1195 rc_object == rcPath) ) {
1211 const string& acc_or_path,
1213 : m_Name(acc_or_path)
1220 if (
rc_t rc = VDBManagerOpenTableRead(mgr,
x_InitPtr(), 0,
"%.*s",
1221 int(path.size()), path.data()) ) {
1223 string msg =
"Cannot open VDB: "+acc_or_path;
1225 if ( (GetRCObject(rc) == RCObject(rcDirectory) ||
1226 GetRCObject(rc) == RCObject(rcPath)) &&
1227 GetRCState(rc) == rcNotFound ) {
1234 else if ( GetRCObject(rc) == RCObject(rcDatabase) &&
1235 GetRCState(rc) == rcIncorrect ) {
1279 const char* index_name,
1290 if ( GetRCObject(rc) == RCObject(rcIndex) &&
1291 GetRCState(rc) == rcNotFound ) {
1320 if (
rc_t rc = KIndexFindText(*
this,
value.c_str(),
1323 if ( GetRCObject(rc) == RCObject(rcString) &&
1324 GetRCState(rc) == rcNotFound ) {
1330 "Cannot find value in index: "<<*
this<<
": "<<
value, rc);
1352 "Cannot init VDB cursor again",
1353 RC(rcApp, rcCursor, rcConstructing, rcSelf, rcOpen));
1357 "Cannot init VDB cursor",
1358 RC(rcApp, rcCursor, rcConstructing, rcTable, rcNull));
1364 "Cannot create VDB cursor: "<<
table, rc);
1366 if (
rc_t rc = VCursorPermitPostOpenAdd(*
this) ) {
1368 "Cannot allow VDB cursor post open column add: "<<
table, rc);
1370 if (
rc_t rc = VCursorOpen(*
this) ) {
1373 "Cannot open VDB cursor: "<<
table, rc);
1384 if (
rc_t rc = VCursorCloseRow(*
this) ) {
1386 "Cannot close VDB cursor row", rc);
1396 if (
rc_t rc = VCursorSetRowId(*
this, row_id) ) {
1399 if (
rc_t rc = VCursorOpenRow(*
this) ) {
1412 "Cannot open VDB cursor row: "<<*
this<<
": "<<row_id, rc);
1420 if (
rc_t rc = VCursorIdRange(*
this,
column, &ret.first, &ret.second) ) {
1423 "Cannot get VDB cursor row range: "<<*
this<<
": "<<
column, rc);
1439 if (
rc_t rc = VCursorParamsSet
1441 name,
"%.*s",
value.size(),
value.data()) ) {
1443 "Cannot set VDB cursor param: "<<*
this<<
": "<<name,
1454 uint32_t read_count, remaining_count;
1455 if (
rc_t rc = VCursorReadBitsDirect(*
this,
row,
column.GetIndex(),
1456 elem_bits, 0, 0, 0, 0,
1457 &read_count, &remaining_count) ) {
1461 "Cannot read VDB value array size: "<<*
this<<
column<<
1464 return remaining_count;
1475 uint32_t read_count, remaining_count;
1476 if (
rc_t rc = VCursorReadBitsDirect(*
this,
row,
column.GetIndex(),
1478 &read_count, &remaining_count) ) {
1480 '['<<
row<<
"]["<<start<<
".."<<(start+
count-1)<<
']', rc);
1482 "Cannot read VDB value array: "<<*
this<<
column<<
1483 '['<<
row<<
"]["<<start<<
".."<<(start+
count-1)<<
']', rc);
1485 if ( read_count !=
count ) {
1487 "Cannot read VDB value array: "<<*
this<<
column<<
1488 '['<<
row<<
"]["<<start<<
".."<<(start+
count-1)<<
1489 "] only "<<read_count<<
" elements are read");
1530 TObjects::iterator best_it;
1534 if ( slot_row >=
row ) {
1536 if ( d <= best_d ) {
1549 CObject* obj = best_it->second.Release();
1586 size_t element_bit_size,
1588 const char* backup_name,
1596 "NULL column name is not allowed"<<cursor<<*
this);
1603 if (
rc_t rc = VCursorAddColumn(cursor, &
m_Index, name) ) {
1606 (rc = VCursorAddColumn(cursor, &
m_Index, backup_name)) == 0 ) {
1614 "Cannot get VDB column: "<<cursor<<*
this,rc);
1621 if ( element_bit_size ) {
1626 "Cannot get VDB column type: "<<cursor<<*
this,rc);
1629 if (
size != element_bit_size ) {
1630 ERR_POST_X(1,
"Wrong VDB column size "<<cursor<<*
this<<
1631 " expected "<<element_bit_size<<
" bits != "<<
1632 type.intrinsic_dim<<
"*"<<
type.intrinsic_bits<<
" bits");
1634 "Wrong VDB column size: "<<cursor<<*
this<<
": "<<
size,
1635 RC(rcApp, rcColumn, rcConstructing, rcSelf, rcIncorrect));
1644 if (
rc_t rc = VCursorIsStaticColumn(cursor,
GetIndex(), &static_value) ) {
1646 "Cannot get static status of "<<cursor<<*
this,rc);
1648 return static_value;
1695 if (
rc_t rc = VCursorCellData(cursor,
column.GetIndex(),
1696 &bit_length, &
m_Data, &bit_offset,
1700 "Cannot read VDB value: "<<cursor<<
column, rc);
1704 "Cannot read VDB value with non-zero bit offset: "
1705 <<cursor<<
column<<
": "<<bit_offset,
1706 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1710 if ( bit_length == 8 ) {
1713 else if ( bit_length == 16 ) {
1721 else if ( bit_length == 32 ) {
1729 else if ( bit_length == 64 ) {
1738 s <<
"*** bad bit_length="<<bit_length;
1754 if (
rc_t rc = VCursorCellDataDirect(cursor,
row,
column.GetIndex(),
1755 &bit_length, &
m_Data, &bit_offset,
1764 "Cannot read VDB value: "<<cursor<<
column<<
'['<<
row<<
']', rc);
1768 "Cannot read VDB value with non-zero bit offset: "<<
1769 cursor<<
column<<
'['<<
row<<
"]: "<<bit_offset,
1770 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1774 if ( bit_length == 8 ) {
1777 else if ( bit_length == 16 ) {
1785 else if ( bit_length == 32 ) {
1793 else if ( bit_length == 64 ) {
1802 s <<
"*** bad bit_length="<<bit_length;
1812 if ( index >=
size() ) {
1814 "Invalid index for VDB value array: "<<
1815 *
this<<
'['<<index<<
']',
1816 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1823 if (
size() != 1 ) {
1825 "VDB value array doen't have single value: "<<
1826 *
this<<
'['<<
size()<<
']',
1827 RC(rcApp, rcData, rcRetrieving, rcSize, rcIncorrect));
1834 if ( pos >
size() ) {
1836 "Invalid index for VDB value array: "<<
1837 *
this<<
'['<<pos<<
']',
1838 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1840 if ( pos+
len < pos ) {
1842 "Invalid length for VDB value sub-array: "<<
1843 *
this<<
'['<<pos<<
','<<
len<<
']',
1844 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1848 "Invalid end of VDB value sub-array: "<<
1849 *
this<<
'['<<pos<<
','<<
len<<
']',
1850 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1868 uint32_t bit_offset, bit_length, elem_count;
1870 if (
rc_t rc = VCursorCellDataDirect(cursor,
row,
column.GetIndex(),
1871 &bit_length, &
data, &bit_offset,
1876 "Cannot read VDB 4-bits value array: "<<
1879 if ( bit_offset >= 8 || (bit_offset&3) ) {
1881 "Cannot read VDB 4-bits value array with odd bit offset"<<
1882 cursor<<
column<<
'['<<
row<<
"]: "<<bit_offset,
1883 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1885 m_RawData =
static_cast<const char*
>(
data);
1886 m_ElemOffset = bit_offset >> 2;
1890 if ( bit_length == 4 ) {
1899 s <<
"*** bad bit_length="<<bit_length;
1909 if ( index >=
size() ) {
1911 "Invalid index for VDB 4-bits value array: "<<
1912 *
this<<
'['<<index<<
']',
1913 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1921 if ( pos >
size() ) {
1923 "Invalid index for VDB 4-bits value array: "<<
1924 *
this<<
'['<<pos<<
']',
1925 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1927 if ( pos+
len < pos ) {
1929 "Invalid length for VDB 4-bits value sub-array: "<<
1930 *
this<<
'['<<pos<<
','<<
len<<
']',
1931 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1935 "Invalid end of VDB 4-bits value sub-array: "<<
1936 *
this<<
'['<<pos<<
','<<
len<<
']',
1937 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1945 size_t offset = m_ElemOffset + pos;
1946 const char* raw_data = m_RawData +
offset/2;
1966 uint32_t bit_offset, bit_length, elem_count;
1968 if (
rc_t rc = VCursorCellDataDirect(cursor,
row,
column.GetIndex(),
1969 &bit_length, &
data, &bit_offset,
1974 "Cannot read VDB 2-bits value array: "<<
1977 if ( bit_offset >= 8 || (bit_offset&1) ) {
1979 "Cannot read VDB 2-bits value array with odd bit offset"<<
1980 cursor<<
column<<
'['<<
row<<
"]: "<<bit_offset,
1981 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1983 m_RawData =
static_cast<const char*
>(
data);
1984 m_ElemOffset = bit_offset >> 1;
1988 if ( bit_length == 2 ) {
1997 s <<
"*** bad bit_length="<<bit_length;
2007 if ( index >=
size() ) {
2009 "Invalid index for VDB 2-bits value array: "<<
2010 *
this<<
'['<<index<<
']',
2011 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
2019 if ( pos >
size() ) {
2021 "Invalid index for VDB 2-bits value array: "<<
2022 *
this<<
'['<<pos<<
']',
2023 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
2025 if ( pos+
len < pos ) {
2027 "Invalid length for VDB 2-bits value sub-array: "<<
2028 *
this<<
'['<<pos<<
','<<
len<<
']',
2029 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
2033 "Invalid end of VDB 2-bits value sub-array: "<<
2034 *
this<<
'['<<pos<<
','<<
len<<
']',
2035 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
2043 size_t offset = m_ElemOffset + pos;
2044 const char* raw_data = m_RawData +
offset/4;
CClientHttpRequest(const CKNSManager &mgr, const string &path)
CClientHttpResult(const CClientHttpRequest &request, EHead)
CFinalRequestContextUpdater()
CFinalRequestContextUpdater(const CFinalRequestContextUpdater &)=delete
~CFinalRequestContextUpdater()
CKDBManager(const CVDBMgr &mgr)
CKNSManager(const CVFSManager &mgr)
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
TObject ** x_InitPtr(void)
TObject * GetPointer(void) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
TVDBColumnIdx GetIndex(void) const
void ResetIfAlwaysEmpty(const CVDBCursor &cursor)
bool IsStatic(const CVDBCursor &cursor) const
void Init(const CVDBCursor &cursor, size_t element_bit_size, const char *name, const char *backup_name, EMissing missing)
rc_t OpenRowRc(TVDBRowId row_id)
void OpenRow(TVDBRowId row_id)
bool RowIsOpened(void) const
uint32_t GetElementCount(TVDBRowId row, const CVDBColumn &column, uint32_t elem_bits) const
const CVDBTable & GetTable(void) const
void ReadElements(TVDBRowId row, const CVDBColumn &column, uint32_t elem_bits, uint32_t start, uint32_t count, void *buffer) const
void SetParam(const char *name, const CTempString &value) const
void Init(const CVDBTable &table)
TVDBRowId GetMaxRowId(void) const
TVDBRowIdRange GetRowIdRange(TVDBColumnIdx column=0) const
~CRequestContextUpdater()
void DeleteCacheOlderThan(Uint4 days)
static int SetDebugLevel(int new_level)
string GetCacheRoot() const
string FindDereferencedAccPath(const string &acc_or_path) const
CTime GetTimestamp(const string &path) const
CTime GetURLTimestamp(const string &url) const
string FindAccPath(const string &acc) const
void SetCacheRoot(const string &path)
static int GetDebugLevel()
void CommitConfig() const
CObject * Get(TVDBRowId row)
void Put(CObject *curs, TVDBRowId row)
pair< TVDBRowId, CRef< CObject > > TSlot
~CVDBObjectCacheBase(void)
CVDBObjectCacheBase(void)
string GetFullName(void) const
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
const char * GetName(void) const
const CVDBTable & GetTable(void) const
TVDBRowIdRange Find(const string &value) const
string GetFullName(void) const
const CVDB & GetDb(void) const
const string & GetName(void) const
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
void x_Get(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column)
void x_ReportIndexOutOfBounds(size_t index) const
CVDBValueFor2Bits substr(size_t pos, size_t len) const
void x_CheckRange(size_t pos, size_t len) const
void x_CheckRange(size_t pos, size_t len) const
CVDBValueFor4Bits substr(size_t pos, size_t len) const
void x_ReportIndexOutOfBounds(size_t index) const
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
void x_Get(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column)
void x_CheckRange(size_t pos, size_t len) const
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
void x_Get(const CVDBCursor &cursor, const CVDBColumn &column)
void x_ReportNotOneValue(void) const
void x_ReportIndexOutOfBounds(size_t index) const
const string & GetFullName(void) const
const string & GetName(void) const
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
string ToString(EType type=eSys) const
static string ConvertAccOrSysPathToPOSIX(const string &acc_or_path)
void x_Init(const CVFSManager &mgr, const string &path, EType type)
static bool IsPlainAccession(const string &acc_or_path)
static string ConvertSysPathToPOSIX(const string &sys_path)
CVResolver(const CVFSManager &mgr)
string Resolve(const string &acc) const
std::ofstream out("events_result.xml")
main entry point for tests
static const char table_name[]
static const char * str(char *buf, int n)
static const char * column
static string GetAppName(EAppNameType name_type=eBaseName, int argc=0, const char *const *argv=NULL)
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
CVersionInfo GetVersion(void) const
Get the program version information.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST_X(err_subcode, message)
const CNcbiDiag &(* FManip)(const CNcbiDiag &)
Diagnostic stream manipulator.
string GetSessionID(void) const
Session ID.
CAtomicCounter::TValue TVersion
bool IsSetSessionID(void) const
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
string GetClientIP(void) const
Client IP/hostname.
bool IsSetHitID(EHitIDSource src=eHitID_Any) const
Check if there's an explicit hit id or the default one.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
bool IsSetClientIP(void) const
string GetHitID(void) const
Get explicit hit id or the default one (from HTTP_NCBI_PHID etc).
TVersion GetVersion(void) const
Return version increased on every context change (hit/subhit id, client ip, session id).
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
void Trace(CExceptionArgs_Base &args)
void Warning(CExceptionArgs_Base &args)
void Fatal(CExceptionArgs_Base &args)
#define NCBI_THROW2(exception_class, err_code, message, extra)
Throw exception with extra parameter.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
void Info(CExceptionArgs_Base &args)
static string CreateAbsolutePath(const string &path, ERelativeToWhat rtw=eRelativeToCwd)
Get an absolute path from some, possibly relative, path.
void DereferencePath(void)
Dereference a path.
virtual bool Exists(void) const
Check the entry existence.
const string & GetPath(void) const
Get entry path.
bool Referenced(void) const THROWS_NONE
Check if object is referenced.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
uint32_t Uint4
4-byte (32-bit) unsigned integer
virtual bool GetBool(const string §ion, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get boolean value of specified parameter name.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
NCBI_NS_STD::string::size_type SIZE_TYPE
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
size_type size(void) const
Return the length of the represented array.
bool IsUniversalTime(void) const
Is time universal (GMT/UTC/Z)?
bool IsEmpty(void) const
Is time object empty (date and time)?
CTime & ToUniversalTime(void)
Convert the time into universal (GMT/UTC) time.
virtual string Print(void) const
Print version information.
#define NCBI_SRAREAD_EXPORT
#define NCBI_DEVELOPMENT_VER
Definition of all error codes used in SRA C++ support libraries.
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
const TYPE & Get(const CNamedParameterList *param)
range(_Ty, _Ty) -> range< _Ty >
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
string s_Value(TValue value)
const GenericPointer< typename T::ValueType > T2 value
#define NCBI_PACKAGE_NAME
#define NCBI_PACKAGE_VERSION
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Multi-threading – mutexes; rw-locks; semaphore.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Defines CRequestContext class for NCBI C++ diagnostic API.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define CHECK_VDB_TIMEOUT_FMT(msg, rc)
#define CHECK_VDB_TIMEOUT(msg, rc)
#define NCBI_THROW2_FMT(exception_class, err_code, message, extra)
#define row(bind, expected)
void Set(const CVDBCursor &cursor, TVDBRowId row, const CVDBColumn &column)
const CVDBTable * m_Table
const char * m_ColumnName
CNcbiOstream & PrintFullName(CNcbiOstream &out) const
static const SVDBSeverityTag kSeverityTags[]
static int & s_GetDebugLevelVar(void)
static const size_t kCacheSize
static char s_VDBVersion[32]
static bool s_HasWindowsDriveLetter(const string &s)
static rc_t VDBLogWriter(void *, const char *buffer, size_t size, size_t *written)
DEFINE_SRA_REF_TRAITS(VDBManager, const)
static void s_InitLocalKNS(KNSManager *kns_mgr)
DECLARE_SRA_REF_TRAITS(KClientHttpRequest,)
static void s_InitAllKNS(KNSManager *kns_mgr)
static int s_GetDiagHandler(void)
static const SVDBSeverityTag * s_GetVDBSeverityTag(CTempString token)
DEFINE_STATIC_FAST_MUTEX(sx_SDKMutex)
static void s_InitVDBVersion()
#define SIMULATE_RESOLVE_ERROR()
static CKConfig s_InitProxyConfig()
#define DECLARE_SDK_GET_GUARD()
static void s_InitStaticKNS(KNSManager *kns_mgr)
#define SIMULATE_SCHEMA_ERROR()
static void s_InitDiagCheck()
#define DECLARE_SDK_GUARD()
static bool s_DiagIsSafe()
NCBI_DEFINE_ERR_SUBCODE_X(9)
NCBI_PARAM_DEF(int, VDB, DIAG_HANDLER, 1)
static void s_UpdateVDBRequestContext(void)
static int s_SetDebugLevel(int new_level)
NCBI_PARAM_DECL(int, VDB, DIAG_HANDLER)
NCBI_PARAM_DEF_EX(int, VDB, DEBUG, 0, eParam_NoThread, VDB_DEBUG)
static DECLARE_TLS_VAR(const CRequestContext *, s_LastRequestContext)
static CNcbiOstream & operator<<(CNcbiOstream &out, const CVDBTable &obj)
static int s_GetDebugLevel()
#define SIMULATE_OPEN_ERROR()
pair< TVDBRowId, TVDBRowCount > TVDBRowIdRange