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>
82 #define NCBI_USE_ERRCODE_X VDBReader
128 #define FAILS_VAR(name, suffix) NCBI_NAME3(VDB_, name, suffix)
130 #define VDB_RESOLVE_RANDOM_FAILS 1
131 #define VDB_OPEN_RANDOM_FAILS 1
132 #define VDB_SCHEMA_RANDOM_FAILS 1
133 #define VDB_READ_RANDOM_FAILS 1
135 #define VDB_RESOLVE_RANDOM_FAILS_FREQUENCY 20
136 #define VDB_RESOLVE_RANDOM_FAILS_RECOVER 10
137 #define VDB_OPEN_RANDOM_FAILS_FREQUENCY 10
138 #define VDB_OPEN_RANDOM_FAILS_RECOVER 5
139 #define VDB_SCHEMA_RANDOM_FAILS_FREQUENCY 50
140 #define VDB_SCHEMA_RANDOM_FAILS_RECOVER 100
141 #define VDB_READ_RANDOM_FAILS_FREQUENCY 20000
142 #define VDB_READ_RANDOM_FAILS_RECOVER 1000
144 #if defined(VDB_RANDOM_FAILS)
145 # define SIMULATE_ERROR(name) \
146 if ( !(FAILS_VAR(name, _RANDOM_FAILS)) ) { \
149 static thread_local unsigned recover_counter = 0; \
150 if ( recover_counter > 0 ) { \
154 if ( (rand() % (FAILS_VAR(name, _RANDOM_FAILS_FREQUENCY))) == 0 ) { \
155 recover_counter = (FAILS_VAR(name, _RANDOM_FAILS_RECOVER)); \
156 ERR_POST("VDB: Simulated " #name " failure: "<<CStackTrace()); \
157 NCBI_THROW(CSraException, eOtherError, \
158 "Simulated " #name " failure"); \
163 # define SIMULATE_ERROR(name) ((void)0)
166 #define SIMULATE_RESOLVE_ERROR() SIMULATE_ERROR(RESOLVE)
167 #define SIMULATE_OPEN_ERROR() SIMULATE_ERROR(OPEN)
168 #define SIMULATE_SCHEMA_ERROR() SIMULATE_ERROR(SCHEMA)
169 #define SIMULATE_READ_ERROR() SIMULATE_ERROR(READ)
178 if (
rc_t rc = KConfigMake(&cfg, 0) ) {
181 "Cannot create KConfig", rc);
190 if (
rc_t rc = KConfigAddRef(*
this) ) {
193 "Cannot get reference to KConfig", rc);
202 "Cannot create KConfig singleton", rc);
209 if (
rc_t rc = KConfigCommit(
const_cast<KConfig*
>(
GetPointer())) ) {
211 "CKConfig: Cannot commit config changes", rc);
236 "Cannot create VFSManager", rc);
246 "Cannot get VFSManager", rc);
257 if (
rc_t rc = VDBManagerGetKDBManagerRead(mgr,
x_InitPtr()) ) {
260 "Cannot get KDBManager", rc);
274 "Cannot make KNSManager", rc);
284 "Cannot get KNSManager", rc);
308 if (
rc_t rc = VFSManagerMakeSysPath(mgr, &vpath, path.c_str()) ) {
311 "Cannot create sys VPath: "<<path, rc);
315 if (
rc_t rc = VFSManagerMakeAccPath(mgr, &vpath, path.c_str()) ) {
318 "Cannot create acc VPath: "<<path, rc);
322 if (
rc_t rc = VFSManagerMakePath(mgr, &vpath, path.c_str()) ) {
325 "Cannot create VPath: "<<path, rc);
339 if (
size == 4 && memcmp(
buffer,
"file", 4) == 0 ) {
342 if (
size == 9 && memcmp(
buffer,
"ncbi-file", 9) == 0 ) {
351 const String*
str = 0;
353 if (
rc_t rc = VPathMakeSysPath(*
this, &
str)) {
355 "Cannot get path from VPath", rc);
359 if (
rc_t rc = VPathMakeString(*
this, &
str)) {
361 "Cannot get path from VPath", rc);
364 string ret(
str->addr,
str->size);
375 return s.length() >= 2 &&
isalpha(s[0]&0xff) && s[1] ==
':';
384 acc_or_path.find_first_of(
"/\\") ==
NPOS;
386 return acc_or_path.find(
'/') ==
NPOS;
396 if ( sys_path[0] ==
'h' &&
403 replace(path.begin(), path.end(),
'\\',
'/');
406 path[1] =
toupper(path[0] & 0xff);
437 "Cannot get VResolver", rc);
445 if (
rc_t rc = VFSManagerMakeResolver(mgr,
x_InitPtr(), cfg) ) {
448 "Cannot create VResolver", rc);
462 rc_t rc = VResolverLocal(*
this, acc, &path);
464 if ( GetRCObject(rc) == rcName &&
465 GetRCState(rc) == rcNotFound &&
466 GetRCContext(rc) == rcResolving ) {
471 "VResolverLocal("<<acc_or_path<<
") failed", rc);
473 rc = VResolverRemote(*
this, eProtocolNone, acc, &path);
477 if ( GetRCObject(rc) == rcName &&
478 GetRCState(rc) == rcNotFound &&
479 GetRCContext(rc) == rcResolving ) {
484 "VResolverRemote("<<acc_or_path<<
") failed", rc);
492 "Cannot find acc path: "<<acc_or_path, rc);
524 LOG_POST_X(4,
"CVDBMgr: resolved accession: " << acc_or_path <<
" -> " << path);
539 LOG_POST_X(5,
"CVDBMgr: resolved file link: " << acc_or_path <<
" -> " << path);
550 if ( path[0] ==
'h' &&
558 if ( !
CDirEntry(path).GetTime(×tamp) ) {
560 "Cannot get timestamp of local path: " << path);
567 LOG_POST_X(3,
"CVDBMgr: timestamp of " << path <<
": " <<
CTime(timestamp).ToLocalTime());
580 :
public CSraRef<KClientHttpRequest>
585 const ver_t kHTTP_1_1 = 0x01010000;
588 "%s", path.c_str()) ) {
592 "Cannot create http client request", rc);
601 :
public CSraRef<KClientHttpResult>
610 if (
rc_t rc = KClientHttpRequestHEAD(request,
x_InitPtr()) ) {
614 "Cannot get http HEAD", rc);
630 if (
rc_t rc = KClientHttpResultGetHeader(
result,
"Last-Modified",
634 "No Last-Modified header in HEAD response", rc);
643 #ifdef NCBI_COMPILER_MSVC
648 # define DECLARE_SDK_GUARD() CFastMutexGuard guard(sx_SDKMutex)
650 # define DECLARE_SDK_GUARD()
654 # define DECLARE_SDK_GET_GUARD() CFastMutexGuard guard(sx_SDKMutex)
656 # define DECLARE_SDK_GET_GUARD()
675 SraReleaseVersion release_version;
676 SraReleaseVersionGet(&release_version);
677 s << (release_version.version>>24) <<
'.'
678 << ((release_version.version>>16)&0xff) <<
'.'
679 << (release_version.version&0xffff);
680 if ( release_version.revision != 0 ||
681 release_version.type != SraReleaseVersion::eSraReleaseVersionTypeFinal ) {
682 const char*
type =
"";
683 switch ( release_version.type ) {
684 case SraReleaseVersion::eSraReleaseVersionTypeDev:
type =
"dev";
break;
685 case SraReleaseVersion::eSraReleaseVersionTypeAlpha:
type =
"a";
break;
686 case SraReleaseVersion::eSraReleaseVersionTypeBeta:
type =
"b";
break;
687 case SraReleaseVersion::eSraReleaseVersionTypeRC:
type =
"RC";
break;
688 default:
type =
"";
break;
690 s <<
'-' <<
type << release_version.revision;
719 if ( !token.
empty() && token[token.
size()-1] ==
':' ) {
721 if ( token ==
tag.tag ) {
730 static thread::id s_DiagCheckThreadID;
736 s_DiagCheckThreadID = this_thread::get_id();
743 return s_DiagCheckThreadID == this_thread::get_id();
757 for (
SIZE_TYPE token_pos = 0, token_end; token_pos < msg.
size(); token_pos = token_end + 1 ) {
758 token_end = msg.
find(
' ', token_pos);
759 if ( token_end ==
NPOS ) {
760 token_end = msg.
size();
763 sev_manip =
tag->manip;
767 if ( sev_manip ==
Trace ) {
786 string host = app->GetConfig().GetString(
"CONN",
"HTTP_PROXY_HOST",
kEmptyStr);
787 int port = app->GetConfig().GetInt(
"CONN",
"HTTP_PROXY_PORT", 0);
788 if ( !host.empty() && port != 0 ) {
792 "/http/proxy/path", path.c_str()) ) {
794 "Cannot set KConfig proxy path", rc);
797 "/http/proxy/enabled",
true) ) {
799 "Cannot set KConfig proxy enabled", rc);
830 if ( &req_ctx == s_LastRequestContext && req_ctx_version == s_LastRequestContextVersion ) {
833 _TRACE(
"CVDBMgr: Updating request context with version: "<<req_ctx_version);
834 s_LastRequestContext = &req_ctx;
835 s_LastRequestContextVersion = req_ctx_version;
839 KNSManagerSetSessionID(kns_mgr, req_ctx.
GetSessionID().c_str());
843 KNSManagerSetClientIP(kns_mgr, req_ctx.
GetClientIP().c_str());
847 KNSManagerSetPageHitID(kns_mgr, req_ctx.
GetHitID().c_str());
856 if (
rc_t rc = KNSManagerSetAllowAllCerts(kns_mgr,
true) ) {
858 "Cannot enable all HTTPS certificates in KNSManager", rc);
871 #ifdef NCBI_PRODUCTION_VER
872 str << NCBI_PRODUCTION_VER <<
"/";
874 #ifdef NCBI_DEVELOPMENT_VER
878 KNSManagerSetUserAgent(kns_mgr,
"%s; VDB %s",
900 static bool initialized =
false;
901 if ( !initialized ) {
908 ask_level = klogDebug;
910 ask_level = klogInfo;
913 KLogLevelSet(ask_level);
917 const char* msg =
"info: VDB initialized";
936 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
950 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
951 size_t r = s_RequestContextUpdaterRecursion;
952 s_RequestContextUpdaterRecursion =
r+1;
964 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
965 size_t r = s_RequestContextUpdaterRecursion;
966 s_RequestContextUpdaterRecursion =
r+1;
978 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
979 size_t r = s_RequestContextUpdaterRecursion;
980 s_RequestContextUpdaterRecursion =
r-1;
987 #ifndef UPDATE_REQUEST_CONTEXT_FINAL
988 size_t r = s_RequestContextUpdaterRecursion;
989 s_RequestContextUpdaterRecursion =
r-1;
1000 "Cannot open VDBManager", rc);
1003 VFSManagerLogNamesServiceErrors(vfs_mgr,
false);
1011 if (
rc_t rc = VDBManagerGetCacheRoot(*
this, &ret) ) {
1012 if ( GetRCObject(rc) == RCObject(rcPath) &&
1013 GetRCState(rc) == rcNotFound ) {
1017 "CVDBMgr: Cannot get cache root", rc);
1026 if (
rc_t rc = VDBManagerSetCacheRoot(*
this, vpath) ) {
1028 "CVDBMgr: Cannot set cache root", rc);
1035 if (
rc_t rc = VDBManagerDeleteCacheOlderThan(*
this, days) ) {
1037 "CVDBMgr: Cannot delete old cache files", rc);
1052 : m_Name(acc_or_path)
1058 if (
rc_t rc = VDBManagerOpenDBRead(mgr,
x_InitPtr(), 0,
"%.*s",
1059 int(path.size()), path.data()) ) {
1061 string msg =
"Cannot open VDB: "+acc_or_path;
1063 if ( (GetRCObject(rc) == RCObject(rcDirectory) ||
1064 GetRCObject(rc) == RCObject(rcPath) ||
1065 GetRCObject(rc) == RCObject(rcFile)) &&
1066 GetRCState(rc) == rcNotFound ) {
1070 else if ( GetRCObject(rc) == rcName &&
1071 GetRCState(rc) == rcNotFound &&
1072 GetRCContext(rc) == rcResolving ) {
1076 else if ( GetRCObject(rc) == RCObject(rcFile) &&
1077 GetRCState(rc) == rcUnauthorized ) {
1081 else if ( GetRCObject(rc) == RCObject(rcDatabase) &&
1082 GetRCState(rc) == rcIncorrect ) {
1092 const KDatabase* kdb = 0;
1093 if (
rc_t rc = VDatabaseOpenKDatabaseRead(*
this, &kdb) ) {
1096 const char* kdb_path = 0;
1097 if (
rc_t rc = KDatabaseGetPath(kdb, &kdb_path) ) {
1100 LOG_POST(
"CVDB("<<acc_or_path<<
") -> "<<path<<
" -> "<<kdb_path);
1101 if (
rc_t rc = KDatabaseRelease(kdb) ) {
1137 RCState rc_state = GetRCState(rc);
1138 int rc_object = GetRCObject(rc);
1139 if ( rc_state == rcNotFound &&
1140 (rc_object == rcParam ||
1141 rc_object == rcPath) ) {
1157 const string& acc_or_path,
1159 : m_Name(acc_or_path)
1166 if (
rc_t rc = VDBManagerOpenTableRead(mgr,
x_InitPtr(), 0,
"%.*s",
1167 int(path.size()), path.data()) ) {
1169 string msg =
"Cannot open VDB: "+acc_or_path;
1171 if ( (GetRCObject(rc) == RCObject(rcDirectory) ||
1172 GetRCObject(rc) == RCObject(rcPath)) &&
1173 GetRCState(rc) == rcNotFound ) {
1180 else if ( GetRCObject(rc) == RCObject(rcDatabase) &&
1181 GetRCState(rc) == rcIncorrect ) {
1225 const char* index_name,
1234 string msg =
"Cannot open VDB table index: "+
GetFullName();
1236 if ( GetRCObject(rc) == RCObject(rcIndex) &&
1237 GetRCState(rc) == rcNotFound ) {
1266 if (
rc_t rc = KIndexFindText(*
this,
value.c_str(),
1269 if ( GetRCObject(rc) == RCObject(rcString) &&
1270 GetRCState(rc) == rcNotFound ) {
1276 "Cannot find value in index: "<<*
this<<
": "<<
value, rc);
1298 "Cannot init VDB cursor again",
1299 RC(rcApp, rcCursor, rcConstructing, rcSelf, rcOpen));
1303 "Cannot init VDB cursor",
1304 RC(rcApp, rcCursor, rcConstructing, rcTable, rcNull));
1310 "Cannot create VDB cursor: "<<
table, rc);
1312 if (
rc_t rc = VCursorPermitPostOpenAdd(*
this) ) {
1314 "Cannot allow VDB cursor post open column add: "<<
table, rc);
1316 if (
rc_t rc = VCursorOpen(*
this) ) {
1319 "Cannot open VDB cursor: "<<
table, rc);
1330 if (
rc_t rc = VCursorCloseRow(*
this) ) {
1332 "Cannot close VDB cursor row", rc);
1342 if (
rc_t rc = VCursorSetRowId(*
this, row_id) ) {
1345 if (
rc_t rc = VCursorOpenRow(*
this) ) {
1358 "Cannot open VDB cursor row: "<<*
this<<
": "<<row_id, rc);
1366 if (
rc_t rc = VCursorIdRange(*
this,
column, &ret.first, &ret.second) ) {
1369 "Cannot get VDB cursor row range: "<<*
this<<
": "<<
column, rc);
1385 if (
rc_t rc = VCursorParamsSet
1387 name,
"%.*s",
value.size(),
value.data()) ) {
1389 "Cannot set VDB cursor param: "<<*
this<<
": "<<name,
1400 uint32_t read_count, remaining_count;
1401 if (
rc_t rc = VCursorReadBitsDirect(*
this, row,
column.GetIndex(),
1402 elem_bits, 0, 0, 0, 0,
1403 &read_count, &remaining_count) ) {
1407 "Cannot read VDB value array size: "<<*
this<<
column<<
1410 return remaining_count;
1421 uint32_t read_count, remaining_count;
1422 if (
rc_t rc = VCursorReadBitsDirect(*
this, row,
column.GetIndex(),
1423 elem_bits, start,
buffer, 0, count,
1424 &read_count, &remaining_count) ) {
1426 '['<<row<<
"]["<<start<<
".."<<(start+count-1)<<
']', rc);
1428 "Cannot read VDB value array: "<<*
this<<
column<<
1429 '['<<row<<
"]["<<start<<
".."<<(start+count-1)<<
']', rc);
1431 if ( read_count != count ) {
1433 "Cannot read VDB value array: "<<*
this<<
column<<
1434 '['<<row<<
"]["<<start<<
".."<<(start+count-1)<<
1435 "] only "<<read_count<<
" elements are read");
1476 TObjects::iterator best_it;
1480 if ( slot_row >= row ) {
1482 if ( d <= best_d ) {
1495 CObject* obj = best_it->second.Release();
1532 size_t element_bit_size,
1534 const char* backup_name,
1541 if (
rc_t rc = VCursorAddColumn(cursor, &
m_Index, name) ) {
1544 (rc = VCursorAddColumn(cursor, &
m_Index, backup_name)) == 0 ) {
1552 "Cannot get VDB column: "<<cursor<<*
this,rc);
1559 if ( element_bit_size ) {
1564 "Cannot get VDB column type: "<<cursor<<*
this,rc);
1567 if (
size != element_bit_size ) {
1568 ERR_POST_X(1,
"Wrong VDB column size "<<cursor<<*
this<<
1569 " expected "<<element_bit_size<<
" bits != "<<
1570 type.intrinsic_dim<<
"*"<<
type.intrinsic_bits<<
" bits");
1572 "Wrong VDB column size: "<<cursor<<*
this<<
": "<<
size,
1573 RC(rcApp, rcColumn, rcConstructing, rcSelf, rcIncorrect));
1582 if (
rc_t rc = VCursorIsStaticColumn(cursor,
GetIndex(), &static_value) ) {
1584 "Cannot get static status of "<<cursor<<*
this,rc);
1586 return static_value;
1633 if (
rc_t rc = VCursorCellData(cursor,
column.GetIndex(),
1634 &bit_length, &
m_Data, &bit_offset,
1638 "Cannot read VDB value: "<<cursor<<
column, rc);
1642 "Cannot read VDB value with non-zero bit offset: "
1643 <<cursor<<
column<<
": "<<bit_offset,
1644 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1648 if ( bit_length == 8 ) {
1651 else if ( bit_length == 16 ) {
1659 else if ( bit_length == 32 ) {
1667 else if ( bit_length == 64 ) {
1676 s <<
"*** bad bit_length="<<bit_length;
1692 if (
rc_t rc = VCursorCellDataDirect(cursor, row,
column.GetIndex(),
1693 &bit_length, &
m_Data, &bit_offset,
1702 "Cannot read VDB value: "<<cursor<<
column<<
'['<<row<<
']', rc);
1706 "Cannot read VDB value with non-zero bit offset: "<<
1707 cursor<<
column<<
'['<<row<<
"]: "<<bit_offset,
1708 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1712 if ( bit_length == 8 ) {
1715 else if ( bit_length == 16 ) {
1723 else if ( bit_length == 32 ) {
1731 else if ( bit_length == 64 ) {
1740 s <<
"*** bad bit_length="<<bit_length;
1750 if ( index >=
size() ) {
1752 "Invalid index for VDB value array: "<<
1753 *
this<<
'['<<index<<
']',
1754 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1761 if (
size() != 1 ) {
1763 "VDB value array doen't have single value: "<<
1764 *
this<<
'['<<
size()<<
']',
1765 RC(rcApp, rcData, rcRetrieving, rcSize, rcIncorrect));
1772 if ( pos >
size() ) {
1774 "Invalid index for VDB value array: "<<
1775 *
this<<
'['<<pos<<
']',
1776 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1778 if ( pos+
len < pos ) {
1780 "Invalid length for VDB value sub-array: "<<
1781 *
this<<
'['<<pos<<
','<<
len<<
']',
1782 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1786 "Invalid end of VDB value sub-array: "<<
1787 *
this<<
'['<<pos<<
','<<
len<<
']',
1788 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1806 uint32_t bit_offset, bit_length, elem_count;
1808 if (
rc_t rc = VCursorCellDataDirect(cursor, row,
column.GetIndex(),
1809 &bit_length, &data, &bit_offset,
1812 cursor<<
column<<
'['<<row<<
']', rc);
1814 "Cannot read VDB 4-bits value array: "<<
1815 cursor<<
column<<
'['<<row<<
']', rc);
1817 if ( bit_offset >= 8 || (bit_offset&3) ) {
1819 "Cannot read VDB 4-bits value array with odd bit offset"<<
1820 cursor<<
column<<
'['<<row<<
"]: "<<bit_offset,
1821 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1823 m_RawData =
static_cast<const char*
>(data);
1824 m_ElemOffset = bit_offset >> 2;
1828 if ( bit_length == 4 ) {
1837 s <<
"*** bad bit_length="<<bit_length;
1847 if ( index >=
size() ) {
1849 "Invalid index for VDB 4-bits value array: "<<
1850 *
this<<
'['<<index<<
']',
1851 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1859 if ( pos >
size() ) {
1861 "Invalid index for VDB 4-bits value array: "<<
1862 *
this<<
'['<<pos<<
']',
1863 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1865 if ( pos+
len < pos ) {
1867 "Invalid length for VDB 4-bits value sub-array: "<<
1868 *
this<<
'['<<pos<<
','<<
len<<
']',
1869 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1873 "Invalid end of VDB 4-bits value sub-array: "<<
1874 *
this<<
'['<<pos<<
','<<
len<<
']',
1875 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1883 size_t offset = m_ElemOffset + pos;
1884 const char* raw_data = m_RawData +
offset/2;
1904 uint32_t bit_offset, bit_length, elem_count;
1906 if (
rc_t rc = VCursorCellDataDirect(cursor, row,
column.GetIndex(),
1907 &bit_length, &data, &bit_offset,
1910 cursor<<
column<<
'['<<row<<
']', rc);
1912 "Cannot read VDB 2-bits value array: "<<
1913 cursor<<
column<<
'['<<row<<
']', rc);
1915 if ( bit_offset >= 8 || (bit_offset&1) ) {
1917 "Cannot read VDB 2-bits value array with odd bit offset"<<
1918 cursor<<
column<<
'['<<row<<
"]: "<<bit_offset,
1919 RC(rcApp, rcColumn, rcDecoding, rcOffset, rcUnsupported));
1921 m_RawData =
static_cast<const char*
>(data);
1922 m_ElemOffset = bit_offset >> 1;
1926 if ( bit_length == 2 ) {
1935 s <<
"*** bad bit_length="<<bit_length;
1945 if ( index >=
size() ) {
1947 "Invalid index for VDB 2-bits value array: "<<
1948 *
this<<
'['<<index<<
']',
1949 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1957 if ( pos >
size() ) {
1959 "Invalid index for VDB 2-bits value array: "<<
1960 *
this<<
'['<<pos<<
']',
1961 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1963 if ( pos+
len < pos ) {
1965 "Invalid length for VDB 2-bits value sub-array: "<<
1966 *
this<<
'['<<pos<<
','<<
len<<
']',
1967 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1971 "Invalid end of VDB 2-bits value sub-array: "<<
1972 *
this<<
'['<<pos<<
','<<
len<<
']',
1973 RC(rcApp, rcData, rcRetrieving, rcOffset, rcTooBig));
1981 size_t offset = m_ElemOffset + pos;
1982 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)
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)
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 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 spaces 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 find(const CTempString match, size_type pos=0) const
Find the first instance of the entire matching string within the current string, beginning at an opti...
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
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)
#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_)
static const char table_name[]
static const char * prefix[]
static pcre_uint8 * buffer
Defines CRequestContext class for NCBI C++ diagnostic API.
#define CHECK_VDB_TIMEOUT_FMT(msg, rc)
#define CHECK_VDB_TIMEOUT(msg, rc)
#define NCBI_THROW2_FMT(exception_class, err_code, message, extra)
static const char * str(char *buf, int n)
static const char * column
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 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 int s_GetDebugLevel(void)
static void s_UpdateVDBRequestContext(void)
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)
#define SIMULATE_OPEN_ERROR()
pair< TVDBRowId, TVDBRowCount > TVDBRowIdRange