NCBI C++ ToolKit
reader.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: reader.cpp 102228 2024-04-09 17:35:06Z vasilche $
2  * ===========================================================================
3  * PUBLIC DOMAIN NOTICE
4  * National Center for Biotechnology Information
5  *
6  * This software/database is a "United States Government Work" under the
7  * terms of the United States Copyright Act. It was written as part of
8  * the author's official duties as a United States Government employee and
9  * thus cannot be copyrighted. This software/database is freely available
10  * to the public for use. The National Library of Medicine and the U.S.
11  * Government have not placed any restriction on its use or reproduction.
12  *
13  * Although all reasonable efforts have been taken to ensure the accuracy
14  * and reliability of the software and data, the NLM and the U.S.
15  * Government do not and cannot warrant the performance or results that
16  * may be obtained by using this software or data. The NLM and the U.S.
17  * Government disclaim all warranties, express or implied, including
18  * warranties of performance, merchantability or fitness for any particular
19  * purpose.
20  *
21  * Please cite the author in any work or product based on this material.
22  * ===========================================================================
23  *
24  * Author: Eugene Vasilchenko
25  *
26  * File Description: Base data reader interface
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
37 #include <objtools/error_codes.hpp>
38 
41 #include <algorithm>
42 #include <math.h>
43 #include <corelib/ncbi_system.hpp>
44 
45 
46 #define NCBI_USE_ERRCODE_X Objtools_Reader
47 
49 
51 
53 
54 #if 1
55 # define TRACE_SET(m)
56 #else
57 # define TRACE_SET(m) \
58  LOG_POST(Info<<SetPostFlags(eDPF_DateTime|eDPF_TID)<<m)
59 #endif
60 
62 {
63  *this << name << '(' << conn << "): ";
64 }
65 
66 
68 {
69  *this << name << ": ";
70 }
71 
72 
74 {
77 }
78 
79 
80 #define DEFAULT_PREOPEN false
81 #define DEFAULT_RETRY_COUNT 5
82 #define DEFAULT_WAIT_TIME_ERRORS 2
83 #define DEFAULT_WAIT_TIME 1
84 #define DEFAULT_WAIT_TIME_MULTIPLIER 1.5
85 #define DEFAULT_WAIT_TIME_INCREMENT 1
86 #define DEFAULT_WAIT_TIME_MAX 30
87 
89  {
91  0,
93  },
94  {
96  0,
98  },
99  {
101  0,
103  },
104  {
106  0,
108  }
109 };
110 
112  : m_Dispatcher(0),
113  m_MaxConnections(0),
117  m_NumFreeConnections(0, 1000),
122 
123 {
124 }
125 
127 {
128 }
129 
130 
132  const string& driver_name,
133  int default_max_conn)
134 {
135  int retry_count =
136  conf.GetInt(driver_name,
140  SetMaximumRetryCount(retry_count);
141  bool open_initial_connection =
142  conf.GetBool(driver_name,
146  SetPreopenConnection(open_initial_connection);
148  conf.GetInt(driver_name,
152  m_WaitTime.Init(conf, driver_name, s_WaitTimeParams);
153 
154  int max_connections = conf.GetInt(driver_name,
157  -1);
158  if ( max_connections == -1 ) {
159  max_connections = conf.GetInt(driver_name,
162  default_max_conn);
163  }
164  SetMaximumConnections(max_connections, default_max_conn);
165 }
166 
167 
169 {
170  if ( GetMaximumConnections() > 0 && (force || GetPreopenConnection()) ) {
171  for ( int attempt = 1; ; ++attempt ) {
173  try {
176  return;
177  }
178  catch ( CLoaderException& exc ) {
180  if ( exc.GetErrCode() == exc.eNoConnection ) {
181  // no connection can be opened
182  throw;
183  }
184  LOG_POST_X(1, Warning<<"CReader: "
185  "cannot open initial connection: "<<exc.what());
186  if ( attempt >= GetRetryCount() ) {
187  // this is the last attempt to establish connection
188  NCBI_RETHROW(exc, CLoaderException, eNoConnection,
189  "cannot open initial connection");
190  }
191  }
192  catch ( CException& exc ) {
194  LOG_POST_X(2, Warning<<"CReader: "
195  "cannot open initial connection: "<<exc.what());
196  if ( attempt >= GetRetryCount() ) {
197  // this is the last attempt to establish connection
198  NCBI_RETHROW(exc, CLoaderException, eNoConnection,
199  "cannot open initial connection");
200  }
201  }
202  }
203  }
204 }
205 
206 
208 {
209  m_PreopenConnection = preopen;
210 }
211 
212 
214 {
215  return m_PreopenConnection;
216 }
217 
218 
219 void CReader::SetMaximumConnections(int max, int default_max_conn)
220 {
221  if ( max == 0 ) {
222  max = default_max_conn;
223  }
225 }
226 
227 
229 {
230  int limit = GetMaximumConnectionsLimit();
231  if ( max > limit ) {
232  max = limit;
233  }
234  if ( max < 0 ) {
235  max = 0;
236  }
237  int error_count = 0;
238  while( GetMaximumConnections() < max ) {
239  try {
240  x_AddConnection();
241  error_count = 0;
242  }
243  catch ( exception& exc ) {
244  LOG_POST_X(3, Warning <<
245  "CReader: cannot add connection: "<<exc.what());
246  if ( ++error_count >= GetRetryCount() ) {
247  if ( max > 0 && GetMaximumConnections() == 0 ) {
248  throw;
249  }
250  }
251  }
252  }
253  while( GetMaximumConnections() > max ) {
255  }
256  return GetMaximumConnections();
257 }
258 
259 
261 {
262  return m_MaxConnections;
263 }
264 
265 
267 {
268  return 1;
269 }
270 
271 
273 {
275  if ( !m_NextConnectTime.IsEmpty() ) {
276  double wait_seconds =
278  if ( wait_seconds > 0 ) {
279  LOG_POST_X(6, Warning << "CReader: waiting "<<
280  wait_seconds<<"s before new connection");
281  _TRACE("CReader: waiting "<<wait_seconds<<
282  "s before new connection");
283  SleepMicroSec((unsigned long)(wait_seconds*1e6));
284  return;
285  }
286  else {
288  return;
289  }
290  }
291  else if ( m_ConnectFailCount >= 2 ) {
292  double wait_seconds = m_WaitTime.GetTime(m_ConnectFailCount-2);
293  if ( wait_seconds > 0 ) {
294  LOG_POST_X(7, Warning << "CReader: waiting "<<
295  wait_seconds<<"s before new connection");
296  _TRACE("CReader: waiting "<<wait_seconds<<
297  "s before new connection");
298  SleepMicroSec((unsigned long)(wait_seconds*1e6));
299  }
300  }
301 }
302 
303 
305 {
306  m_ConnectFailCount = 0;
307 }
308 
309 
311 {
315 }
316 
317 
318 void CReader::SetNewConnectionDelayMicroSec(unsigned long micro_sec)
319 {
321  CTime curr(CTime::eCurrent);
322  m_NextConnectTime = curr.AddTimeSpan(CTimeSpan(micro_sec*1e-6));
323 }
324 
325 
327 {
329  try {
331  }
332  catch ( exception& /*rethrown*/ ) {
334  throw;
335  }
337 }
338 
339 
341 {
348 }
349 
350 
352 {
353  TConn conn = x_AllocConnection(true);
358 }
359 
360 
362 {
363  if ( GetMaximumConnections() <= 0 ) {
364  NCBI_THROW(CLoaderException, eNoConnection, "connections limit is 0");
365  }
368  SConnSlot slot;
369  if ( oldest ) {
370  slot = m_FreeConnections.back();
371  m_FreeConnections.pop_back();
372  }
373  else {
374  slot = m_FreeConnections.front();
375  m_FreeConnections.pop_front();
376  }
377  if ( !slot.m_LastUseTime.IsEmpty() ) {
378  double age = CTime(CTime::eCurrent).DiffNanoSecond(slot.m_LastUseTime)*1e-9;
379  if ( age > 60 ) {
380  // too old, disconnect
381  x_DisconnectAtSlot(slot.m_Conn, false);
382  }
383  else if ( age < slot.m_RetryDelay ) {
384  double wait_seconds = slot.m_RetryDelay - age;
385  LOG_POST_X(8, Warning << "CReader: waiting "<<
386  wait_seconds<<"s before next command");
387  _TRACE("CReader: waiting "<<wait_seconds<<
388  "s before next connection");
389  SleepMicroSec((unsigned long)(wait_seconds*1e6));
390  }
391  }
392  return slot.m_Conn;
393 }
394 
395 
397 {
399  SConnSlot slot;
400  slot.m_Conn = conn;
401  slot.m_RetryDelay = 0;
402  m_FreeConnections.push_back(slot);
404 }
405 
406 
407 void CReader::x_ReleaseConnection(TConn conn, double retry_delay)
408 {
410  SConnSlot slot;
411  slot.m_Conn = conn;
413  slot.m_RetryDelay = retry_delay;
414  m_FreeConnections.push_front(slot);
416 }
417 
418 
420 {
422  try {
425  return;
426  }
427  catch ( exception& exc ) {
428  ERR_POST_X(4, "CReader("<<conn<<"): "
429  "cannot reuse connection: "<<exc.what());
430  }
431  // cannot reuse connection number, allocate new one
432  try {
434  }
435  catch ( exception& ) {
436  // ignore
437  }
440  x_AddConnection();
441 }
442 
443 
444 void CReader::x_ReportDisconnect(const char* reader, const char* server,
445  TConn conn, bool failed) const
446 {
447  if ( failed ) {
448  LOG_POST_X(4, Warning << reader << "("<<conn<<"): " << server <<
449  " GenBank connection failed: reconnecting...");
450  }
451  else {
452  LOG_POST_X(5, Info << reader << "("<<conn<<"): " << server <<
453  " GenBank connection too old: reconnecting...");
454  }
455 }
456 
457 
459 {
460  x_ReportDisconnect("CReader", "", conn, failed);
463 }
464 
465 
466 int CReader::GetConst(const string& ) const
467 {
468  return 0;
469 }
470 
471 
472 void CReader::SetMaximumRetryCount(int retry_count)
473 {
474  m_MaximumRetryCount = retry_count;
475 }
476 
477 
478 int CReader::GetRetryCount(void) const
479 {
480  return m_MaximumRetryCount;
481 }
482 
483 
485 {
486  return false;
487 }
488 
489 
491  const CSeq_id_Handle& seq_id)
492 {
493  CLoadLockGi lock(result, seq_id);
494  if ( lock.IsLoadedGi() ) {
495  return true;
496  }
497  CLoadLockSeqIds ids_lock(result, seq_id);
498  if ( !ids_lock.IsLoaded() ) {
500  if ( !ids_lock.IsLoaded() ) {
501  return false;
502  }
503  }
504  SetAndSaveSeq_idGiFromSeqIds(result, seq_id, ids_lock);
505  return true;
506 }
507 
508 
510  const CSeq_id_Handle& seq_id)
511 {
512  CLoadLockAcc lock(result, seq_id);
513  if ( lock.IsLoadedAccVer() ) {
514  return true;
515  }
516  CLoadLockSeqIds ids_lock(result, seq_id);
517  if ( !ids_lock.IsLoaded() ) {
519  if ( !ids_lock.IsLoaded() ) {
520  return false;
521  }
522  }
523  SetAndSaveSeq_idAccFromSeqIds(result, seq_id, ids_lock);
524  return true;
525 }
526 
527 
529  const CSeq_id_Handle& seq_id)
530 {
531  CLoadLockLabel lock(result, seq_id);
532  if ( lock.IsLoadedLabel() ) {
533  return true;
534  }
535  CLoadLockSeqIds ids_lock(result, seq_id);
536  if ( !ids_lock.IsLoaded() ) {
538  if ( !ids_lock.IsLoaded() ) {
539  return false;
540  }
541  }
542  SetAndSaveSeq_idLabelFromSeqIds(result, seq_id, ids_lock);
543  return true;
544 }
545 
546 
548  const CSeq_id_Handle& seq_id)
549 {
550  if ( result.IsLoadedTaxId(seq_id) ) {
551  return true;
552  }
553 
554  TTaxId taxid = INVALID_TAX_ID;
556  CLoadLockBlobIds blobs(result, seq_id, static_cast<SAnnotSelector*>(0));
557  _ASSERT(blobs.IsLoaded());
558  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
559  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
560  const CBlob_Info& info = *it;
561  const CBlob_id& blob_id = *info.GetBlob_id();
562  if ( !info.Matches(fBlobHasCore, 0) ) {
563  continue;
564  }
565  CLoadLockBlob blob(result, blob_id);
566  _ASSERT(blob.IsLoadedBlob());
567  CTSE_LoadLock& lock = blob.GetTSE_LoadLock();
568  _ASSERT(lock);
569  if ( CConstRef<CBioseq_Info> seq = lock->FindMatchingBioseq(seq_id) ) {
570  taxid = seq->GetTaxId();
571  break;
572  }
573  }
574  SetAndSaveSeq_idTaxId(result, seq_id, taxid);
575  return true;
576 }
577 
578 
580  const CSeq_id_Handle& seq_id)
581 {
582  if ( !result.IsLoadedHash(seq_id) ) {
584  CLoadLockSeqIds ids(result, seq_id);
585  if ( !ids.IsLoaded() ) {
587  hash.sequence_found = ids.GetSeq_ids().IsFound();
588  // no hash information by default
589  }
590  result.SetLoadedHash(seq_id, hash);
591  }
592  return true;
593 }
594 
595 
597  const CSeq_id_Handle& seq_id)
598 {
599  if ( result.IsLoadedLength(seq_id) ) {
600  return true;
601  }
602 
603  TSeqPos length = kInvalidSeqPos;
605  CLoadLockBlobIds blobs(result, seq_id, static_cast<SAnnotSelector*>(0));
606  _ASSERT(blobs.IsLoaded());
607  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
608  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
609  const CBlob_Info& info = *it;
610  const CBlob_id& blob_id = *info.GetBlob_id();
611  if ( !info.Matches(fBlobHasCore, 0) ) {
612  continue;
613  }
614  CLoadLockBlob blob(result, blob_id);
615  _ASSERT(blob.IsLoadedBlob());
616  CTSE_LoadLock& lock = blob.GetTSE_LoadLock();
617  _ASSERT(lock);
618  if ( CConstRef<CBioseq_Info> seq = lock->FindMatchingBioseq(seq_id) ) {
619  length = seq->GetInst().GetLength();
620  break;
621  }
622  }
623  SetAndSaveSequenceLength(result, seq_id, length);
624  return true;
625 }
626 
627 
629  const CSeq_id_Handle& seq_id)
630 {
631  if ( result.IsLoadedType(seq_id) ) {
632  return true;
633  }
634 
637  CLoadLockBlobIds blobs(result, seq_id, static_cast<SAnnotSelector*>(0));
638  _ASSERT(blobs.IsLoaded());
639  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
640  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
641  const CBlob_Info& info = *it;
642  const CBlob_id& blob_id = *info.GetBlob_id();
643  if ( !info.Matches(fBlobHasCore, 0) ) {
644  continue;
645  }
646  CLoadLockBlob blob(result, blob_id);
647  _ASSERT(blob.IsLoadedBlob());
648  CTSE_LoadLock& lock = blob.GetTSE_LoadLock();
649  _ASSERT(lock);
650  if ( CConstRef<CBioseq_Info> seq = lock->FindMatchingBioseq(seq_id) ) {
651  type.type = seq->GetInst().GetMol();
652  type.sequence_found = true;
653  break;
654  }
655  }
657  return true;
658 }
659 
660 
662  const TIds& ids, TLoaded& loaded, TBulkIds& ret)
663 {
664  size_t count = ids.size();
665  for ( size_t i = 0; i < count; ++i ) {
666  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
667  continue;
668  }
669  CLoadLockSeqIds lock(result, ids[i]);
670  if ( !lock.IsLoaded() ) {
672  }
673  if ( lock.IsLoaded() ) {
674  CFixedSeq_ids data = lock.GetSeq_ids();
675  if ( data.IsFound() ) {
676  ret[i] = data.Get();
677  loaded[i] = true;
678  }
679  }
680  }
681  return true;
682 }
683 
684 
686  const TIds& ids, TLoaded& loaded, TIds& ret)
687 {
688  size_t count = ids.size();
689  for ( size_t i = 0; i < count; ++i ) {
690  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
691  continue;
692  }
693  CLoadLockAcc lock(result, ids[i]);
694  if ( !lock.IsLoadedAccVer() ) {
696  }
697  if ( lock.IsLoadedAccVer() ) {
698  TSequenceAcc data = lock.GetAccVer();
699  if ( lock.IsFound(data) ) {
700  ret[i] = lock.GetAcc(data);
701  loaded[i] = true;
702  }
703  }
704  }
705  return true;
706 }
707 
708 
710  const TIds& ids, TLoaded& loaded, TGis& ret)
711 {
712  size_t count = ids.size();
713  for ( size_t i = 0; i < count; ++i ) {
714  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
715  continue;
716  }
717  CLoadLockGi lock(result, ids[i]);
718  if ( !lock.IsLoadedGi() ) {
720  }
721  if ( lock.IsLoadedGi() ) {
722  TSequenceGi data = lock.GetGi();
723  if ( lock.IsFound(data) ) {
724  ret[i] = lock.GetGi(data);
725  loaded[i] = true;
726  }
727  }
728  }
729  return true;
730 }
731 
732 
734  const TIds& ids, TLoaded& loaded, TLabels& ret)
735 {
736  size_t count = ids.size();
737  for ( size_t i = 0; i < count; ++i ) {
738  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
739  continue;
740  }
741  CLoadLockLabel lock(result, ids[i]);
742  if ( !lock.IsLoadedLabel() ) {
744  }
745  if ( lock.IsLoadedLabel() && !lock.GetLabel().empty() ) {
746  ret[i] = lock.GetLabel();
747  loaded[i] = true;
748  }
749  }
750  return true;
751 }
752 
753 
755  const TIds& ids, TLoaded& loaded, TTaxIds& ret)
756 {
757  size_t count = ids.size();
758  for ( size_t i = 0; i < count; ++i ) {
759  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
760  continue;
761  }
762  CLoadLockTaxId lock(result, ids[i]);
763  if ( !lock.IsLoadedTaxId() ) {
765  }
766  if ( lock.IsLoadedTaxId() && lock.GetTaxId() != INVALID_TAX_ID ) {
767  ret[i] = lock.GetTaxId();
768  loaded[i] = true;
769  }
770  }
771  return true;
772 }
773 
774 
776  const TIds& ids, TLoaded& loaded,
777  THashes& ret, TKnown& known)
778 {
779  size_t count = ids.size();
780  for ( size_t i = 0; i < count; ++i ) {
781  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
782  continue;
783  }
784  CLoadLockHash lock(result, ids[i]);
785  if ( !lock.IsLoadedHash() ) {
787  }
788  if ( lock.IsLoadedHash() ) {
789  TSequenceHash hash = lock.GetHash();
790  if ( hash.sequence_found ) {
791  ret[i] = hash.hash;
792  loaded[i] = true;
793  known[i] = hash.hash_known;
794  }
795  }
796  }
797  return true;
798 }
799 
800 
802  const TIds& ids, TLoaded& loaded, TLengths& ret)
803 {
804  size_t count = ids.size();
805  for ( size_t i = 0; i < count; ++i ) {
806  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
807  continue;
808  }
809  CLoadLockLength lock(result, ids[i]);
810  if ( !lock.IsLoadedLength() ) {
812  }
813  if ( lock.IsLoadedLength() && lock.GetLength() != kInvalidSeqPos ) {
814  ret[i] = lock.GetLength();
815  loaded[i] = true;
816  }
817  }
818  return true;
819 }
820 
821 
823  const TIds& ids, TLoaded& loaded, TTypes& ret)
824 {
825  size_t count = ids.size();
826  for ( size_t i = 0; i < count; ++i ) {
827  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
828  continue;
829  }
830  CLoadLockType lock(result, ids[i]);
831  if ( !lock.IsLoadedType() ) {
833  }
834  if ( lock.IsLoadedType() ) {
835  TSequenceType data = lock.GetType();
836  if ( lock.IsFound(data) ) {
837  ret[i] = lock.GetType(data);
838  loaded[i] = true;
839  }
840  }
841  }
842  return true;
843 }
844 
845 
847  const TIds& ids, TLoaded& loaded, TStates& ret)
848 {
849  size_t count = ids.size();
850  for ( size_t i = 0; i < count; ++i ) {
851  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
852  continue;
853  }
854  CLoadLockBlobIds lock(result, ids[i]);
855  if ( !lock.IsLoaded() ) {
857  }
858  if ( lock.IsLoaded() ) {
859  CReadDispatcher::SetBlobState(i, result, ids, loaded, ret);
860  }
861  if ( loaded[i] ) {
862  continue;
863  }
864  CFixedBlob_ids blob_ids = lock.GetBlob_ids();
865  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
866  if ( it->Matches(fBlobHasCore, 0) ) {
867  CLoadLockBlobState state_lock(result, *it->GetBlob_id());
868  if ( !state_lock.IsLoaded() ) {
869  m_Dispatcher->LoadBlobState(result, *it->GetBlob_id());
870  }
871  if ( state_lock.IsLoaded() &&
872  !(state_lock.GetBlobState() & CBioseq_Handle::fState_not_found) ) {
873  ret[i] = state_lock.GetBlobState();
874  loaded[i] = true;
875  break;
876  }
877  }
878  }
879  }
880  return true;
881 }
882 
883 
885  const CSeq_id_Handle& seq_id,
886  const SAnnotSelector* sel)
887 {
888  if ( !sel || !sel->IsIncludedAnyNamedAnnotAccession() ) {
889  return false;
890  }
891  // recurse to non-named version
892  CLoadLockBlobIds src_ids(result, seq_id, 0);
894  if ( !src_ids.IsLoaded() ) {
895  return false;
896  }
897  CLoadLockBlobIds dst_ids(result, seq_id, sel);
898  dst_ids.SetLoadedBlob_ids(src_ids);
899  return true;
900 }
901 
902 
904  const CSeq_id_Handle& seq_id,
906  const SAnnotSelector* sel)
907 {
908  CLoadLockBlobIds ids(result, seq_id, sel);
909  if ( !ids.IsLoaded() ) {
910  if ( !LoadSeq_idBlob_ids(result, seq_id, sel) && !ids.IsLoaded() ) {
911  return false;
912  }
913  if ( !ids.IsLoaded() ) {
914  return true;
915  }
916  }
917  m_Dispatcher->LoadBlobs(result, ids, mask, sel);
918  return true;
919 }
920 
921 
923  const CLoadLockBlobIds& blobs,
925  const SAnnotSelector* sel)
926 {
927  int loaded_count = 0;
928  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
929  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
930  const CBlob_Info& info = *it;
931  const CBlob_id& blob_id = *info.GetBlob_id();
932  if ( info.Matches(mask, sel) ) {
933  CLoadLockBlob blob(result, blob_id);
934  if ( blob.IsLoadedBlob() ) {
935  continue;
936  }
937 
938  if ( info.IsSetAnnotInfo() ) {
939  if ( info.GetAnnotInfo()->GetAnnotInfo().empty() ) {
940  // no actual annot info - only name
941  auto& names = info.GetAnnotInfo()->GetNamedAnnotNames();
942  if ( names.size() == 1 ) {
943  CLoadLockSetter setter(blob);
944  setter.GetTSE_LoadLock()->SetName(*names.begin());
945  setter.AllowIncompleteLoading();
946  }
947  }
948  else {
950  _ASSERT(blob.IsLoadedBlob());
951  ++loaded_count;
952  continue;
953  }
954  }
955 
956  m_Dispatcher->LoadBlob(result, blob_id);
957  if ( blob.IsLoadedBlob() ) {
958  ++loaded_count;
959  }
960  }
961  }
962  return loaded_count > 0;
963 }
964 
965 
967  const CBlob_Info& blob_info)
968 {
969  const CBlob_id& blob_id = *blob_info.GetBlob_id();
970  CLoadLockBlob blob(result, blob_id);
971  if ( blob.IsLoadedBlob() ) {
972  return true;
973  }
974 
975  if ( blob_info.IsSetAnnotInfo() ) {
977  _ASSERT(blob.IsLoadedBlob());
978  return true;
979  }
980 
981  return LoadBlob(result, blob_id);
982 }
983 
984 
986  const TBlobId& /*blob_id*/,
987  TChunkId /*chunk_id*/)
988 {
989  return false;
990 }
991 
992 
994  const TBlobId& blob_id,
995  const TChunkIds& chunk_ids)
996 {
997  bool ret = false;
998  ITERATE(TChunkIds, id, chunk_ids) {
999  ret |= LoadChunk(result, blob_id, *id);
1000  }
1001  return ret;
1002 }
1003 
1004 
1006  const TBlobChunkIds& chunk_ids)
1007 {
1008  bool ret = false;
1009  for ( auto& blob_chunks : chunk_ids ) {
1010  ret |= LoadChunks(result, blob_chunks.first, blob_chunks.second);
1011  }
1012  return ret;
1013 }
1014 
1015 
1017  const TSeqIds& seq_ids)
1018 {
1019  bool ret = false;
1020  ITERATE(TSeqIds, id, seq_ids) {
1021  ret |= LoadBlobs(result, *id, fBlobHasCore, 0);
1022  }
1023  return ret;
1024 }
1025 
1026 
1028  const TBlobIds& blob_infos)
1029 {
1030  bool ret = false;
1031  for ( auto& info : blob_infos ) {
1032  const CBlob_id& blob_id = *info.GetBlob_id();
1033  CLoadLockBlob blob(result, blob_id);
1034  if ( blob.IsLoadedBlob() ) {
1035  continue;
1036  }
1037 
1038  if ( info.IsSetAnnotInfo() ) {
1039  if ( info.GetAnnotInfo()->GetAnnotInfo().empty() ) {
1040  // no actual annot info - only name
1041  auto& names = info.GetAnnotInfo()->GetNamedAnnotNames();
1042  if ( names.size() == 1 ) {
1043  CLoadLockSetter setter(blob);
1044  setter.GetTSE_LoadLock()->SetName(*names.begin());
1045  setter.AllowIncompleteLoading();
1046  }
1047  }
1048  else {
1050  _ASSERT(blob.IsLoadedBlob());
1051  ret = true;
1052  continue;
1053  }
1054  }
1055 
1056  m_Dispatcher->LoadBlob(result, blob_id);
1057  if ( blob.IsLoadedBlob() ) {
1058  ret = true;
1059  }
1060  }
1061  return ret;
1062 }
1063 
1064 
1066  const TBlobId& blob_id,
1067  TChunkId chunk_id,
1068  TBlobState blob_state)
1069 {
1070  blob_state |=
1073  result.SetNoBlob(blob_id, blob_state);
1074 }
1075 
1076 
1078  const CSeq_id_Handle& seq_id,
1079  const SAnnotSelector* sel,
1080  const CFixedBlob_ids& blob_ids) const
1081 {
1082  CLoadLockBlobIds lock(result, seq_id, sel);
1083  SetAndSaveSeq_idBlob_ids(result, seq_id, sel, lock, blob_ids);
1084 }
1085 
1086 
1088  const CSeq_id_Handle& seq_id,
1089  const SAnnotSelector* sel,
1090  TBlobState state) const
1091 {
1092  CLoadLockBlobIds lock(result, seq_id, sel);
1093  SetAndSaveNoSeq_idBlob_ids(result, seq_id, sel, lock, state);
1094 }
1095 
1096 
1098  const TBlobId& blob_id,
1099  TBlobVersion blob_state) const
1100 {
1101  if ( !result.SetLoadedBlobState(blob_id, blob_state) ) {
1102  return;
1103  }
1104  if ( CWriter* writer = result.GetIdWriter() ) {
1105  writer->SaveBlobState(result, blob_id, blob_state);
1106  }
1107 }
1108 
1109 
1111  const TBlobId& blob_id,
1112  TBlobVersion version) const
1113 {
1114  if ( !result.SetLoadedBlobVersion(blob_id, version) ) {
1115  return;
1116  }
1117  if ( CWriter* writer = result.GetIdWriter() ) {
1118  writer->SaveBlobVersion(result, blob_id, version);
1119  }
1120 }
1121 
1122 
1124  const CSeq_id_Handle& seq_id,
1125  const CFixedSeq_ids& seq_ids) const
1126 {
1127  TRACE_SET("SetAndSaveSeq_idSeq_ids("<<seq_id<<") state: "<<seq_ids.GetState());
1128  if ( !seq_ids.IsFound() ) {
1129  SetAndSaveNoSeq_idBlob_ids(result, seq_id, 0, seq_ids.GetState());
1130  }
1131  if ( !result.SetLoadedSeqIds(seq_id, seq_ids) ) {
1132  return;
1133  }
1134  TRACE_SET("SetAndSaveSeq_idSeq_ids("<<seq_id<<") set");
1135  if ( CWriter* writer = result.GetIdWriter() ) {
1136  writer->SaveSeq_idSeq_ids(result, seq_id);
1137  }
1138 }
1139 
1140 
1142  const CSeq_id_Handle& seq_id,
1143  const CLoadLockSeqIds& seq_ids) const
1144 {
1145  if ( !result.SetLoadedSeqIds(seq_id, seq_ids) ) {
1146  return;
1147  }
1148  if ( CWriter* writer = result.GetIdWriter() ) {
1149  writer->SaveSeq_idSeq_ids(result, seq_id);
1150  }
1151 }
1152 
1153 
1155  const CSeq_id_Handle& seq_id,
1156  const CLoadLockSeqIds& seq_ids) const
1157 {
1158  if ( !result.SetLoadedAccFromSeqIds(seq_id, seq_ids) ) {
1159  return;
1160  }
1161  if ( CWriter* writer = result.GetIdWriter() ) {
1162  writer->SaveSeq_idAccVer(result, seq_id);
1163  }
1164 }
1165 
1166 
1168  const CSeq_id_Handle& seq_id,
1169  const CLoadLockSeqIds& seq_ids) const
1170 {
1171  if ( !result.SetLoadedGiFromSeqIds(seq_id, seq_ids) ) {
1172  return;
1173  }
1174  if ( CWriter* writer = result.GetIdWriter() ) {
1175  writer->SaveSeq_idGi(result, seq_id);
1176  }
1177 }
1178 
1179 
1181  const CSeq_id_Handle& seq_id,
1182  const CLoadLockSeqIds& seq_ids) const
1183 {
1184  if ( !result.SetLoadedLabelFromSeqIds(seq_id, seq_ids) ) {
1185  return;
1186  }
1187  if ( CWriter* writer = result.GetIdWriter() ) {
1188  writer->SaveSeq_idLabel(result, seq_id);
1189  }
1190 }
1191 
1192 
1194  const CSeq_id_Handle& seq_id,
1195  const CLoadLockGi& gi_lock) const
1196 {
1197  if ( !result.SetLoadedSeqIdsFromZeroGi(seq_id, gi_lock) ) {
1198  return;
1199  }
1200  if ( CWriter* writer = result.GetIdWriter() ) {
1201  writer->SaveSeq_idSeq_ids(result, seq_id);
1202  }
1203 }
1204 
1205 
1207  const CSeq_id_Handle& seq_id,
1208  const SAnnotSelector* sel,
1209  const CLoadLockGi& gi_lock) const
1210 {
1211  TRACE_SET("SetAndSaveNoSeq_idBlob_ids("<<seq_id<<") from gi");
1212  if ( !result.SetLoadedBlobIdsFromZeroGi(seq_id, sel, gi_lock) ) {
1213  return;
1214  }
1215  TRACE_SET("SetAndSaveNoSeq_idBlob_ids("<<seq_id<<") from gi set");
1216  if ( CWriter* writer = result.GetIdWriter() ) {
1217  writer->SaveSeq_idBlob_ids(result, seq_id, sel);
1218  }
1219 }
1220 
1221 
1223  const CSeq_id_Handle& seq_id,
1224  TState state) const
1225 {
1226  state |=
1230 }
1231 
1232 
1234  const CSeq_id_Handle& seq_id,
1235  const TSequenceGi& gi) const
1236 {
1237  if ( !result.SetLoadedGi(seq_id, gi) ) {
1238  return;
1239  }
1240  if ( CWriter* writer = result.GetIdWriter() ) {
1241  writer->SaveSeq_idGi(result, seq_id);
1242  }
1243 }
1244 
1245 
1247  const CSeq_id_Handle& seq_id,
1248  const TSequenceAcc& acc_id) const
1249 {
1250  if ( !result.SetLoadedAcc(seq_id, acc_id) ) {
1251  return;
1252  }
1253  if ( CWriter* writer = result.GetIdWriter() ) {
1254  writer->SaveSeq_idAccVer(result, seq_id);
1255  }
1256 }
1257 
1258 
1260  const CSeq_id_Handle& seq_id,
1261  const string& label) const
1262 {
1263  if ( !result.SetLoadedLabel(seq_id, label) ) {
1264  return;
1265  }
1266  if ( CWriter* writer = result.GetIdWriter() ) {
1267  writer->SaveSeq_idLabel(result, seq_id);
1268  }
1269 }
1270 
1271 
1273  const CSeq_id_Handle& seq_id,
1274  TTaxId taxid) const
1275 {
1276  if ( !result.SetLoadedTaxId(seq_id, taxid) ) {
1277  return;
1278  }
1279  if ( CWriter* writer = result.GetIdWriter() ) {
1280  writer->SaveSeq_idTaxId(result, seq_id);
1281  }
1282 }
1283 
1284 
1286  const CSeq_id_Handle& seq_id,
1287  const TSequenceHash& hash) const
1288 {
1289  if ( !result.SetLoadedHash(seq_id, hash) ) {
1290  return;
1291  }
1292  if ( CWriter* writer = result.GetIdWriter() ) {
1293  writer->SaveSequenceHash(result, seq_id);
1294  }
1295 }
1296 
1297 
1299  const CSeq_id_Handle& seq_id,
1300  TSeqPos length) const
1301 {
1302  if ( !result.SetLoadedLength(seq_id, length) ) {
1303  return;
1304  }
1305  if ( CWriter* writer = result.GetIdWriter() ) {
1306  writer->SaveSequenceLength(result, seq_id);
1307  }
1308 }
1309 
1310 
1312  const CSeq_id_Handle& seq_id,
1313  const TSequenceType& type) const
1314 {
1315  if ( !result.SetLoadedType(seq_id, type) ) {
1316  return;
1317  }
1318  if ( CWriter* writer = result.GetIdWriter() ) {
1319  writer->SaveSequenceType(result, seq_id);
1320  }
1321 }
1322 
1323 
1325  const CSeq_id_Handle& seq_id,
1326  const SAnnotSelector* sel,
1327  CLoadLockBlobIds& lock,
1328  const CFixedBlob_ids& blob_ids) const
1329 {
1330  TRACE_SET("SetAndSaveSeq_idBlob_ids("<<seq_id<<")");
1331  if ( !lock.SetLoadedBlob_ids(sel, blob_ids) ) {
1332  return;
1333  }
1334  TRACE_SET("SetAndSaveSeq_idBlob_ids("<<seq_id<<") set");
1335  if ( CWriter* writer = result.GetIdWriter() ) {
1336  writer->SaveSeq_idBlob_ids(result, seq_id, sel);
1337  }
1338 }
1339 
1340 
1342  const CSeq_id_Handle& seq_id,
1343  const SAnnotSelector* sel,
1344  CLoadLockBlobIds& lock,
1345  const CLoadLockBlobIds& blob_ids) const
1346 {
1347  TRACE_SET("SetAndSaveSeq_idBlob_ids("<<seq_id<<")");
1348  if ( !lock.SetLoadedBlob_ids(sel, blob_ids.GetBlob_ids(), blob_ids.GetExpirationTime()) ) {
1349  return;
1350  }
1351  TRACE_SET("SetAndSaveSeq_idBlob_ids("<<seq_id<<") set");
1352  if ( CWriter* writer = result.GetIdWriter() ) {
1353  writer->SaveSeq_idBlob_ids(result, seq_id, sel);
1354  }
1355 }
1356 
1357 
1359  const CSeq_id_Handle& seq_id,
1360  const SAnnotSelector* sel,
1361  CLoadLockBlobIds& lock,
1362  TBlobState state) const
1363 {
1364  state |=
1367  TRACE_SET("SetAndSaveNoSeq_idBlob_ids("<<seq_id<<")");
1368  if ( !lock.SetNoBlob_ids(state) ) {
1369  return;
1370  }
1371  TRACE_SET("SetAndSaveNoSeq_idBlob_ids("<<seq_id<<") set");
1372  if ( CWriter* writer = result.GetIdWriter() ) {
1373  writer->SaveSeq_idBlob_ids(result, seq_id, sel);
1374  }
1375 }
1376 
1377 
1379 {
1380  int value;
1381  stream.read(reinterpret_cast<char*>(&value), sizeof(value));
1382  if ( stream.gcount() != sizeof(value) ) {
1383  NCBI_THROW(CLoaderException, eLoaderFailed,
1384  "cannot read value");
1385  }
1386  return value;
1387 }
1388 
1389 
1391  const TPluginManagerParamTree* /*params*/)
1392 {
1393 }
1394 
1395 
1397 {
1398 }
1399 
1400 
1401 void CReader::SetIncludeHUP(bool include_hup, const string& web_cookie)
1402 {
1403  NCBI_THROW(CObjMgrException, eRegisterError,
1404  "HUP is supported only by pubseqos or pubseqos2 readers");
1405 }
1406 
1407 
1409 {
1410 }
1411 
1412 
1414 {
1415 }
1416 
1417 
1419 {
1420 }
1421 
1422 
1424  : m_Cache(&cache),
1425  m_Type(cache_type)
1426 {
1427 }
1428 
1430 {
1431 }
1432 
1433 /////////////////////////////////////////////////////////////////////////////
1434 // CReaderAllocatedConnection
1435 /////////////////////////////////////////////////////////////////////////////
1436 
1438  : m_Result(0), m_Reader(0), m_Conn(0), m_Restart(false)
1439 {
1440  if ( !reader ) {
1441  return;
1442  }
1443  CReaderAllocatedConnection* pconn = result.m_AllocatedConnection;
1444  if ( !pconn ) {
1445  result.ReleaseNotLoadedBlobs();
1446  m_Conn = reader->x_AllocConnection();
1447  m_Reader = reader;
1448  m_Result = &result;
1449  result.ClearRetryDelay();
1450  result.m_AllocatedConnection = this;
1451  }
1452  else if ( pconn->m_Reader == reader ) {
1453  // reuse allocated connection
1454  m_Conn = pconn->m_Conn;
1455  pconn->m_Conn = 0;
1456  pconn->m_Reader = 0;
1457  pconn->m_Result = 0;
1458  m_Reader = reader;
1459  m_Result = &result;
1460  result.m_AllocatedConnection = this;
1461  }
1462  else {
1463  NCBI_THROW(CLoaderException, eLoaderFailed,
1464  "Only one reader can allocate connection for a result");
1465  }
1466 }
1467 
1468 
1470 {
1471  if ( m_Result ) {
1473  _ASSERT(m_Reader);
1477  }
1478 }
1479 
1480 
1482 {
1483  m_Restart = true;
1484 }
1485 
1486 
1488 {
1489  if ( m_Result ) {
1491  _ASSERT(m_Reader);
1492  double retry_delay = m_Result->GetRetryDelay();
1494  m_Result = 0;
1495  m_Reader->x_ReleaseConnection(m_Conn, min(retry_delay, 60.0));
1496  }
1497 }
1498 
1499 
ncbi::TMaskedQueryRegions mask
const CConstRef< CBlob_id > & GetBlob_id(void) const
bool IsSetAnnotInfo(void) const
TState GetState(void) const
bool IsFound(void) const
double GetTime(int step) const
Definition: incr_time.cpp:75
void Init(CConfig &conf, const string &driver_name, const SAllParams &params)
Definition: incr_time.cpp:43
static bool IsFound(const TData &data)
TData GetAccVer(void) const
static const CSeq_id_Handle & GetAcc(const TData &data)
bool IsLoadedAccVer(void) const
bool SetNoBlob_ids(const CFixedBlob_ids::TState &state, TExpirationTime expiration_time)
TData GetBlob_ids(void) const
bool SetLoadedBlob_ids(const TData &data, TExpirationTime expiration_time)
TData GetBlobState(void) const
bool IsLoadedBlob(void) const
CTSE_LoadLock & GetTSE_LoadLock(void)
bool IsLoadedGi(void) const
static bool IsFound(const TData &data)
static TGi GetGi(const TData &data)
bool IsLoadedHash(void) const
static int GetHash(const TData &data)
bool IsLoadedLabel(void) const
TData GetLabel(void) const
TData GetLength(void) const
bool IsLoadedLength(void) const
TData GetSeq_ids(void) const
void AllowIncompleteLoading()
CTSE_LoadLock & GetTSE_LoadLock(void)
bool IsLoadedTaxId(void) const
TData GetTaxId(void) const
static bool IsFound(const TData &data)
static CSeq_inst::TMol GetType(const TData &data)
bool IsLoadedType(void) const
Data loader exceptions, used by GenBank loader.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
Base class for all object manager exceptions.
static void LoadBlob(CReaderRequestResult &result, const CBlob_Info &blob_info)
void LoadSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
static bool SetBlobState(size_t i, CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TStates &ret)
void LoadSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadBlobState(CReaderRequestResult &result, const TBlobId &blob_id)
void LoadSeq_idTaxId(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
void LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSequenceLength(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel)
void LoadBlob(CReaderRequestResult &result, const CBlob_id &blob_id)
static bool CannotProcess(const CSeq_id_Handle &sih)
Definition: dispatcher.cpp:261
CReaderRequestResult * m_Result
Definition: reader.hpp:441
CReaderAllocatedConnection(CReaderRequestResult &result, CReader *reader)
Definition: reader.cpp:1437
virtual ~CReaderCacheManager(void)
Definition: reader.cpp:1418
CReaderCacheManager(void)
Definition: reader.cpp:1413
CReaderAllocatedConnection * m_AllocatedConnection
double GetRetryDelay(void) const
void ReleaseNotLoadedBlobs(void)
CDebugPrinter(TConn conn, const char *name)
Definition: reader.cpp:61
CSemaphore m_NumFreeConnections
Definition: reader.hpp:399
void SetPreopenConnection(bool preopen=true)
Definition: reader.cpp:207
vector< CSeq_id_Handle > TSeqIds
Definition: reader.hpp:96
virtual void x_DisconnectAtSlot(TConn conn, bool failed)
Definition: reader.cpp:458
virtual int GetRetryCount(void) const
Definition: reader.cpp:478
virtual bool LoadBlobSet(CReaderRequestResult &result, const TSeqIds &seq_ids)
Definition: reader.cpp:1016
virtual bool LoadHashes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, THashes &ret, TKnown &known)
Definition: reader.cpp:775
CReadDispatcher * m_Dispatcher
Definition: reader.hpp:353
void SetAndSaveSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceAcc &acc_id) const
Definition: reader.cpp:1246
virtual bool LoadStates(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TStates &ret)
Definition: reader.cpp:846
virtual bool LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:579
virtual bool LoadSeq_idTaxId(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:547
void x_ReleaseClosedConnection(TConn conn)
Definition: reader.cpp:396
vector< TIds > TBulkIds
Definition: reader.hpp:125
void SetAndSaveNoSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, const CLoadLockGi &gi_lock) const
Definition: reader.cpp:1206
void x_RemoveConnection(void)
Definition: reader.cpp:351
void OpenInitialConnection(bool force)
Definition: reader.cpp:168
virtual bool LoadLabels(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLabels &ret)
Definition: reader.cpp:733
void SetAndSaveSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceType &type) const
Definition: reader.cpp:1311
virtual void x_ConnectAtSlot(TConn conn)=0
virtual void InitializeCache(CReaderCacheManager &cache_manager, const TPluginManagerParamTree *params)
Definition: reader.cpp:1390
void SetAndSaveSeq_idLabelFromSeqIds(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const CLoadLockSeqIds &seq_ids) const
Definition: reader.cpp:1180
virtual void ConnectSucceeds(TConn conn)
Definition: reader.cpp:304
virtual bool LoadTypes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTypes &ret)
Definition: reader.cpp:822
int m_WaitTimeErrors
Definition: reader.hpp:404
void SetAndSaveSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceGi &gi) const
Definition: reader.cpp:1233
void SetAndSaveBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id, TBlobVersion version) const
Definition: reader.cpp:1110
virtual bool MayBeSkippedOnErrors(void) const
Definition: reader.cpp:484
int TBlobVersion
Definition: reader.hpp:91
vector< CBlob_Info > TBlobIds
Definition: reader.hpp:97
TFreeConnections m_FreeConnections
Definition: reader.hpp:397
void SetAndSaveBlobState(CReaderRequestResult &result, const TBlobId &blob_id, TBlobState blob_state) const
Definition: reader.cpp:1097
vector< int > TStates
Definition: reader.hpp:129
CReader(void)
Definition: reader.cpp:111
virtual bool LoadTaxIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTaxIds &ret)
Definition: reader.cpp:754
virtual void ConnectFailed(TConn conn)
Definition: reader.cpp:310
void SetAndSaveNoBlob(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, TBlobState blob_state)
Definition: reader.cpp:1065
static int ReadInt(CNcbiIstream &stream)
Definition: reader.cpp:1378
virtual bool LoadSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:628
CIncreasingTime m_WaitTime
Definition: reader.hpp:405
TConn x_AllocConnection(bool oldest=false)
Definition: reader.cpp:361
vector< string > TLabels
Definition: reader.hpp:127
void SetAndSaveSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const CFixedSeq_ids &seq_ids) const
Definition: reader.cpp:1123
vector< TGi > TGis
Definition: reader.hpp:126
virtual bool LoadBlob(CReaderRequestResult &result, const CBlob_id &blob_id)=0
unsigned TConn
Definition: reader.hpp:87
atomic< int > m_ConnectFailCount
Definition: reader.hpp:401
void SetAndSaveSeq_idGiFromSeqIds(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const CLoadLockSeqIds &seq_ids) const
Definition: reader.cpp:1167
virtual bool LoadBulkIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TBulkIds &ret)
Definition: reader.cpp:661
virtual bool LoadSequenceLength(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:596
virtual bool LoadChunks(CReaderRequestResult &result, const TBlobId &blob_id, const TChunkIds &chunk_ids)
Definition: reader.cpp:993
void SetAndSaveSequenceLength(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TSeqPos length) const
Definition: reader.cpp:1298
void SetAndSaveSeq_idTaxId(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TTaxId taxid) const
Definition: reader.cpp:1272
void x_ReleaseConnection(TConn conn, double retry_delay=0)
Definition: reader.cpp:407
virtual void ResetCache(void)
Definition: reader.cpp:1396
TConn m_NextNewConnection
Definition: reader.hpp:390
vector< TSeqPos > TLengths
Definition: reader.hpp:132
vector< pair< TBlobId, TChunkIds > > TBlobChunkIds
Definition: reader.hpp:135
virtual bool LoadGis(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TGis &ret)
Definition: reader.cpp:709
bool m_IncludeHUP
Definition: reader.hpp:387
void x_AbortConnection(TConn conn, bool failed)
Definition: reader.cpp:419
void SetAndSaveSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const string &label) const
Definition: reader.cpp:1259
virtual bool LoadAccVers(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TIds &ret)
Definition: reader.cpp:685
void x_AddConnection(void)
Definition: reader.cpp:340
TConn m_MaxConnections
Definition: reader.hpp:385
vector< CSeq_inst::EMol > TTypes
Definition: reader.hpp:133
CTime m_LastTimeFailed
Definition: reader.hpp:402
vector< int > THashes
Definition: reader.hpp:130
virtual void SetIncludeHUP(bool include_hup=true, const string &web_cookie=NcbiEmptyString)
Definition: reader.cpp:1401
virtual int GetMaximumConnectionsLimit(void) const
Definition: reader.cpp:266
virtual bool LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:490
void SetMaximumRetryCount(int retry_count)
Definition: reader.cpp:472
vector< CSeq_id_Handle > TIds
Definition: reader.hpp:123
void x_ReportDisconnect(const char *reader, const char *server, TConn conn, bool failed) const
Definition: reader.cpp:444
virtual bool LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:509
virtual void OpenConnection(TConn conn)
Definition: reader.cpp:326
void SetAndSaveSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, CLoadLockBlobIds &lock, const CLoadLockBlobIds &blob_ids) const
Definition: reader.cpp:1341
int TChunkId
Definition: reader.hpp:93
int GetMaximumConnections(void) const
Definition: reader.cpp:260
virtual void WaitBeforeNewConnection(TConn conn)
Definition: reader.cpp:272
virtual void x_AddConnectionSlot(TConn conn)=0
void SetAndSaveSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceHash &hash) const
Definition: reader.cpp:1285
int m_MaximumRetryCount
Definition: reader.hpp:400
virtual bool LoadChunk(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
Definition: reader.cpp:985
bool m_PreopenConnection
Definition: reader.hpp:386
virtual int GetConst(const string &const_name) const
Definition: reader.cpp:466
CTime m_NextConnectTime
Definition: reader.hpp:403
void InitParams(CConfig &conf, const string &driver_name, int default_max_conn)
Definition: reader.cpp:131
vector< TChunkId > TChunkIds
Definition: reader.hpp:95
vector< bool > TLoaded
Definition: reader.hpp:124
virtual bool LoadLengths(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLengths &ret)
Definition: reader.cpp:801
virtual void SetParams(const CReaderParams &params)
Definition: reader.cpp:1408
int SetMaximumConnections(int max)
Definition: reader.cpp:228
CMutex m_ConnectionsMutex
Definition: reader.hpp:398
virtual void SetNewConnectionDelayMicroSec(unsigned long micro_sec)
Definition: reader.cpp:318
int TContentsMask
Definition: reader.hpp:94
virtual bool LoadSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel)
All LoadXxx() methods should return false if there is no requested data in the reader.
Definition: reader.cpp:884
int TState
Definition: reader.hpp:89
bool GetPreopenConnection(void) const
Definition: reader.cpp:213
int TBlobState
Definition: reader.hpp:90
void SetAndSaveSeq_idAccFromSeqIds(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const CLoadLockSeqIds &seq_ids) const
Definition: reader.cpp:1154
vector< TTaxId > TTaxIds
Definition: reader.hpp:128
virtual ~CReader(void)
Definition: reader.cpp:126
virtual bool LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
Definition: reader.cpp:903
virtual void x_RemoveConnectionSlot(TConn conn)=0
void SetAndSaveNoSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TState state) const
Definition: reader.cpp:1222
virtual bool LoadSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:528
vector< bool > TKnown
Definition: reader.hpp:131
CConstRef< CBioseq_Info > FindMatchingBioseq(const CSeq_id_Handle &id) const
Definition: tse_info.cpp:776
void SetName(const CAnnotName &name)
Definition: tse_info.cpp:333
CTimeSpan.
Definition: ncbitime.hpp:1313
CTime –.
Definition: ncbitime.hpp:296
definition of a Culling tree
Definition: ncbi_tree.hpp:100
BLOB cache read/write/maintenance interface.
Definition: icache.hpp:64
SetPostFlags –.
Definition: ncbidiag.hpp:848
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
static const struct name_t names[]
int failed
Definition: dbmorecmds.c:10
#define false
Definition: bool.h:36
static int type
Definition: getdata.c:31
char data[12]
Definition: iconv.c:80
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define INVALID_TAX_ID
Definition: ncbimisc.hpp:1116
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
Definition: ncbimisc.hpp:878
#define _TRACE(message)
Definition: ncbidbg.hpp:122
#define LOG_POST_X(err_subcode, message)
Definition: ncbidiag.hpp:553
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
@ eDPF_TID
Thread ID.
Definition: ncbidiag.hpp:705
@ eDPF_DateTime
Include date and time.
Definition: ncbidiag.hpp:700
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
Definition: ncbiexpt.hpp:737
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
int GetInt(const string &driver_name, const string &param_name, EErrAction on_error, int default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
bool GetBool(const string &driver_name, const string &param_name, EErrAction on_error, bool default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
@ eErr_NoThrow
Return default value on error.
bool IsIncludedAnyNamedAnnotAccession(void) const
check if any named annot accession is included in the search
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
void Wait(void)
Wait on semaphore.
Definition: ncbimtx.cpp:1787
void Post(unsigned int count=1)
Increment the semaphore by "count".
Definition: ncbimtx.cpp:1971
CTime & AddTimeSpan(const CTimeSpan &timespan)
Add specified time span.
Definition: ncbitime.cpp:1911
CTime & Clear(void)
Make the time "empty",.
Definition: ncbitime.cpp:1998
bool IsEmpty(void) const
Is time object empty (date and time)?
Definition: ncbitime.hpp:2378
double DiffNanoSecond(const CTime &t) const
Difference in nanoseconds from specified time.
Definition: ncbitime.hpp:2412
@ eCurrent
Use current time. See also CCurrentTime.
Definition: ncbitime.hpp:300
static const char label[]
Definition of all error codes used in objtools libraries.
int i
static MDB_envinfo info
Definition: mdb_load.c:37
static int version
Definition: mdb_load.c:29
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
void SleepMicroSec(unsigned long mc_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
T max(T x_, T y_)
T min(T x_, T y_)
@ fBlobHasCore
Definition: blob_id.hpp:155
@ fBlobHasDescr
Definition: blob_id.hpp:156
static int error_count
Definition: pcregrep.c:171
#define DEFAULT_PREOPEN
Definition: reader.cpp:80
#define TRACE_SET(m)
Definition: reader.cpp:55
#define DEFAULT_WAIT_TIME_MAX
Definition: reader.cpp:86
static CIncreasingTime::SAllParams s_WaitTimeParams
Definition: reader.cpp:88
#define DEFAULT_RETRY_COUNT
Definition: reader.cpp:81
NCBI_DEFINE_ERR_SUBCODE_X(9)
#define DEFAULT_WAIT_TIME_MULTIPLIER
Definition: reader.cpp:84
#define DEFAULT_WAIT_TIME_ERRORS
Definition: reader.cpp:82
#define DEFAULT_WAIT_TIME_INCREMENT
Definition: reader.cpp:85
#define DEFAULT_WAIT_TIME
Definition: reader.cpp:83
#define NCBI_GBLOADER_READER_PARAM_WAIT_TIME_MAX
Definition: reader_params.h:54
#define NCBI_GBLOADER_READER_PARAM_WAIT_TIME_ERRORS
Definition: reader_params.h:46
#define NCBI_GBLOADER_READER_PARAM_WAIT_TIME_MULTIPLIER
Definition: reader_params.h:50
#define NCBI_GBLOADER_READER_PARAM_WAIT_TIME
Definition: reader_params.h:48
#define NCBI_GBLOADER_READER_PARAM_RETRY_COUNT
Definition: reader_params.h:43
#define NCBI_GBLOADER_READER_PARAM2_NUM_CONN
Definition: reader_params.h:39
#define NCBI_GBLOADER_READER_PARAM_PREOPEN
Definition: reader_params.h:41
#define NCBI_GBLOADER_READER_PARAM_NUM_CONN
Definition: reader_params.h:38
#define NCBI_GBLOADER_READER_PARAM_WAIT_TIME_INCREMENT
Definition: reader_params.h:52
Better replacement of GetAccVer(), this method should be defined in data loaders, GetAccVer() is left...
Better replacement of GetGi(), this method should be defined in data loaders, GetGi() is left for com...
Better replacement of GetSequenceHash(), this method should be defined in data loaders,...
Better replacement of GetSequenceType(), this method should be defined in data loaders,...
SReaderCacheInfo(ICache &cache, ECacheType cache_type)
Definition: reader.cpp:1423
double m_RetryDelay
Definition: reader.hpp:394
SAnnotSelector –.
Definition: _hash_fun.h:40
Definition: type.c:6
SQLSMALLINT type
Definition: type.c:7
#define _ASSERT
else result
Definition: token2.c:20
Modified on Tue Apr 30 06:43:00 2024 by modify_doxy.py rev. 669887