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

Go to the SVN repository for this file.

1 /* $Id: dispatcher.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: Anton Butanaev, Eugene Vasilchenko
25  *
26  * File Description: Base data reader interface
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
37 #include <objtools/error_codes.hpp>
42 
43 
44 #define NCBI_USE_ERRCODE_X Objtools_Rd_Disp
45 
47 
49 
51 
52 NCBI_PARAM_DECL(bool, GENBANK, ALLOW_INCOMPLETE_COMMANDS);
53 NCBI_PARAM_DEF_EX(bool, GENBANK, ALLOW_INCOMPLETE_COMMANDS, false,
54  eParam_NoThread, GENBANK_ALLOW_INCOMPLETE_COMMANDS);
55 
56 static
58 {
59  static CSafeStatic<NCBI_PARAM_TYPE(GENBANK, ALLOW_INCOMPLETE_COMMANDS)> s_Value;
60  return s_Value->Get();
61 }
62 
63 
64 /////////////////////////////////////////////////////////////////////////////
65 // CReadDispatcher
66 /////////////////////////////////////////////////////////////////////////////
67 
68 
70 {
71  CGBRequestStatistics("resolved", "string ids"),
72  CGBRequestStatistics("resolved", "seq-ids"),
73  CGBRequestStatistics("resolved", "gis"),
74  CGBRequestStatistics("resolved", "accs"),
75  CGBRequestStatistics("resolved", "labels"),
76  CGBRequestStatistics("resolved", "taxids"),
77  CGBRequestStatistics("resolved", "blob ids"),
78  CGBRequestStatistics("resolved", "blob state"),
79  CGBRequestStatistics("resolved", "blob versions"),
80  CGBRequestStatistics("loaded", "blob data"),
81  CGBRequestStatistics("loaded", "SNP data"),
82  CGBRequestStatistics("loaded", "split data"),
83  CGBRequestStatistics("loaded", "chunk data"),
84  CGBRequestStatistics("parsed", "blob data"),
85  CGBRequestStatistics("parsed", "SNP data"),
86  CGBRequestStatistics("parsed", "split data"),
87  CGBRequestStatistics("parsed", "chunk data"),
88  CGBRequestStatistics("attached", "blob data"),
89  CGBRequestStatistics("attached", "SNP data"),
90  CGBRequestStatistics("attached", "split data"),
91  CGBRequestStatistics("attached", "chunk data"),
92  CGBRequestStatistics("loaded", "sequence hash"),
93  CGBRequestStatistics("loaded", "sequence length"),
94  CGBRequestStatistics("loaded", "sequence type")
95 };
96 
98  const char* entity)
99  : m_Action(action), m_Entity(entity),
100  m_Count(0), m_Time(0), m_Size(0)
101 {
102 }
103 
105 {
107  NCBI_THROW_FMT(CLoaderException, eOtherError,
108  "CGBRequestStatistics::GetStatistics: "
109  "invalid statistics type: "<<type);
110  }
111  return sx_Statistics[type];
112 }
113 
115 {
116  size_t count = GetCount();
117  if ( count > 0 ) {
118  double time = GetTime();
119  double size = GetSize();
120  if ( size <= 0 ) {
121  LOG_POST_X(5, "GBLoader: " << GetAction() << ' ' <<
122  count << ' ' << GetEntity() << " in " <<
123  setiosflags(ios::fixed) <<
124  setprecision(3) <<
125  (time) << " s (" <<
126  (time*1000/count) << " ms/one)");
127  }
128  else {
129  LOG_POST_X(6, "GBLoader: " << GetAction() << ' ' <<
130  count << ' ' << GetEntity() << " in " <<
131  setiosflags(ios::fixed) <<
132  setprecision(3) <<
133  (time) << " s (" <<
134  (time*1000/count) << " ms/one)" <<
135  setprecision(2) << " (" <<
136  (size/1024.0) << " kB " <<
137  (size/time/1024) << " kB/s)");
138  }
139  }
140 }
141 
142 
144 {
145  for ( int type = eStat_First; type <= eStat_Last; ++type ) {
147  }
148 }
149 
150 inline
152 {
153  static CSafeStatic<NCBI_PARAM_TYPE(GENBANK, READER_STATS)> s_Value;
154  return s_Value->Get();
155 }
156 
157 
159 {
162 }
163 
164 
166 {
167  if ( CollectStatistics() > 0 ) {
169  }
170 }
171 
172 
174 {
175  if ( !reader ) {
176  return;
177  }
178 
179  m_Readers[level] = reader;
180  reader->m_Dispatcher = this;
181 }
182 
183 
185 {
186  if ( !writer ) {
187  return;
188  }
189 
190  m_Writers[level] = writer;
191 }
192 
193 
195 {
196  if ( !processor ) {
197  return;
198  }
199 
200  m_Processors[processor->GetType()] = processor;
201 }
202 
203 
205  CWriter::EType type) const
206 {
207  ITERATE ( TWriters, i, m_Writers ) {
208  if ( i->first >= result.GetLevel() ) {
209  break;
210  }
211  if ( i->second->CanWrite(type) ) {
212  return const_cast<CWriter*>(i->second.GetPointer());
213  }
214  }
215  return 0;
216 }
217 
218 
220 {
222  if ( iter == m_Processors.end() ) {
223  NCBI_THROW_FMT(CLoaderException, eLoaderFailed,
224  "CReadDispatcher::GetProcessor: "
225  "processor unknown: "<<type);
226  }
227  return *iter->second;
228 }
229 
230 
232 {
233  if ( m_Readers.empty() ) {
234  NCBI_THROW(CLoaderException, eLoaderFailed, "no reader loaded");
235  }
236 }
237 
238 
240 {
241  for ( auto& rd : m_Readers ) {
242  if ( rd.second->HasHUPIncluded() ) {
243  return true;
244  }
245  }
246  return false;
247 }
248 
249 
251 {
253  rd->second->ResetCache();
254  }
256  wr->second->ResetCache();
257  }
258 }
259 
260 
262 {
263  return !sih || sih.Which() == CSeq_id::e_Local ||
264  (sih.Which() == CSeq_id::e_General &&
265  NStr::EqualNocase(sih.GetSeqId()->GetGeneral().GetDb(), "SRA"));
266 }
267 
268 
270  : m_Result(result)
271 {
272 }
273 
274 
276 {
277 }
278 
279 
281 {
282  return false;
283 }
284 
285 
287 {
288  return 1;
289 }
290 
291 
292 namespace {
293  class CCommandLoadSeq_idSeq_ids : public CReadDispatcherCommand
294  {
295  public:
296  typedef CSeq_id_Handle TKey;
297  typedef CLoadLockSeqIds TLock;
298  CCommandLoadSeq_idSeq_ids(CReaderRequestResult& result,
299  const TKey& key)
301  m_Key(key), m_Lock(result, key)
302  {
303  }
304 
305  bool IsDone(void)
306  {
307  return m_Lock.IsLoaded();
308  }
309  bool Execute(CReader& reader)
310  {
311  return reader.LoadSeq_idSeq_ids(GetResult(), m_Key);
312  }
313  string GetErrMsg(void) const
314  {
315  return "LoadSeq_idSeq_ids("+m_Key.AsString()+"): "
316  "data not found";
317  }
318  CGBRequestStatistics::EStatType GetStatistics(void) const
319  {
321  }
322  string GetStatisticsDescription(void) const
323  {
324  return "Seq-ids("+m_Key.AsString()+")";
325  }
326 
327  private:
328  TKey m_Key;
329  TLock m_Lock;
330  };
331 
332  class CCommandLoadSeq_idGi : public CReadDispatcherCommand
333  {
334  public:
335  typedef CSeq_id_Handle TKey;
336  typedef CLoadLockGi TLock;
337  CCommandLoadSeq_idGi(CReaderRequestResult& result,
338  const TKey& key)
340  m_Key(key), m_Lock(result, key)
341  {
342  }
343 
344  bool IsDone(void)
345  {
346  return m_Lock.IsLoadedGi();
347  }
348  bool Execute(CReader& reader)
349  {
350  return reader.LoadSeq_idGi(GetResult(), m_Key);
351  }
352  string GetErrMsg(void) const
353  {
354  return "LoadSeq_idGi("+m_Key.AsString()+"): "
355  "data not found";
356  }
357  CGBRequestStatistics::EStatType GetStatistics(void) const
358  {
360  }
361  string GetStatisticsDescription(void) const
362  {
363  return "gi("+m_Key.AsString()+")";
364  }
365 
366  private:
367  TKey m_Key;
368  TLock m_Lock;
369  };
370 
371  class CCommandLoadSeq_idAccVer : public CReadDispatcherCommand
372  {
373  public:
374  typedef CSeq_id_Handle TKey;
375  typedef CLoadLockAcc TLock;
376  CCommandLoadSeq_idAccVer(CReaderRequestResult& result,
377  const TKey& key)
379  m_Key(key), m_Lock(result, key)
380  {
381  }
382 
383  bool IsDone(void)
384  {
385  return m_Lock.IsLoadedAccVer();
386  }
387  bool Execute(CReader& reader)
388  {
389  return reader.LoadSeq_idAccVer(GetResult(), m_Key);
390  }
391  string GetErrMsg(void) const
392  {
393  return "LoadSeq_idAccVer("+m_Key.AsString()+"): "
394  "data not found";
395  }
396  CGBRequestStatistics::EStatType GetStatistics(void) const
397  {
399  }
400  string GetStatisticsDescription(void) const
401  {
402  return "acc("+m_Key.AsString()+")";
403  }
404 
405  private:
406  TKey m_Key;
407  TLock m_Lock;
408  };
409 
410  class CCommandLoadSeq_idLabel : public CReadDispatcherCommand
411  {
412  public:
413  typedef CSeq_id_Handle TKey;
414  typedef CLoadLockLabel TLock;
415  CCommandLoadSeq_idLabel(CReaderRequestResult& result,
416  const TKey& key)
418  m_Key(key), m_Lock(result, key)
419  {
420  }
421 
422  bool IsDone(void)
423  {
424  return m_Lock.IsLoadedLabel();
425  }
426  bool Execute(CReader& reader)
427  {
428  return reader.LoadSeq_idLabel(GetResult(), m_Key);
429  }
430  string GetErrMsg(void) const
431  {
432  return "LoadSeq_idLabel("+m_Key.AsString()+"): "
433  "data not found";
434  }
435  CGBRequestStatistics::EStatType GetStatistics(void) const
436  {
438  }
439  string GetStatisticsDescription(void) const
440  {
441  return "label("+m_Key.AsString()+")";
442  }
443 
444  private:
445  TKey m_Key;
446  TLock m_Lock;
447  };
448 
449  class CCommandLoadSeq_idTaxId : public CReadDispatcherCommand
450  {
451  public:
452  typedef CSeq_id_Handle TKey;
453  typedef CLoadLockTaxId TLock;
454  CCommandLoadSeq_idTaxId(CReaderRequestResult& result,
455  const TKey& key)
457  m_Key(key), m_Lock(result, key)
458  {
459  }
460 
461  bool IsDone(void)
462  {
463  return m_Lock.IsLoadedTaxId();
464  }
465  bool Execute(CReader& reader)
466  {
467  return reader.LoadSeq_idTaxId(GetResult(), m_Key);
468  }
469  bool MayBeSkipped(void) const
470  {
471  return true;
472  }
473  string GetErrMsg(void) const
474  {
475  return "LoadSeq_idTaxId("+m_Key.AsString()+"): "
476  "data not found";
477  }
478  CGBRequestStatistics::EStatType GetStatistics(void) const
479  {
481  }
482  string GetStatisticsDescription(void) const
483  {
484  return "taxid("+m_Key.AsString()+")";
485  }
486 
487  private:
488  TKey m_Key;
489  TLock m_Lock;
490  };
491 
492  class CCommandLoadSequenceHash : public CReadDispatcherCommand
493  {
494  public:
495  typedef CSeq_id_Handle TKey;
496  typedef CLoadLockHash TLock;
497  CCommandLoadSequenceHash(CReaderRequestResult& result,
498  const TKey& key)
500  m_Key(key), m_Lock(result, key)
501  {
502  }
503 
504  bool IsDone(void)
505  {
506  return m_Lock.IsLoadedHash();
507  }
508  bool Execute(CReader& reader)
509  {
510  return reader.LoadSequenceHash(GetResult(), m_Key);
511  }
512  bool MayBeSkipped(void) const
513  {
514  return true;
515  }
516  string GetErrMsg(void) const
517  {
518  return "LoadSequenceHash("+m_Key.AsString()+"): "
519  "data not found";
520  }
521  CGBRequestStatistics::EStatType GetStatistics(void) const
522  {
524  }
525  string GetStatisticsDescription(void) const
526  {
527  return "hash("+m_Key.AsString()+")";
528  }
529 
530  private:
531  TKey m_Key;
532  TLock m_Lock;
533  };
534 
535  class CCommandLoadSequenceLength : public CReadDispatcherCommand
536  {
537  public:
538  typedef CSeq_id_Handle TKey;
539  typedef CLoadLockLength TLock;
540  CCommandLoadSequenceLength(CReaderRequestResult& result,
541  const TKey& key)
543  m_Key(key), m_Lock(result, key)
544  {
545  }
546 
547  bool IsDone(void)
548  {
549  return m_Lock.IsLoadedLength();
550  }
551  bool Execute(CReader& reader)
552  {
553  return reader.LoadSequenceLength(GetResult(), m_Key);
554  }
555  bool MayBeSkipped(void) const
556  {
557  return true;
558  }
559  string GetErrMsg(void) const
560  {
561  return "LoadSequenceLength("+m_Key.AsString()+"): "
562  "data not found";
563  }
564  CGBRequestStatistics::EStatType GetStatistics(void) const
565  {
567  }
568  string GetStatisticsDescription(void) const
569  {
570  return "length("+m_Key.AsString()+")";
571  }
572 
573  private:
574  TKey m_Key;
575  TLock m_Lock;
576  };
577 
578  class CCommandLoadSequenceType : public CReadDispatcherCommand
579  {
580  public:
581  typedef CSeq_id_Handle TKey;
582  typedef CLoadLockType TLock;
583  CCommandLoadSequenceType(CReaderRequestResult& result,
584  const TKey& key)
586  m_Key(key), m_Lock(result, key)
587  {
588  }
589 
590  bool IsDone(void)
591  {
592  return m_Lock.IsLoadedType();
593  }
594  bool Execute(CReader& reader)
595  {
596  return reader.LoadSequenceType(GetResult(), m_Key);
597  }
598  bool MayBeSkipped(void) const
599  {
600  return true;
601  }
602  string GetErrMsg(void) const
603  {
604  return "LoadSequenceType("+m_Key.AsString()+"): "
605  "data not found";
606  }
607  CGBRequestStatistics::EStatType GetStatistics(void) const
608  {
610  }
611  string GetStatisticsDescription(void) const
612  {
613  return "type("+m_Key.AsString()+")";
614  }
615 
616  private:
617  TKey m_Key;
618  TLock m_Lock;
619  };
620 
621  bool s_Blob_idsLoaded(CLoadLockBlobIds& ids,
623  const CSeq_id_Handle& seq_id)
624  {
625  if ( ids.IsLoaded() ) {
626  return true;
627  }
628  // check if seq-id is known as absent
629  CLoadLockSeqIds seq_ids(result, seq_id, eAlreadyLoaded);
630  if ( seq_ids && !seq_ids.GetData().IsFound() ) {
631  // mark blob-ids as absent too
632  ids.SetNoBlob_ids(seq_ids.GetState());
633  return true;
634  }
635  return false;
636  }
637 
638  class CCommandLoadSeq_idBlob_ids : public CReadDispatcherCommand
639  {
640  public:
641  typedef CSeq_id_Handle TKey;
642  typedef CLoadLockBlobIds TLock;
643  CCommandLoadSeq_idBlob_ids(CReaderRequestResult& result,
644  const TKey& key,
645  const SAnnotSelector* sel)
647  m_Key(key), m_Selector(sel),
648  m_Lock(result, key, sel)
649  {
650  }
651 
652  bool IsDone(void)
653  {
654  return s_Blob_idsLoaded(m_Lock, GetResult(), m_Key);
655  }
656  bool Execute(CReader& reader)
657  {
658  return reader.LoadSeq_idBlob_ids(GetResult(),
659  m_Key, m_Selector);
660  }
661  string GetErrMsg(void) const
662  {
663  return "LoadSeq_idBlob_ids("+m_Key.AsString()+"): "
664  "data not found";
665  }
666  CGBRequestStatistics::EStatType GetStatistics(void) const
667  {
669  }
670  string GetStatisticsDescription(void) const
671  {
672  return "blob-ids("+m_Key.AsString()+")";
673  }
674 
675  private:
676  TKey m_Key;
677  const SAnnotSelector* m_Selector;
678  TLock m_Lock;
679  };
680 
681  template<class CLoadLock>
682  bool sx_IsLoaded(size_t i,
684  const vector<CSeq_id_Handle>& ids,
685  const vector<bool>& loaded)
686  {
687  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
688  return true;
689  }
690  CLoadLock lock(result, ids[i]);
691  if ( lock.IsLoaded() && !lock.IsFound() ) {
692  return true;
693  }
694  return false;
695  }
696 
697  template<class CLoadLock>
698  bool sx_BulkIsDone(CReaderRequestResult& result,
699  const vector<CSeq_id_Handle>& ids,
700  const vector<bool>& loaded)
701  {
702  for ( size_t i = 0; i < ids.size(); ++i ) {
703  if ( sx_IsLoaded<CLoadLock>(i, result, ids, loaded) ) {
704  continue;
705  }
706  return false;
707  }
708  return true;
709  }
710 
711  template<class CLoadLock>
712  string sx_DescribeError(CReaderRequestResult& result,
713  const vector<CSeq_id_Handle>& ids,
714  const vector<bool>& loaded)
715  {
716  string ret;
717  for ( size_t i = 0; i < ids.size(); ++i ) {
718  if ( sx_IsLoaded<CLoadLock>(i, result, ids, loaded) ) {
719  continue;
720  }
721  if ( !ret.empty() ) {
722  ret += ", ";
723  }
724  ret += ids[i].AsString();
725  }
726  ret += " ["+NStr::SizetToString(ids.size())+"]";
727  return ret;
728  }
729 
730  class CCommandLoadBulkIds : public CReadDispatcherCommand
731  {
732  public:
733  typedef vector<CSeq_id_Handle> TKey;
734  typedef vector<bool> TLoaded;
735  typedef vector<CSeq_id_Handle> TIds;
736  typedef vector<TIds> TRet;
737  typedef CLoadLockSeqIds CLoadLock;
738  CCommandLoadBulkIds(CReaderRequestResult& result,
739  const TKey& key, TLoaded& loaded, TRet& ret)
741  m_Key(key), m_Loaded(loaded), m_Ret(ret)
742  {
743  }
744 
745  bool Execute(CReader& reader)
746  {
747  return reader.LoadBulkIds(GetResult(), m_Key, m_Loaded, m_Ret);
748  }
749  bool IsDone(void)
750  {
751  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
752  }
753  string GetErrMsg(void) const
754  {
755  return "LoadBulkIds("+
756  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
757  "): data not found";
758  }
759  string GetStatisticsDescription(void) const
760  {
761  return "bulkids("+
762  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
763  ")";
764  }
765  CGBRequestStatistics::EStatType GetStatistics(void) const
766  {
768  }
769  size_t GetStatisticsCount(void) const
770  {
771  return m_Key.size();
772  }
773 
774  private:
775  const TKey& m_Key;
776  TLoaded& m_Loaded;
777  TRet& m_Ret;
778  };
779 
780  class CCommandLoadAccVers : public CReadDispatcherCommand
781  {
782  public:
783  typedef vector<CSeq_id_Handle> TKey;
784  typedef vector<bool> TLoaded;
785  typedef vector<CSeq_id_Handle> TRet;
786  typedef CLoadLockAcc CLoadLock;
787  CCommandLoadAccVers(CReaderRequestResult& result,
788  const TKey& key, TLoaded& loaded, TRet& ret)
790  m_Key(key), m_Loaded(loaded), m_Ret(ret)
791  {
792  }
793 
794  bool Execute(CReader& reader)
795  {
796  return reader.LoadAccVers(GetResult(), m_Key, m_Loaded, m_Ret);
797  }
798  bool IsDone(void)
799  {
800  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
801  }
802  string GetErrMsg(void) const
803  {
804  return "LoadAccVers("+
805  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
806  "): data not found";
807  }
808  string GetStatisticsDescription(void) const
809  {
810  return "accs("+
811  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
812  ")";
813  }
814  CGBRequestStatistics::EStatType GetStatistics(void) const
815  {
817  }
818  size_t GetStatisticsCount(void) const
819  {
820  return m_Key.size();
821  }
822 
823  private:
824  const TKey& m_Key;
825  TLoaded& m_Loaded;
826  TRet& m_Ret;
827  };
828 
829  class CCommandLoadGis : public CReadDispatcherCommand
830  {
831  public:
832  typedef vector<CSeq_id_Handle> TKey;
833  typedef vector<bool> TLoaded;
834  typedef vector<TGi> TRet;
835  typedef CLoadLockGi CLoadLock;
836  CCommandLoadGis(CReaderRequestResult& result,
837  const TKey& key, TLoaded& loaded, TRet& ret)
839  m_Key(key), m_Loaded(loaded), m_Ret(ret)
840  {
841  }
842 
843  bool Execute(CReader& reader)
844  {
845  return reader.LoadGis(GetResult(), m_Key, m_Loaded, m_Ret);
846  }
847  bool IsDone(void)
848  {
849  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
850  }
851  string GetErrMsg(void) const
852  {
853  return "LoadGis("+
854  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
855  "): data not found";
856  }
857  string GetStatisticsDescription(void) const
858  {
859  return "gis("+
860  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
861  ")";
862  }
863  CGBRequestStatistics::EStatType GetStatistics(void) const
864  {
866  }
867  size_t GetStatisticsCount(void) const
868  {
869  return m_Key.size();
870  }
871 
872  private:
873  const TKey& m_Key;
874  TLoaded& m_Loaded;
875  TRet& m_Ret;
876  };
877 
878  class CCommandLoadLabels : public CReadDispatcherCommand
879  {
880  public:
881  typedef vector<CSeq_id_Handle> TKey;
882  typedef vector<bool> TLoaded;
883  typedef vector<string> TRet;
884  typedef CLoadLockLabel CLoadLock;
885  CCommandLoadLabels(CReaderRequestResult& result,
886  const TKey& key, TLoaded& loaded, TRet& ret)
888  m_Key(key), m_Loaded(loaded), m_Ret(ret)
889  {
890  }
891 
892  bool Execute(CReader& reader)
893  {
894  return reader.LoadLabels(GetResult(), m_Key, m_Loaded, m_Ret);
895  }
896  bool IsDone(void)
897  {
898  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
899  }
900  string GetErrMsg(void) const
901  {
902  return "LoadLabels("+
903  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
904  "): data not found";
905  }
906  string GetStatisticsDescription(void) const
907  {
908  return "labels("+
909  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
910  ")";
911  }
912  CGBRequestStatistics::EStatType GetStatistics(void) const
913  {
915  }
916  size_t GetStatisticsCount(void) const
917  {
918  return m_Key.size();
919  }
920 
921  private:
922  const TKey& m_Key;
923  TLoaded& m_Loaded;
924  TRet& m_Ret;
925  };
926 
927  class CCommandLoadTaxIds : public CReadDispatcherCommand
928  {
929  public:
930  typedef vector<CSeq_id_Handle> TKey;
931  typedef vector<bool> TLoaded;
932  typedef vector<TTaxId> TRet;
933  typedef CLoadLockTaxId CLoadLock;
934  CCommandLoadTaxIds(CReaderRequestResult& result,
935  const TKey& key, TLoaded& loaded, TRet& ret)
937  m_Key(key), m_Loaded(loaded), m_Ret(ret)
938  {
939  }
940 
941  bool Execute(CReader& reader)
942  {
943  return reader.LoadTaxIds(GetResult(), m_Key, m_Loaded, m_Ret);
944  }
945  bool MayBeSkipped(void) const
946  {
947  return true;
948  }
949  bool IsDone(void)
950  {
951  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
952  }
953  string GetErrMsg(void) const
954  {
955  return "LoadTaxIds("+
956  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
957  "): data not found";
958  }
959  string GetStatisticsDescription(void) const
960  {
961  return "taxids("+
962  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
963  ")";
964  }
965  CGBRequestStatistics::EStatType GetStatistics(void) const
966  {
968  }
969  size_t GetStatisticsCount(void) const
970  {
971  return m_Key.size();
972  }
973 
974  private:
975  const TKey& m_Key;
976  TLoaded& m_Loaded;
977  TRet& m_Ret;
978  };
979 
980  class CCommandLoadHashes : public CReadDispatcherCommand
981  {
982  public:
983  typedef vector<CSeq_id_Handle> TKey;
984  typedef vector<bool> TLoaded;
985  typedef vector<bool> TKnown;
986  typedef vector<int> TRet;
987  typedef CLoadLockHash CLoadLock;
988  CCommandLoadHashes(CReaderRequestResult& result,
989  const TKey& key, TLoaded& loaded,
990  TRet& ret, TKnown& known)
992  m_Key(key), m_Loaded(loaded), m_Ret(ret), m_Known(known)
993  {
994  }
995 
996  bool Execute(CReader& reader)
997  {
998  return reader.LoadHashes(GetResult(), m_Key, m_Loaded,
999  m_Ret, m_Known);
1000  }
1001  bool MayBeSkipped(void) const
1002  {
1003  return true;
1004  }
1005  bool IsDone(void)
1006  {
1007  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
1008  }
1009  string GetErrMsg(void) const
1010  {
1011  return "LoadHashes("+
1012  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1013  "): data not found";
1014  }
1015  string GetStatisticsDescription(void) const
1016  {
1017  return "hashes("+
1018  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1019  ")";
1020  }
1021  CGBRequestStatistics::EStatType GetStatistics(void) const
1022  {
1024  }
1025  size_t GetStatisticsCount(void) const
1026  {
1027  return m_Key.size();
1028  }
1029 
1030  private:
1031  const TKey& m_Key;
1032  TLoaded& m_Loaded;
1033  TRet& m_Ret;
1034  TKnown& m_Known;
1035  };
1036 
1037  class CCommandLoadLengths : public CReadDispatcherCommand
1038  {
1039  public:
1040  typedef vector<CSeq_id_Handle> TKey;
1041  typedef vector<bool> TLoaded;
1042  typedef vector<TSeqPos> TRet;
1043  typedef CLoadLockLength CLoadLock;
1044  CCommandLoadLengths(CReaderRequestResult& result,
1045  const TKey& key, TLoaded& loaded, TRet& ret)
1047  m_Key(key), m_Loaded(loaded), m_Ret(ret)
1048  {
1049  }
1050 
1051  bool Execute(CReader& reader)
1052  {
1053  return reader.LoadLengths(GetResult(), m_Key, m_Loaded, m_Ret);
1054  }
1055  bool MayBeSkipped(void) const
1056  {
1057  return true;
1058  }
1059  bool IsDone(void)
1060  {
1061  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
1062  }
1063  string GetErrMsg(void) const
1064  {
1065  return "LoadLengths("+
1066  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1067  "): data not found";
1068  }
1069  string GetStatisticsDescription(void) const
1070  {
1071  return "lengths("+
1072  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1073  ")";
1074  }
1075  CGBRequestStatistics::EStatType GetStatistics(void) const
1076  {
1078  }
1079  size_t GetStatisticsCount(void) const
1080  {
1081  return m_Key.size();
1082  }
1083 
1084  private:
1085  const TKey& m_Key;
1086  TLoaded& m_Loaded;
1087  TRet& m_Ret;
1088  };
1089 
1090  class CCommandLoadTypes : public CReadDispatcherCommand
1091  {
1092  public:
1093  typedef vector<CSeq_id_Handle> TKey;
1094  typedef vector<bool> TLoaded;
1095  typedef vector<CSeq_inst::EMol> TRet;
1096  typedef CLoadLockType CLoadLock;
1097  CCommandLoadTypes(CReaderRequestResult& result,
1098  const TKey& key, TLoaded& loaded, TRet& ret)
1100  m_Key(key), m_Loaded(loaded), m_Ret(ret)
1101  {
1102  }
1103 
1104  bool Execute(CReader& reader)
1105  {
1106  return reader.LoadTypes(GetResult(), m_Key, m_Loaded, m_Ret);
1107  }
1108  bool MayBeSkipped(void) const
1109  {
1110  return true;
1111  }
1112  bool IsDone(void)
1113  {
1114  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
1115  }
1116  string GetErrMsg(void) const
1117  {
1118  return "LoadTypes("+
1119  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1120  "): data not found";
1121  }
1122  string GetStatisticsDescription(void) const
1123  {
1124  return "types("+
1125  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1126  ")";
1127  }
1128  CGBRequestStatistics::EStatType GetStatistics(void) const
1129  {
1131  }
1132  size_t GetStatisticsCount(void) const
1133  {
1134  return m_Key.size();
1135  }
1136 
1137  private:
1138  const TKey& m_Key;
1139  TLoaded& m_Loaded;
1140  TRet& m_Ret;
1141  };
1142 
1143  class CCommandLoadStates : public CReadDispatcherCommand
1144  {
1145  public:
1146  typedef vector<CSeq_id_Handle> TKey;
1147  typedef vector<bool> TLoaded;
1148  typedef vector<int> TRet;
1149  typedef CLoadLockBlobIds CLoadLock;
1150  CCommandLoadStates(CReaderRequestResult& result,
1151  const TKey& key, TLoaded& loaded, TRet& ret)
1153  m_Key(key), m_Loaded(loaded), m_Ret(ret)
1154  {
1155  }
1156 
1157  bool Execute(CReader& reader)
1158  {
1159  return reader.LoadStates(GetResult(), m_Key, m_Loaded, m_Ret);
1160  }
1161  bool IsDone(void)
1162  {
1163  return sx_BulkIsDone<CLoadLock>(GetResult(), m_Key, m_Loaded);
1164  }
1165  string GetErrMsg(void) const
1166  {
1167  return "LoadStates("+
1168  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1169  "): data not found";
1170  }
1171  string GetStatisticsDescription(void) const
1172  {
1173  return "states("+
1174  sx_DescribeError<CLoadLock>(GetResult(), m_Key, m_Loaded)+
1175  ")";
1176  }
1177  CGBRequestStatistics::EStatType GetStatistics(void) const
1178  {
1180  }
1181  size_t GetStatisticsCount(void) const
1182  {
1183  return m_Key.size();
1184  }
1185 
1186  private:
1187  const TKey& m_Key;
1188  TLoaded& m_Loaded;
1189  TRet& m_Ret;
1190  };
1191 
1192  static const size_t kMaxErrorSeqIds = 100;
1193 
1194  string sx_ErrorSeqIds(CReaderRequestResult& result, const vector<CBlob_id>& keys)
1195  {
1196  string ret = "; seq-ids: { ";
1197  if (result.GetRequestedId()) {
1198  ret += result.GetRequestedId().AsString();
1199  }
1200  else {
1201  size_t total = 0;
1202  for (auto key : keys) {
1203  CTSE_LoadLock lock = result.GetTSE_LoadLock(key);
1204  CTSE_Info::TSeqIds ids;
1205  lock->GetBioseqsIds(ids);
1206  if (!ids.empty()) {
1207  int cnt = 0;
1208  for (auto& id : ids) {
1209  if (++total > kMaxErrorSeqIds) continue;
1210  if (cnt++ > 0) ret += ", ";
1211  ret += id.AsString();
1212  }
1213  }
1214  }
1215  if (total == 0) return "";
1216  if (total > kMaxErrorSeqIds) {
1217  ret += ", ... (+" + NStr::NumericToString(total - kMaxErrorSeqIds) + " more)";
1218  }
1219  }
1220  ret += " }";
1221  return ret;
1222  }
1223 
1224  string sx_ErrorSeqIds(CReaderRequestResult& result,
1225  const vector<pair<CBlob_id, vector<int>>>& keys)
1226  {
1227  string ret = "; seq-ids: { ";
1228  if (result.GetRequestedId()) {
1229  ret += result.GetRequestedId().AsString();
1230  }
1231  else {
1232  size_t total = 0;
1233  for ( auto& key : keys ) {
1234  CTSE_LoadLock lock = result.GetTSE_LoadLock(key.first);
1235  CTSE_Info::TSeqIds ids;
1236  lock->GetBioseqsIds(ids);
1237  if (!ids.empty()) {
1238  int cnt = 0;
1239  for (auto& id : ids) {
1240  if (++total > kMaxErrorSeqIds) continue;
1241  if (cnt++ > 0) ret += ", ";
1242  ret += id.AsString();
1243  }
1244  }
1245  }
1246  if (total == 0) return "";
1247  if (total > kMaxErrorSeqIds) {
1248  ret += ", ... (+" + NStr::NumericToString(total - kMaxErrorSeqIds) + " more)";
1249  }
1250  }
1251  ret += " }";
1252  return ret;
1253  }
1254 
1255  class CCommandLoadBlobState : public CReadDispatcherCommand
1256  {
1257  public:
1258  typedef CBlob_id TKey;
1259  typedef CLoadLockBlobState TLock;
1260  CCommandLoadBlobState(CReaderRequestResult& result,
1261  const TKey& key)
1263  m_Key(key), m_Lock(result, key)
1264  {
1265  }
1266 
1267  bool IsDone(void)
1268  {
1269  return m_Lock.IsLoadedBlobState();
1270  }
1271  bool Execute(CReader& reader)
1272  {
1273  return reader.LoadBlobState(GetResult(), m_Key);
1274  }
1275  string GetErrMsg(void) const
1276  {
1277  return "LoadBlobVersion("+m_Key.ToString()+")" +
1278  sx_ErrorSeqIds(GetResult(), {m_Key}) + ": data not found";
1279  }
1280  CGBRequestStatistics::EStatType GetStatistics(void) const
1281  {
1283  }
1284  string GetStatisticsDescription(void) const
1285  {
1286  return "blob-version("+m_Key.ToString()+")";
1287  }
1288 
1289  private:
1290  TKey m_Key;
1291  TLock m_Lock;
1292  };
1293 
1294  class CCommandLoadBlobVersion : public CReadDispatcherCommand
1295  {
1296  public:
1297  typedef CBlob_id TKey;
1298  typedef CLoadLockBlobVersion TLock;
1299  CCommandLoadBlobVersion(CReaderRequestResult& result,
1300  const TKey& key)
1302  m_Key(key), m_Lock(result, key)
1303  {
1304  }
1305 
1306  bool IsDone(void)
1307  {
1308  return m_Lock.IsLoadedBlobVersion();
1309  }
1310  bool Execute(CReader& reader)
1311  {
1312  return reader.LoadBlobVersion(GetResult(), m_Key);
1313  }
1314  string GetErrMsg(void) const
1315  {
1316  return "LoadBlobVersion("+m_Key.ToString()+")" +
1317  sx_ErrorSeqIds(GetResult(), {m_Key}) + ": "
1318  "data not found";
1319  }
1320  CGBRequestStatistics::EStatType GetStatistics(void) const
1321  {
1323  }
1324  string GetStatisticsDescription(void) const
1325  {
1326  return "blob-version("+m_Key.ToString()+")";
1327  }
1328 
1329  private:
1330  TKey m_Key;
1331  TLock m_Lock;
1332  };
1333 
1334  bool s_AllBlobsAreLoaded(CReaderRequestResult& result,
1335  const CReader::TBlobIds& infos,
1337  const SAnnotSelector* sel = 0)
1338  {
1339  for ( auto& info : infos ) {
1340  if ( !info.Matches(mask, sel) ) {
1341  continue;
1342  }
1343  CLoadLockBlob blob(result, *info.GetBlob_id());
1344  if ( !blob.IsLoadedBlob() ) {
1345  return false;
1346  }
1347  }
1348  return true;
1349  }
1350 
1351  bool s_AllBlobsAreLoaded(CReaderRequestResult& result,
1352  const CLoadLockBlobIds& blobs,
1354  const SAnnotSelector* sel)
1355  {
1356  _ASSERT(blobs.IsLoaded());
1357  return s_AllBlobsAreLoaded(result, blobs.GetBlob_ids().Get(), mask, sel);
1358  }
1359 
1360  class CCommandLoadBlobs : public CReadDispatcherCommand
1361  {
1362  public:
1363  typedef CLoadLockBlobIds TIds;
1364  typedef CReadDispatcher::TContentsMask TMask;
1365  CCommandLoadBlobs(CReaderRequestResult& result,
1366  TIds ids, TMask mask, const SAnnotSelector* sel)
1368  m_Ids(ids), m_Mask(mask), m_Selector(sel)
1369  {
1370  }
1371 
1372  bool IsDone(void)
1373  {
1374  return s_AllBlobsAreLoaded(GetResult(),
1375  m_Ids, m_Mask, m_Selector);
1376  }
1377  bool Execute(CReader& reader)
1378  {
1379  return reader.LoadBlobs(GetResult(),
1380  m_Ids, m_Mask, m_Selector);
1381  }
1382  string GetErrMsg(void) const
1383  {
1384  return "LoadBlobs(CLoadInfoBlob_ids): "
1385  "data not found";
1386  }
1387  CGBRequestStatistics::EStatType GetStatistics(void) const
1388  {
1390  }
1391  string GetStatisticsDescription(void) const
1392  {
1393  return "blobs(...)";
1394  }
1395 
1396  private:
1397  TIds m_Ids;
1398  TMask m_Mask;
1399  const SAnnotSelector* m_Selector;
1400  };
1401 
1402  class CCommandLoadSeq_idBlobs : public CReadDispatcherCommand
1403  {
1404  public:
1405  typedef CSeq_id_Handle TKey;
1406  typedef CLoadLockBlobIds TIds;
1407  typedef CReadDispatcher::TContentsMask TMask;
1408  CCommandLoadSeq_idBlobs(CReaderRequestResult& result,
1409  const TKey& key, TMask mask,
1410  const SAnnotSelector* sel)
1412  m_Key(key), m_Ids(result, key, sel),
1413  m_Mask(mask), m_Selector(sel)
1414  {
1415  }
1416 
1417  bool IsDone(void)
1418  {
1419  return s_Blob_idsLoaded(m_Ids, GetResult(), m_Key) &&
1420  s_AllBlobsAreLoaded(GetResult(),
1421  m_Ids, m_Mask, m_Selector);
1422  }
1423  bool Execute(CReader& reader)
1424  {
1425  return reader.LoadBlobs(GetResult(),
1426  m_Key, m_Mask, m_Selector);
1427  }
1428  string GetErrMsg(void) const
1429  {
1430  return "LoadBlobs("+m_Key.AsString()+"): "
1431  "data not found";
1432  }
1433  CGBRequestStatistics::EStatType GetStatistics(void) const
1434  {
1436  }
1437  string GetStatisticsDescription(void) const
1438  {
1439  return "blobs("+m_Key.AsString()+")";
1440  }
1441 
1442  private:
1443  TKey m_Key;
1444  TIds m_Ids;
1445  TMask m_Mask;
1446  const SAnnotSelector* m_Selector;
1447  };
1448 
1449  class CCommandLoadBlobList : public CReadDispatcherCommand
1450  {
1451  public:
1452  typedef CReader::TBlobIds TIds;
1453  CCommandLoadBlobList(CReaderRequestResult& result,
1454  const TIds& ids)
1456  m_Ids(ids)
1457  {
1458  }
1459 
1460  bool IsDone(void)
1461  {
1462  return s_AllBlobsAreLoaded(GetResult(), m_Ids);
1463  }
1464  bool Execute(CReader& reader)
1465  {
1466  return reader.LoadBlobs(GetResult(), m_Ids);
1467  }
1468  string GetErrMsg(void) const
1469  {
1470  return "LoadBlobs(CLoadInfoBlob_ids): "
1471  "data not found";
1472  }
1473  CGBRequestStatistics::EStatType GetStatistics(void) const
1474  {
1476  }
1477  string GetStatisticsDescription(void) const
1478  {
1479  return "blobs(...)";
1480  }
1481 
1482  private:
1483  const TIds& m_Ids;
1484  };
1485 
1486  class CCommandLoadBlob : public CReadDispatcherCommand
1487  {
1488  public:
1489  typedef CBlob_id TKey;
1490  typedef CLoadLockBlob TLock;
1491  CCommandLoadBlob(CReaderRequestResult& result,
1492  const TKey& key,
1493  const CBlob_Info* blob_info = 0)
1495  m_Key(key),
1496  m_Lock(result, key),
1497  m_BlobInfo(blob_info)
1498  {
1499  }
1500 
1501  bool IsDone(void)
1502  {
1503  return m_Lock.IsLoadedBlob();
1504  }
1505  bool Execute(CReader& reader)
1506  {
1507  if ( m_BlobInfo ) {
1508  return reader.LoadBlob(GetResult(), *m_BlobInfo);
1509  }
1510  else {
1511  return reader.LoadBlob(GetResult(), m_Key);
1512  }
1513  }
1514  string GetErrMsg(void) const
1515  {
1516  return "LoadBlob("+m_Key.ToString()+")" +
1517  sx_ErrorSeqIds(GetResult(), {m_Key}) + ": "
1518  "data not found";
1519  }
1520  CGBRequestStatistics::EStatType GetStatistics(void) const
1521  {
1523  }
1524  string GetStatisticsDescription(void) const
1525  {
1526  return "blob("+m_Key.ToString()+")";
1527  }
1528 
1529  private:
1530  TKey m_Key;
1531  TLock m_Lock;
1532  const CBlob_Info* m_BlobInfo;
1533  };
1534 
1535  class CCommandLoadChunk : public CReadDispatcherCommand
1536  {
1537  public:
1538  typedef CBlob_id TKey;
1539  typedef CLoadLockBlob TLock;
1540  typedef int TChunkId;
1541  CCommandLoadChunk(CReaderRequestResult& result,
1542  const TKey& key,
1543  TChunkId chunk_id)
1545  m_Key(key), m_Lock(result, key, chunk_id),
1546  m_ChunkId(chunk_id)
1547  {
1548  }
1549 
1550  bool IsDone(void)
1551  {
1552  return m_Lock.IsLoadedChunk();
1553  }
1554  bool Execute(CReader& reader)
1555  {
1556  return reader.LoadChunk(GetResult(), m_Key, m_ChunkId);
1557  }
1558  string GetErrMsg(void) const
1559  {
1560  return "LoadChunk("+m_Key.ToString()+", "+
1561  NStr::IntToString(m_ChunkId)+")" +
1562  sx_ErrorSeqIds(GetResult(), {m_Key}) + ": "
1563  "data not found";
1564  }
1565  CGBRequestStatistics::EStatType GetStatistics(void) const
1566  {
1568  }
1569  string GetStatisticsDescription(void) const
1570  {
1571  return "chunk("+m_Key.ToString()+"."+
1572  NStr::IntToString(m_ChunkId)+")";
1573  }
1574 
1575  private:
1576  TKey m_Key;
1577  TLock m_Lock;
1578  TChunkId m_ChunkId;
1579  };
1580 
1581  class CCommandLoadChunks : public CReadDispatcherCommand
1582  {
1583  public:
1584  typedef CBlob_id TKey;
1585  typedef CLoadLockBlob TLock;
1586  typedef int TChunkId;
1587  typedef vector<TChunkId> TChunkIds;
1588  CCommandLoadChunks(CReaderRequestResult& result,
1589  const TKey& key,
1590  const TChunkIds chunk_ids)
1592  m_Key(key), m_Lock(result, key),
1593  m_ChunkIds(chunk_ids)
1594  {
1595  }
1596 
1597  bool IsDone(void)
1598  {
1599  ITERATE ( TChunkIds, it, m_ChunkIds ) {
1600  if ( !m_Lock.IsLoadedChunk(*it) ) {
1601  return false;
1602  }
1603  }
1604  return true;
1605  }
1606  bool Execute(CReader& reader)
1607  {
1608  return reader.LoadChunks(GetResult(), m_Key, m_ChunkIds);
1609  }
1610  string GetErrMsg(void) const
1611  {
1613  str << "LoadChunks(" << m_Key.ToString() << "; chunks: {";
1614  int cnt = 0;
1615  ITERATE ( TChunkIds, it, m_ChunkIds ) {
1616  if ( !m_Lock.IsLoadedChunk(*it) ) {
1617  if ( cnt++ ) str << ',';
1618  str << ' ' << *it;
1619  }
1620  }
1621  str << " })" + sx_ErrorSeqIds(GetResult(), {m_Key}) + ": data not found";
1622  return CNcbiOstrstreamToString(str);
1623  }
1624  CGBRequestStatistics::EStatType GetStatistics(void) const
1625  {
1627  }
1628  string GetStatisticsDescription(void) const
1629  {
1631  int cnt = 0;
1632  ITERATE ( TChunkIds, it, m_ChunkIds ) {
1633  int id = *it;
1634  if ( id >= 0 && id < kMax_Int ) {
1635  if ( !cnt ) {
1636  str << "chunk(" << m_Key.ToString() << '.';
1637  cnt = 1;
1638  }
1639  else {
1640  str << ',';
1641  }
1642  str << id;
1643  }
1644  }
1645  if ( !cnt ) {
1646  str << "blob(" << m_Key.ToString();
1647  }
1648  str << ')';
1649  return CNcbiOstrstreamToString(str);
1650  }
1651 
1652  private:
1653  TKey m_Key;
1654  TLock m_Lock;
1655  TChunkIds m_ChunkIds;
1656  };
1657 
1658  class CCommandLoadBlobChunks : public CReadDispatcherCommand
1659  {
1660  public:
1661  typedef int TChunkId;
1662  typedef vector<TChunkId> TChunkIds;
1663  typedef vector<pair<CBlob_id, TChunkIds>> TKey;
1664  typedef vector<CLoadLockBlob> TLock;
1665  CCommandLoadBlobChunks(CReaderRequestResult& result,
1666  const TKey& key)
1668  m_Key(key)
1669  {
1670  for ( auto& blob : key ) {
1671  m_Lock.push_back(CLoadLockBlob(result, blob.first));
1672  }
1673  }
1674 
1675  bool IsDone(void)
1676  {
1677  for ( size_t i = 0; i < m_Key.size(); ++i ) {
1678  for ( auto chunk : m_Key[i].second ) {
1679  if ( !m_Lock[i].IsLoadedChunk(chunk) ) {
1680  return false;
1681  }
1682  }
1683  }
1684  return true;
1685  }
1686  bool Execute(CReader& reader)
1687  {
1688  return reader.LoadChunks(GetResult(), m_Key);
1689  }
1690  string GetErrMsg(void) const
1691  {
1693  str << "LoadChunks(";
1694  int blob_cnt = 0;
1695  for ( size_t i = 0; i < m_Key.size(); ++i ) {
1696  int chunk_cnt = 0;
1697  for ( auto& chunk : m_Key[i].second ) {
1698  if ( !m_Lock[i].IsLoadedChunk(chunk) ) {
1699  if ( chunk_cnt++ ) {
1700  str << ',';
1701  }
1702  else {
1703  if ( blob_cnt++ ) {
1704  str << ", ";
1705  }
1706  str << "("<<m_Key[i].first.ToString() << "; chunks: {";
1707  }
1708  str << ' ' << chunk;
1709  }
1710  }
1711  if ( chunk_cnt ) {
1712  str << "})";
1713  }
1714  }
1715  str << sx_ErrorSeqIds(GetResult(), m_Key) + ": data not found";
1716  return CNcbiOstrstreamToString(str);
1717  }
1718  CGBRequestStatistics::EStatType GetStatistics(void) const
1719  {
1721  }
1722  string GetStatisticsDescription(void) const
1723  {
1725  int blob_cnt = 0;
1726  for ( auto& blob : m_Key ) {
1727  if ( blob_cnt++ ) {
1728  str << ',';
1729  }
1730  int cnt = 0;
1731  for ( auto id : blob.second ) {
1732  if ( id >= 0 && id < kMax_Int ) {
1733  if ( !cnt ) {
1734  str << "chunk(" << blob.first.ToString() << '.';
1735  cnt = 1;
1736  }
1737  else {
1738  str << ',';
1739  }
1740  str << id;
1741  }
1742  }
1743  if ( !cnt ) {
1744  str << "blob(" << blob.first.ToString();
1745  }
1746  str << ')';
1747  }
1748  return CNcbiOstrstreamToString(str);
1749  }
1750 
1751  private:
1752  TKey m_Key;
1753  TLock m_Lock;
1754  };
1755 
1756  class CCommandLoadBlobSet : public CReadDispatcherCommand
1757  {
1758  public:
1759  typedef CReadDispatcher::TIds TIds;
1760  CCommandLoadBlobSet(CReaderRequestResult& result,
1761  const TIds& seq_ids)
1763  m_Ids(seq_ids)
1764  {
1765  }
1766 
1767  bool IsDone(void)
1768  {
1769  CReaderRequestResult& result = GetResult();
1770  ITERATE(TIds, id, m_Ids) {
1771  CLoadLockBlobIds blob_ids(result, *id, 0);
1772  if ( !blob_ids ) {
1773  return false;
1774  }
1775  if ( !s_Blob_idsLoaded(blob_ids, result, *id) ) {
1776  return false;
1777  }
1778  CFixedBlob_ids ids = blob_ids.GetBlob_ids();
1779  ITERATE ( CFixedBlob_ids, it, ids ) {
1780  if ( !it->Matches(fBlobHasCore, 0) ) {
1781  continue;
1782  }
1783  CLoadLockBlob blob(result, *it->GetBlob_id());
1784  if ( !blob.IsLoadedBlob() ) {
1785  return false;
1786  }
1787  }
1788  }
1789  return true;
1790  }
1791  bool Execute(CReader& reader)
1792  {
1793  return reader.LoadBlobSet(GetResult(), m_Ids);
1794  }
1795  string GetErrMsg(void) const
1796  {
1797  return "LoadBlobSet(" +
1798  NStr::SizetToString(m_Ids.size()) + " ids): "
1799  "data not found";
1800  }
1801  CGBRequestStatistics::EStatType GetStatistics(void) const
1802  {
1804  }
1805  string GetStatisticsDescription(void) const
1806  {
1807  return "blobs(" +
1808  NStr::SizetToString(m_Ids.size()) + " ids)";
1809  }
1810 
1811  private:
1812  TIds m_Ids;
1813  };
1814 }
1815 
1817 
1819 {
1821  : m_Command(command),
1822  m_SavedLevel(command.GetResult().GetLevel())
1823  {
1824  }
1825 
1827  {
1829  }
1830 
1833 };
1834 
1836 
1837 
1839  const CReader* asking_reader)
1840 {
1841  CheckReaders();
1842 
1843  if ( command.IsDone() ) {
1844  return;
1845  }
1846 
1847  SSaveResultLevel save_level(command);
1849  if ( asking_reader ) {
1850  // skip all readers before the asking one
1851  if ( rdr->second == asking_reader ) {
1852  // found the asking reader, start processing next readers
1853  asking_reader = 0;
1854  }
1855  continue;
1856  }
1857  CReader& reader = *rdr->second;
1858  command.GetResult().SetLevel(rdr->first);
1859  int retry_count = 0;
1860  int max_retry_count = reader.GetRetryCount();
1861  do {
1862  ++retry_count;
1863  try {
1865  if ( !command.Execute(reader) ) {
1866  retry_count = kMax_Int;
1867  }
1868  LogStat(command, r);
1869  }
1870  catch ( CLoaderException& exc ) {
1871  if ( exc.GetErrCode() == exc.eRepeatAgain ) {
1872  // no actual error, just restart
1873  --retry_count;
1874  LOG_POST_X(10, Info<<
1875  "CReadDispatcher: connection reopened "
1876  "due to inactivity timeout");
1877  }
1878  else if ( exc.GetErrCode() == exc.eNoConnection ) {
1879  LOG_POST_X(1, Warning<<
1880  "CReadDispatcher: Exception: "<<exc);
1881  retry_count = kMax_Int;
1882  }
1883  else {
1884  if ( retry_count >= max_retry_count &&
1885  !command.MayBeSkipped() &&
1886  !reader.MayBeSkippedOnErrors() ) {
1887  throw;
1888  }
1889  LOG_POST_X(2, Warning<<
1890  "CReadDispatcher: Exception: "<<exc);
1891  }
1892  }
1893  catch ( CException& exc ) {
1894  // error in the command
1895  if ( retry_count >= max_retry_count &&
1896  !command.MayBeSkipped() &&
1897  !reader.MayBeSkippedOnErrors() ) {
1898  throw;
1899  }
1900  LOG_POST_X(3, Warning <<
1901  "CReadDispatcher: Exception: "<<exc);
1902  }
1903  catch ( exception& exc ) {
1904  // error in the command
1905  if ( retry_count >= max_retry_count &&
1906  !command.MayBeSkipped() &&
1907  !reader.MayBeSkippedOnErrors() ) {
1908  throw;
1909  }
1910  LOG_POST_X(4, Warning <<
1911  "CReadDispatcher: Exception: "<<exc.what());
1912  }
1913  if ( command.IsDone() ) {
1914  return;
1915  }
1916  } while ( retry_count < max_retry_count );
1917  if ( !command.MayBeSkipped() &&
1918  !reader.MayBeSkippedOnErrors() &&
1920  NCBI_THROW(CLoaderException, eLoaderFailed, command.GetErrMsg());
1921  }
1922  }
1923 
1924  if ( !command.MayBeSkipped() &&
1926  NCBI_THROW(CLoaderException, eLoaderFailed, command.GetErrMsg());
1927  }
1928 }
1929 
1930 
1932  const CSeq_id_Handle& seq_id)
1933 {
1934  CCommandLoadSeq_idSeq_ids command(result, seq_id);
1935  Process(command);
1936 }
1937 
1938 
1940  const CSeq_id_Handle& seq_id)
1941 {
1942  CCommandLoadSeq_idGi command(result, seq_id);
1943  Process(command);
1944 }
1945 
1946 
1948  const CSeq_id_Handle& seq_id)
1949 {
1950  CCommandLoadSeq_idAccVer command(result, seq_id);
1951  Process(command);
1952 }
1953 
1954 
1956  const CSeq_id_Handle& seq_id)
1957 {
1958  CCommandLoadSeq_idLabel command(result, seq_id);
1959  Process(command);
1960 }
1961 
1962 
1964  const CSeq_id_Handle& seq_id)
1965 {
1966  CCommandLoadSeq_idTaxId command(result, seq_id);
1967  Process(command);
1968 }
1969 
1970 
1972  const CSeq_id_Handle& seq_id)
1973 {
1974  CCommandLoadSequenceHash command(result, seq_id);
1975  Process(command);
1976 }
1977 
1978 
1980  const CSeq_id_Handle& seq_id)
1981 {
1982  CCommandLoadSequenceLength command(result, seq_id);
1983  Process(command);
1984 }
1985 
1986 
1988  const CSeq_id_Handle& seq_id)
1989 {
1990  CCommandLoadSequenceType command(result, seq_id);
1991  Process(command);
1992 }
1993 
1994 
1996  const TIds& ids, TLoaded& loaded, TBulkIds& ret)
1997 {
1998  CCommandLoadBulkIds command(result, ids, loaded, ret);
1999  Process(command);
2000 }
2001 
2002 
2004  const TIds& ids, TLoaded& loaded, TIds& ret)
2005 {
2006  CCommandLoadAccVers command(result, ids, loaded, ret);
2007  Process(command);
2008 }
2009 
2010 
2012  const TIds& ids, TLoaded& loaded, TGis& ret)
2013 {
2014  CCommandLoadGis command(result, ids, loaded, ret);
2015  Process(command);
2016 }
2017 
2018 
2020  const TIds& ids, TLoaded& loaded, TLabels& ret)
2021 {
2022  CCommandLoadLabels command(result, ids, loaded, ret);
2023  Process(command);
2024 }
2025 
2026 
2028  const TIds& ids, TLoaded& loaded, TTaxIds& ret)
2029 {
2030  CCommandLoadTaxIds command(result, ids, loaded, ret);
2031  Process(command);
2032 }
2033 
2034 
2036  const TIds& ids, TLoaded& loaded,
2037  THashes& ret, TKnown& known)
2038 {
2039  CCommandLoadHashes command(result, ids, loaded, ret, known);
2040  Process(command);
2041 }
2042 
2043 
2045  const TIds& ids, TLoaded& loaded, TLengths& ret)
2046 {
2047  CCommandLoadLengths command(result, ids, loaded, ret);
2048  Process(command);
2049 }
2050 
2051 
2053  const TIds& ids, TLoaded& loaded, TTypes& ret)
2054 {
2055  CCommandLoadTypes command(result, ids, loaded, ret);
2056  Process(command);
2057 }
2058 
2059 
2061  const TIds& ids, TLoaded& loaded, TStates& ret)
2062 {
2063  CCommandLoadStates command(result, ids, loaded, ret);
2064  Process(command);
2065 }
2066 
2067 
2069  const CSeq_id_Handle& seq_id,
2070  const SAnnotSelector* sel)
2071 {
2072  CCommandLoadSeq_idBlob_ids command(result, seq_id, sel);
2073  Process(command);
2074 }
2075 
2076 
2078  const TBlobId& blob_id)
2079 {
2080  CCommandLoadBlobState command(result, blob_id);
2081  Process(command);
2082 }
2083 
2085  const TBlobId& blob_id,
2086  const CReader* asking_reader)
2087 {
2088  CCommandLoadBlobVersion command(result, blob_id);
2089  Process(command, asking_reader);
2090 }
2091 
2093  const CSeq_id_Handle& seq_id,
2095  const SAnnotSelector* sel)
2096 {
2097  CCommandLoadSeq_idBlobs command(result, seq_id, mask, sel);
2098  Process(command);
2099 }
2100 
2101 
2103  const CLoadLockBlobIds& blobs,
2105  const SAnnotSelector* sel)
2106 {
2107  CCommandLoadBlobs command(result, blobs, mask, sel);
2108  Process(command);
2109 }
2110 
2111 
2113  const TBlobInfos& blob_infos)
2114 {
2115  CCommandLoadBlobList command(result, blob_infos);
2116  Process(command);
2117 }
2118 
2119 
2121  const CBlob_id& blob_id)
2122 {
2123  CCommandLoadBlob command(result, blob_id);
2124  Process(command);
2125 }
2126 
2127 
2129  const CBlob_Info& blob_info)
2130 {
2131  CCommandLoadBlob command(result, *blob_info.GetBlob_id(), &blob_info);
2132  Process(command);
2133 }
2134 
2135 
2137  const TBlobId& blob_id, TChunkId chunk_id)
2138 {
2139  CCommandLoadChunk command(result, blob_id, chunk_id);
2140  Process(command);
2141 }
2142 
2143 
2145  const TBlobId& blob_id,
2146  const TChunkIds& chunk_ids)
2147 {
2148  CCommandLoadChunks command(result, blob_id, chunk_ids);
2149  Process(command);
2150 }
2151 
2152 
2154  const TBlobChunkIds& chunk_ids)
2155 {
2156  CCommandLoadBlobChunks command(result, chunk_ids);
2157  Process(command);
2158 }
2159 
2160 
2162  const TIds& seq_ids)
2163 {
2164  CCommandLoadBlobSet command(result, seq_ids);
2165  Process(command);
2166 }
2167 
2168 
2171  const TIds& ids, TLoaded& loaded,
2172  TStates& ret)
2173 {
2174  if ( loaded[i] || CannotProcess(ids[i]) ) {
2175  return true;
2176  }
2177  CLoadLockBlobIds lock(result, ids[i]);
2178  if ( lock.IsLoaded() ) {
2179  CFixedBlob_ids blob_ids = lock.GetBlob_ids();
2180  if ( !blob_ids.IsFound() ) {
2181  ret[i] = lock.GetState();
2182  return true;
2183  }
2184  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
2185  if ( it->Matches(fBlobHasCore, 0) ) {
2188  CLoadLockBlobState state_lock(result, *it->GetBlob_id());
2189  if ( state_lock.IsLoadedBlobState() ) {
2190  state = state_lock.GetBlobState();
2191  }
2192  }
2194  ret[i] = state;
2195  loaded[i] = true;
2196  return true;
2197  }
2198  return false;
2199  }
2200  }
2201  }
2202  else {
2203  CLoadLockSeqIds ids_lock(result, ids[i], eAlreadyLoaded);
2204  if ( ids_lock && !ids_lock.GetData().IsFound() ) {
2205  ret[i] = ids_lock.GetState();
2206  return true;
2207  }
2208  }
2209  return false;
2210 }
2211 
2212 
2214  CReaderRequestResultRecursion& recursion)
2215 {
2216  CReaderRequestResult& result = command.GetResult();
2217  double time = recursion.GetCurrentRequestTime();
2218  size_t count = command.GetStatisticsCount();
2219  CGBRequestStatistics& stat = sx_Statistics[command.GetStatistics()];
2220  stat.AddTime(time, count);
2221  if ( CollectStatistics() >= 2 ) {
2222  string descr = command.GetStatisticsDescription();
2223  const CSeq_id_Handle& idh = result.GetRequestedId();
2224  if ( idh ) {
2225  descr = descr + " for " + idh.AsString();
2226  }
2227  LOG_POST_X(8, setw(recursion.GetRecursionLevel()) << "" <<
2228  "Dispatcher: read " <<
2229  descr << " in " <<
2230  setiosflags(ios::fixed) <<
2231  setprecision(3) << (time*1000) << " ms");
2232  }
2233 }
2234 
2235 
2237  CReaderRequestResultRecursion& recursion,
2238  double size)
2239 {
2240  CReaderRequestResult& result = command.GetResult();
2241  double time = recursion.GetCurrentRequestTime();
2242  CGBRequestStatistics& stat = sx_Statistics[command.GetStatistics()];
2243  stat.AddTimeSize(time, size);
2244  if ( CollectStatistics() >= 2 ) {
2245  string descr = command.GetStatisticsDescription();
2246  const CSeq_id_Handle& idh = result.GetRequestedId();
2247  if ( idh ) {
2248  descr = descr + " for " + idh.AsString();
2249  }
2250  LOG_POST_X(9, setw(recursion.GetRecursionLevel()) << "" <<
2251  descr << " in " <<
2252  setiosflags(ios::fixed) <<
2253  setprecision(3) <<
2254  (time*1000) << " ms (" <<
2255  setprecision(2) <<
2256  (size/1024.0) << " kB " <<
2257  setprecision(2) <<
2258  (size/time/1024) << " kB/s)");
2259  }
2260 }
2261 
2262 
#define static
ncbi::TMaskedQueryRegions mask
const CConstRef< CBlob_id > & GetBlob_id(void) const
bool IsFound(void) const
static const CGBRequestStatistics & GetStatistics(EStatType type)
Definition: dispatcher.cpp:104
double GetSize(void) const
Definition: statistics.hpp:88
void AddTimeSize(double time, double size)
Definition: statistics.hpp:102
const char * GetEntity(void) const
Definition: statistics.hpp:79
static void PrintStatistics(void)
Definition: dispatcher.cpp:143
void PrintStat(void) const
Definition: dispatcher.cpp:114
CGBRequestStatistics(const char *action, const char *entity)
Definition: dispatcher.cpp:97
const char * GetAction(void) const
Definition: statistics.hpp:76
double GetTime(void) const
Definition: statistics.hpp:85
size_t GetCount(void) const
Definition: statistics.hpp:82
void AddTime(double time, size_t count=1)
Definition: statistics.hpp:97
bool SetNoBlob_ids(const CFixedBlob_ids::TState &state, TExpirationTime expiration_time)
TData GetBlob_ids(void) const
TData::TState GetState(void) const
TData GetBlobState(void) const
bool IsLoadedBlobState(void) const
static bool IsFound(const TData &data)
TData::TState GetState(void) const
Data loader exceptions, used by GenBank loader.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
static void RegisterAllProcessors(CReadDispatcher &dispatcher)
Definition: processors.cpp:299
virtual EType GetType(void) const =0
CReadDispatcherCommand(CReaderRequestResult &result)
Definition: dispatcher.cpp:269
virtual bool MayBeSkipped(void) const
Definition: dispatcher.cpp:280
virtual size_t GetStatisticsCount(void) const
Definition: dispatcher.cpp:286
CReaderRequestResult & GetResult(void) const
Definition: dispatcher.hpp:212
virtual ~CReadDispatcherCommand(void)
Definition: dispatcher.cpp:275
void LoadStates(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TStates &ret)
void ResetCaches(void)
Definition: dispatcher.cpp:250
void CheckReaders(void) const
Definition: dispatcher.cpp:231
void LoadBlobSet(CReaderRequestResult &result, const TIds &seq_ids)
void LoadChunks(CReaderRequestResult &result, const TBlobId &blob_id, const TChunkIds &chunk_ids)
TProcessors m_Processors
Definition: dispatcher.hpp:193
void LoadSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
CReader::TChunkId TChunkId
Definition: dispatcher.hpp:66
void LoadGis(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TGis &ret)
CReader::TContentsMask TContentsMask
Definition: dispatcher.hpp:62
static void LogStat(CReadDispatcherCommand &command, CReaderRequestResultRecursion &recursion)
vector< string > TLabels
Definition: dispatcher.hpp:111
void LoadBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id, const CReader *asking_reader=0)
void InsertReader(TLevel level, CRef< CReader > reader)
Definition: dispatcher.cpp:173
void LoadBulkIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TBulkIds &ret)
const CProcessor & GetProcessor(CProcessor::EType type) const
Definition: dispatcher.cpp:219
CReader::TChunkIds TChunkIds
Definition: dispatcher.hpp:67
void LoadLabels(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLabels &ret)
void LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
~CReadDispatcher(void)
Definition: dispatcher.cpp:165
vector< int > THashes
Definition: dispatcher.hpp:113
void InsertWriter(TLevel level, CRef< CWriter > writer)
Definition: dispatcher.cpp:184
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 LoadAccVers(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TIds &ret)
void LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void LoadLengths(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLengths &ret)
vector< TBlobState > TStates
Definition: dispatcher.hpp:116
vector< pair< CBlob_id, TChunkIds > > TBlobChunkIds
Definition: dispatcher.hpp:119
void LoadTaxIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTaxIds &ret)
void LoadHashes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, THashes &ret, TKnown &known)
vector< bool > TLoaded
Definition: dispatcher.hpp:107
bool HasReaderWithHUPIncluded() const
Definition: dispatcher.cpp:239
void LoadBlobState(CReaderRequestResult &result, const TBlobId &blob_id)
void LoadTypes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTypes &ret)
vector< bool > TKnown
Definition: dispatcher.hpp:108
void LoadSeq_idTaxId(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
vector< CBlob_Info > TBlobInfos
Definition: dispatcher.hpp:118
void LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
vector< CSeq_id_Handle > TIds
Definition: dispatcher.hpp:69
TWriters m_Writers
Definition: dispatcher.hpp:192
vector< CSeq_inst::EMol > TTypes
Definition: dispatcher.hpp:115
void InsertProcessor(CRef< CProcessor > processor)
Definition: dispatcher.cpp:194
void LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
vector< TIds > TBulkIds
Definition: dispatcher.hpp:109
CWriter * GetWriter(const CReaderRequestResult &result, CWriter::EType type) const
Definition: dispatcher.cpp:204
TReaders m_Readers
Definition: dispatcher.hpp:191
void LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
void Process(CReadDispatcherCommand &command, const CReader *asking_reader=0)
static int CollectStatistics(void)
Definition: dispatcher.cpp:151
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)
vector< TTaxId > TTaxIds
Definition: dispatcher.hpp:112
void LoadChunk(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
vector< TGi > TGis
Definition: dispatcher.hpp:110
vector< TSeqPos > TLengths
Definition: dispatcher.hpp:114
void LoadBlob(CReaderRequestResult &result, const CBlob_id &blob_id)
static bool CannotProcess(const CSeq_id_Handle &sih)
Definition: dispatcher.cpp:261
double GetCurrentRequestTime(void) const
void SetLevel(TLevel level)
virtual bool LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)=0
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
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
virtual bool LoadLabels(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLabels &ret)
Definition: reader.cpp:733
virtual bool LoadTypes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTypes &ret)
Definition: reader.cpp:822
virtual bool MayBeSkippedOnErrors(void) const
Definition: reader.cpp:484
vector< CBlob_Info > TBlobIds
Definition: reader.hpp:97
virtual bool LoadTaxIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTaxIds &ret)
Definition: reader.cpp:754
virtual bool LoadSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:628
virtual bool LoadBlob(CReaderRequestResult &result, const CBlob_id &blob_id)=0
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
virtual bool LoadGis(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TGis &ret)
Definition: reader.cpp:709
virtual bool LoadAccVers(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TIds &ret)
Definition: reader.cpp:685
virtual bool LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:490
virtual bool LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:509
virtual bool LoadBlobState(CReaderRequestResult &result, const TBlobId &blob_id)=0
virtual bool LoadChunk(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
Definition: reader.cpp:985
virtual bool LoadLengths(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLengths &ret)
Definition: reader.cpp:801
virtual bool LoadBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id)=0
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
virtual bool LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
Definition: reader.cpp:903
virtual bool LoadSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:528
CSafeStatic<>::
virtual void GetBioseqsIds(TSeqIds &ids) const
Definition: tse_info.cpp:691
vector< CSeq_id_Handle > TSeqIds
Definition: tse_info.hpp:351
bool IsLoaded(void) const
const_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
static bool s_AllowIncompleteCommands(void)
Definition: dispatcher.cpp:57
BEGIN_LOCAL_NAMESPACE
static CGBRequestStatistics sx_Statistics[CGBRequestStatistics::eStats_Count]
Definition: dispatcher.cpp:69
NCBI_PARAM_DEF_EX(bool, GENBANK, ALLOW_INCOMPLETE_COMMANDS, false, eParam_NoThread, GENBANK_ALLOW_INCOMPLETE_COMMANDS)
END_LOCAL_NAMESPACE
NCBI_PARAM_DECL(bool, GENBANK, ALLOW_INCOMPLETE_COMMANDS)
NCBI_DEFINE_ERR_SUBCODE_X(10)
#define false
Definition: bool.h:36
static int type
Definition: getdata.c:31
static const char * str(char *buf, int n)
Definition: stats.c:84
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define LOG_POST_X(err_subcode, message)
Definition: ncbidiag.hpp:553
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
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
Definition: ncbiexpt.hpp:719
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
CConstRef< CSeq_id > GetSeqId(void) const
string AsString(void) const
CSeq_id::E_Choice Which(void) const
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
Definition: ncbi_param.hpp:149
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
#define kMax_Int
Definition: ncbi_limits.h:184
#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
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2742
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5078
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5347
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
@ e_General
for other databases
Definition: Seq_id_.hpp:105
@ e_Local
local use
Definition: Seq_id_.hpp:95
Definition of all error codes used in objtools libraries.
int i
static MDB_envinfo info
Definition: mdb_load.c:37
string Execute(const string &cmmd, const vector< string > &args, const string &data=kEmptyStr)
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
string s_Value(TValue value)
const char * command
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static unsigned cnt[256]
int TChunkId
Definition: blob_id.hpp:145
@ fBlobHasCore
Definition: blob_id.hpp:155
@ fBlobHasAll
Definition: blob_id.hpp:200
#define count
@ eAlreadyLoaded
SAnnotSelector –.
CReadDispatcherCommand & m_Command
SSaveResultLevel(CReadDispatcherCommand &command)
CReadDispatcher::TLevel m_SavedLevel
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
Modified on Fri Sep 20 14:57:36 2024 by modify_doxy.py rev. 669887