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

Go to the SVN repository for this file.

1 /* $Id: reader_id2_base.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  *
25  * Author: Eugene Vasilchenko
26  *
27  * File Description: Data reader from ID2
28  *
29  */
30 
31 #include <ncbi_pch.hpp>
32 #include <corelib/ncbi_param.hpp>
33 #include <corelib/request_ctx.hpp>
34 
38 
41 #include <objmgr/impl/tse_info.hpp>
44 
46 #include <objtools/error_codes.hpp>
47 
48 #include <corelib/ncbimtx.hpp>
49 
51 
56 #include <objects/id2/id2__.hpp>
60 
61 #include <serial/iterator.hpp>
62 #include <serial/serial.hpp>
63 #include <serial/objistr.hpp>
64 
67 
68 #include <iomanip>
69 
70 
71 #define NCBI_USE_ERRCODE_X Objtools_Rd_Id2Base
72 
74 
76 
77 
78 NCBI_PARAM_ENUM_ARRAY(objects::CSeq_id::ESNPScaleLimit, GENBANK, ID2SNP_SCALE_LIMIT) {
79  {"", objects::CSeq_id::eSNPScaleLimit_Default},
80  {"Unit", objects::CSeq_id::eSNPScaleLimit_Unit},
81  {"Contig", objects::CSeq_id::eSNPScaleLimit_Contig},
82  {"Supercontig", objects::CSeq_id::eSNPScaleLimit_Supercontig},
83  {"Chromosome", objects::CSeq_id::eSNPScaleLimit_Chromosome},
84 };
85 NCBI_PARAM_ENUM_DECL(objects::CSeq_id::ESNPScaleLimit, GENBANK, ID2SNP_SCALE_LIMIT);
86 NCBI_PARAM_ENUM_DEF_EX(objects::CSeq_id::ESNPScaleLimit, GENBANK, ID2SNP_SCALE_LIMIT,
87  objects::CSeq_id::eSNPScaleLimit_Default,
88  eParam_NoThread, GENBANK_ID2SNP_SCALE_LIMIT);
89 typedef NCBI_PARAM_TYPE(GENBANK, ID2SNP_SCALE_LIMIT) TID2SNP_Scale_Limit;
90 
91 
93 
94 NCBI_PARAM_DECL(int, GENBANK, ID2_DEBUG);
95 NCBI_PARAM_DECL(int, GENBANK, ID2_MAX_CHUNKS_REQUEST_SIZE);
96 NCBI_PARAM_DECL(int, GENBANK, ID2_MAX_IDS_REQUEST_SIZE);
97 NCBI_PARAM_DECL(string, GENBANK, ID2_PROCESSOR);
98 NCBI_PARAM_DECL(bool, GENBANK, VDB_WGS);
99 NCBI_PARAM_DECL(bool, GENBANK, VDB_SNP);
100 NCBI_PARAM_DECL(bool, GENBANK, VDB_CDD);
101 
102 #ifdef _DEBUG
103 # define DEFAULT_DEBUG_LEVEL CId2ReaderBase::eTraceError
104 #else
105 # define DEFAULT_DEBUG_LEVEL 0
106 #endif
107 
108 NCBI_PARAM_DEF_EX(int, GENBANK, ID2_DEBUG, DEFAULT_DEBUG_LEVEL,
109  eParam_NoThread, GENBANK_ID2_DEBUG);
110 NCBI_PARAM_DEF_EX(int, GENBANK, ID2_MAX_CHUNKS_REQUEST_SIZE, 100,
111  eParam_NoThread, GENBANK_ID2_MAX_CHUNKS_REQUEST_SIZE);
112 NCBI_PARAM_DEF_EX(int, GENBANK, ID2_MAX_IDS_REQUEST_SIZE, 100,
113  eParam_NoThread, GENBANK_ID2_MAX_IDS_REQUEST_SIZE);
114 NCBI_PARAM_DEF_EX(string, GENBANK, ID2_PROCESSOR, "",
115  eParam_NoThread, GENBANK_ID2_PROCESSOR);
116 NCBI_PARAM_DEF_EX(bool, GENBANK, VDB_WGS, true,
117  eParam_NoThread, GENBANK_VDB_WGS);
118 NCBI_PARAM_DEF_EX(bool, GENBANK, VDB_SNP, true,
119  eParam_NoThread, GENBANK_VDB_SNP);
120 NCBI_PARAM_DEF_EX(bool, GENBANK, VDB_CDD, true,
121  eParam_NoThread, GENBANK_VDB_CDD);
122 
123 typedef NCBI_PARAM_TYPE(GENBANK, VDB_WGS) TGenbankVdbWgsParam;
124 typedef NCBI_PARAM_TYPE(GENBANK, VDB_SNP) TGenbankVdbSnpParam;
125 typedef NCBI_PARAM_TYPE(GENBANK, VDB_CDD) TGenbankVdbCddParam;
126 
128 {
129  static CSafeStatic<NCBI_PARAM_TYPE(GENBANK, ID2_DEBUG)> s_Value;
130  return s_Value->Get();
131 }
132 
133 
135 {
136  return TGenbankVdbSnpParam::GetDefault();
137 }
138 
139 
141 {
142  return TGenbankVdbSnpParam::SetDefault(enabled);
143 }
144 
145 
147 {
148  return TGenbankVdbWgsParam::GetDefault();
149 }
150 
151 
153 {
154  return TGenbankVdbWgsParam::SetDefault(enabled);
155 }
156 
157 
159 {
160  return TGenbankVdbCddParam::GetDefault();
161 }
162 
163 
165 {
166  return TGenbankVdbCddParam::SetDefault(enabled);
167 }
168 
169 
171 {
172  return TID2SNP_Scale_Limit::GetDefault();
173 }
174 
175 
177 {
178  TID2SNP_Scale_Limit::SetDefault(value);
179 }
180 
181 
182 static const char kSpecialId_label[] = "LABEL";
183 static const char kSpecialId_taxid[] = "TAXID";
184 static const char kSpecialId_hash[] = "HASH";
185 static const char kSpecialId_length[] = "Seq-inst.length";
186 static const char kSpecialId_type[] = "Seq-inst.mol";
187 
188 
189 // Number of chunks allowed in a single request
190 // 0 = unlimited request size
191 // 1 = do not use packets or get-chunks requests
192 static size_t GetMaxChunksRequestSize(void)
193 {
194  static CSafeStatic<NCBI_PARAM_TYPE(GENBANK, ID2_MAX_CHUNKS_REQUEST_SIZE)> s_Value;
195  return (size_t)s_Value->Get();
196 }
197 
198 
199 static size_t GetMaxIdsRequestSize(void)
200 {
201  static CSafeStatic<NCBI_PARAM_TYPE(GENBANK, ID2_MAX_IDS_REQUEST_SIZE)> s_Value;
202  return (size_t)s_Value->Get();
203 }
204 
205 
206 static inline
207 bool
209 {
210  return max_request_size == 1;
211 }
212 
213 
214 static inline
215 bool
216 LimitChunksRequests(size_t max_request_size = GetMaxChunksRequestSize())
217 {
218  return max_request_size > 0;
219 }
220 
221 
223 {
225  typedef list< CRef<CID2S_Seq_annot_Info> > TAnnotInfo;
227 };
228 
229 
231 {
232  typedef pair<int, CReader::TSeqIds> TSeq_idsInfo; // state & ids
236  typedef pair<int, TBlob_ids> TBlob_idsInfo; // state & blob-info
240 
245 };
246 
247 
249  : m_RequestSerialNumber(1),
250  m_AvoidRequest(0)
251 {
252  vector<string> proc_list;
253  string proc_param = NCBI_PARAM_TYPE(GENBANK, ID2_PROCESSOR)::GetDefault();
254  NStr::Split(proc_param, ";", proc_list);
255  ITERATE ( vector<string>, it, proc_list ) {
256  const string& proc_name = *it;
258  try {
260  CreateInstance(proc_name);
261  }
262  catch ( CException& exc ) {
263  ERR_POST_X(15, "CId2ReaderBase: "
264  "cannot load ID2 processor "<<proc_name<<": "<<exc);
265  }
266  if ( info.processor ) {
267  info.context = info.processor->CreateContext();
268  // send init request
269  CID2_Request req;
270  req.SetRequest().SetInit();
271  x_SetContextData(req);
272  CID2_Request_Packet packet;
273  packet.Set().push_back(Ref(&req));
274  CID2Processor::TReplies replies;
275  info.processor->ProcessPacket(info.context, packet, replies);
276  m_Processors.push_back(info);
277  }
278  }
279 }
280 
281 
283 {
284 }
285 
286 
288 {
289  m_Processors.clear();
290 }
291 
292 
293 #define MConnFormat MSerial_AsnBinary
294 
295 
297  const CSeq_id& seq_id)
298 {
299  //get_blob_id.SetSeq_id().SetSeq_id().SetSeq_id(const_cast<CSeq_id&>(seq_id));
300  get_blob_id.SetSeq_id().SetSeq_id().SetSeq_id().Assign(seq_id);
301  get_blob_id.SetExternal();
303 }
304 
305 
307  TContentsMask /*mask*/)
308 {
309 }
310 
311 
313  const CSeq_id_Handle& idh,
315 {
316  if ( SeparateChunksRequests() ) {
317  // Minimize size of request rather than response
318  return;
319  }
321  result.GetLoadedBlob_ids(idh, loaded_blob_ids);
322  if ( loaded_blob_ids.empty() ) {
323  return;
324  }
325  CID2_Request_Get_Blob_Info::C_Blob_id::C_Resolve::TExclude_blobs&
326  exclude_blobs =
327  get_blob_info.SetBlob_id().SetResolve().SetExclude_blobs();
328  ITERATE(CReaderRequestResult::TLoadedBlob_ids, id, loaded_blob_ids) {
329  CRef<CID2_Blob_Id> blob_id(new CID2_Blob_Id);
330  x_SetResolve(*blob_id, *id);
331  exclude_blobs.push_back(blob_id);
332  }
333 }
334 
335 
337 {
338  CBlob_id ret;
339  ret.SetSat(blob_id.GetSat());
340  ret.SetSubSat(blob_id.GetSub_sat());
341  ret.SetSatKey(blob_id.GetSat_key());
342  //ret.SetVersion(blob_id.GetVersion());
343  return ret;
344 }
345 
346 
348 {
349  blob_id.SetSat(src.GetSat());
350  blob_id.SetSub_sat(src.GetSubSat());
351  blob_id.SetSat_key(src.GetSatKey());
352  //blob_id.SetVersion(src.GetVersion());
353 }
354 
355 
357  const CSeq_id_Handle& seq_id)
358 {
359  CLoadLockSeqIds ids(result, seq_id);
360  if ( ids.IsLoaded() ) {
361  return true;
362  }
363 
364  CID2_Request req;
366  req.SetRequest().SetGet_seq_id();
367  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
368  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
369  x_ProcessRequest(result, req, 0);
370  return true;
371 }
372 
373 
375  const CSeq_id_Handle& seq_id)
376 {
377  CLoadLockGi lock(result, seq_id);
378  if ( lock.IsLoadedGi() ) {
379  return true;
380  }
381  CID2_Request req;
383  req.SetRequest().SetGet_seq_id();
384  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
385  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
386  x_ProcessRequest(result, req, 0);
387 
388  if ( !lock.IsLoadedGi() ) {
389  return CReader::LoadSeq_idGi(result, seq_id);
390  }
391 
392  return true;
393 }
394 
395 
397  const CSeq_id_Handle& seq_id)
398 {
399  CLoadLockAcc lock(result, seq_id);
400  if ( lock.IsLoadedAccVer() ) {
401  return true;
402  }
403  CID2_Request req;
405  req.SetRequest().SetGet_seq_id();
406  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
407  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
408  x_ProcessRequest(result, req, 0);
409 
410  if ( lock.IsLoadedAccVer() ) {
411  return true;
412  }
413  // load via full Seq-ids list
414  return CReader::LoadSeq_idAccVer(result, seq_id);
415 }
416 
417 
419  const CSeq_id_Handle& seq_id)
420 {
422  return CReader::LoadSeq_idLabel(result, seq_id);
423  }
424 
425  CLoadLockLabel ids(result, seq_id);
426  if ( ids.IsLoadedLabel() ) {
427  return true;
428  }
429  CID2_Request req;
431  req.SetRequest().SetGet_seq_id();
432  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
433  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_label);
434  x_ProcessRequest(result, req, 0);
435 
436  if ( ids.IsLoadedLabel() ) {
437  return true;
438  }
440  // load via full Seq-ids list
441  return CReader::LoadSeq_idLabel(result, seq_id);
442 }
443 
444 
446  const CSeq_id_Handle& seq_id)
447 {
449  return CReader::LoadSeq_idTaxId(result, seq_id);
450  }
451 
452  CLoadLockTaxId lock(result, seq_id);
453  if ( lock.IsLoadedTaxId() ) {
454  return true;
455  }
456  CID2_Request req;
458  req.SetRequest().SetGet_seq_id();
459  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
460  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_taxid);
461  x_ProcessRequest(result, req, 0);
462 
463  if ( !lock.IsLoadedTaxId() ) {
465  return true; // repeat
466  }
467 
468  return true;
469 }
470 
471 
473  const CSeq_id_Handle& seq_id)
474 {
476  return CReader::LoadSequenceHash(result, seq_id);
477  }
478 
479  CLoadLockHash lock(result, seq_id);
480  if ( lock.IsLoadedHash() ) {
481  return true;
482  }
483  CID2_Request req;
485  req.SetRequest().SetGet_seq_id();
486  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
487  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_hash);
488  x_ProcessRequest(result, req, 0);
489 
490  if ( !lock.IsLoadedHash() ) {
492  return true; // repeat
493  }
494 
495  return true;
496 }
497 
498 
500  const CSeq_id_Handle& seq_id)
501 {
503  return CReader::LoadSequenceLength(result, seq_id);
504  }
505 
506  CLoadLockLength lock(result, seq_id);
507  if ( lock.IsLoadedLength() ) {
508  return true;
509  }
510  CID2_Request req;
512  req.SetRequest().SetGet_seq_id();
513  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
514  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all |
516  x_ProcessRequest(result, req, 0);
517 
518  if ( !lock.IsLoadedLength() ) {
520  return true; // repeat
521  }
522 
523  return true;
524 }
525 
526 
528  const CSeq_id_Handle& seq_id)
529 {
531  return CReader::LoadSequenceType(result, seq_id);
532  }
533 
534  CLoadLockType lock(result, seq_id);
535  if ( lock.IsLoadedType() ) {
536  return true;
537  }
538  CID2_Request req;
540  req.SetRequest().SetGet_seq_id();
541  get_id.SetSeq_id().SetSeq_id().Assign(*seq_id.GetSeqId());
542  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all |
544  x_ProcessRequest(result, req, 0);
545 
546  if ( !lock.IsLoadedType() ) {
548  return true; // repeat
549  }
550 
551  return true;
552 }
553 
554 
556  const TIds& ids, TLoaded& loaded, TBulkIds& ret)
557 {
558  size_t max_request_size = GetMaxIdsRequestSize();
559  if ( max_request_size <= 1 ) {
560  return CReader::LoadBulkIds(result, ids, loaded, ret);
561  }
562 
563  size_t count = ids.size();
564  CID2_Request_Packet packet;
565  size_t packet_start = 0;
566 
567  for ( size_t i = 0; i < count; ++i ) {
568  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
569  continue;
570  }
571  CLoadLockSeqIds lock(result, ids[i]);
572  if ( lock.IsLoaded() ) {
573  CFixedSeq_ids data = lock.GetSeq_ids();
574  if ( data.IsFound() ) {
575  ret[i] = data.Get();
576  loaded[i] = true;
577  }
578  continue;
579  }
580 
583  req->SetRequest().SetGet_seq_id();
584  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
585  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
586  if ( packet.Set().empty() ) {
587  packet_start = i;
588  }
589  packet.Set().push_back(req);
590  if ( packet.Set().size() == max_request_size ) {
591  x_ProcessPacket(result, packet, 0);
592  size_t count = i+1;
593  for ( size_t i = packet_start; i < count; ++i ) {
594  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
595  continue;
596  }
597  CLoadLockSeqIds lock(result, ids[i]);
598  if ( lock.IsLoaded() ) {
599  CFixedSeq_ids data = lock.GetSeq_ids();
600  if ( data.IsFound() ) {
601  ret[i] = data.Get();
602  loaded[i] = true;
603  }
604  continue;
605  }
606  }
607  packet.Set().clear();
608  }
609  }
610 
611  if ( !packet.Set().empty() ) {
612  x_ProcessPacket(result, packet, 0);
613 
614  for ( size_t i = packet_start; i < count; ++i ) {
615  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
616  continue;
617  }
618  CLoadLockSeqIds lock(result, ids[i]);
619  if ( lock.IsLoaded() ) {
620  CFixedSeq_ids data = lock.GetSeq_ids();
621  if ( data.IsFound() ) {
622  ret[i] = data.Get();
623  loaded[i] = true;
624  }
625  continue;
626  }
627  }
628  }
629 
630  return true;
631 }
632 
633 
635  const TIds& ids, TLoaded& loaded, TIds& ret)
636 {
637  size_t max_request_size = GetMaxIdsRequestSize();
638  if ( max_request_size <= 1 ) {
639  return CReader::LoadAccVers(result, ids, loaded, ret);
640  }
641 
642  size_t count = ids.size();
643  CID2_Request_Packet packet;
644  size_t packet_start = 0;
645 
646  for ( size_t i = 0; i < count; ++i ) {
647  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
648  continue;
649  }
650  CLoadLockAcc lock(result, ids[i]);
651  if ( lock.IsLoadedAccVer() ) {
652  TSequenceAcc data = lock.GetAccVer();
653  if ( lock.IsFound(data) ) {
654  ret[i] = lock.GetAcc(data);
655  loaded[i] = true;
656  }
657  continue;
658  }
659 
662  req->SetRequest().SetGet_seq_id();
663  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
664  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
665  if ( packet.Set().empty() ) {
666  packet_start = i;
667  }
668  packet.Set().push_back(req);
669  if ( packet.Set().size() == max_request_size ) {
670  x_ProcessPacket(result, packet, 0);
671  size_t count = i+1;
672  for ( size_t i = packet_start; i < count; ++i ) {
673  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
674  continue;
675  }
676  CLoadLockAcc lock(result, ids[i]);
677  if ( lock.IsLoadedAccVer() ) {
678  TSequenceAcc data = lock.GetAccVer();
679  if ( lock.IsFound(data) ) {
680  ret[i] = lock.GetAcc(data);
681  loaded[i] = true;
682  }
683  continue;
684  }
685  }
686  packet.Set().clear();
687  }
688  }
689 
690  if ( !packet.Set().empty() ) {
691  x_ProcessPacket(result, packet, 0);
692 
693  for ( size_t i = packet_start; i < count; ++i ) {
694  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
695  continue;
696  }
697  CLoadLockAcc lock(result, ids[i]);
698  if ( lock.IsLoadedAccVer() ) {
699  TSequenceAcc data = lock.GetAccVer();
700  if ( lock.IsFound(data) ) {
701  ret[i] = lock.GetAcc(data);
702  loaded[i] = true;
703  }
704  continue;
705  }
706  }
707  }
708 
709  return true;
710 }
711 
712 
714  const TIds& ids, TLoaded& loaded, TGis& ret)
715 {
716  size_t max_request_size = GetMaxIdsRequestSize();
717  if ( max_request_size <= 1 ) {
718  return CReader::LoadGis(result, ids, loaded, ret);
719  }
720 
721  size_t count = ids.size();
722  CID2_Request_Packet packet;
723  size_t packet_start = 0;
724 
725  for ( size_t i = 0; i < count; ++i ) {
726  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
727  continue;
728  }
729  CLoadLockGi lock(result, ids[i]);
730  if ( lock.IsLoadedGi() ) {
731  TSequenceGi data = lock.GetGi();
732  if ( lock.IsFound(data) ) {
733  ret[i] = lock.GetGi(data);
734  loaded[i] = true;
735  }
736  continue;
737  }
738 
741  req->SetRequest().SetGet_seq_id();
742  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
743  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
744  if ( packet.Set().empty() ) {
745  packet_start = i;
746  }
747  packet.Set().push_back(req);
748  if ( packet.Set().size() == max_request_size ) {
749  x_ProcessPacket(result, packet, 0);
750  size_t count = i+1;
751  for ( size_t i = packet_start; i < count; ++i ) {
752  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
753  continue;
754  }
755  CLoadLockGi lock(result, ids[i]);
756  if ( lock.IsLoadedGi() ) {
757  TSequenceGi data = lock.GetGi();
758  if ( lock.IsFound(data) ) {
759  ret[i] = lock.GetGi(data);
760  loaded[i] = true;
761  }
762  continue;
763  }
764  }
765  packet.Set().clear();
766  }
767  }
768 
769  if ( !packet.Set().empty() ) {
770  x_ProcessPacket(result, packet, 0);
771 
772  for ( size_t i = packet_start; i < count; ++i ) {
773  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
774  continue;
775  }
776  CLoadLockGi lock(result, ids[i]);
777  if ( lock.IsLoadedGi() ) {
778  TSequenceGi data = lock.GetGi();
779  if ( lock.IsFound(data) ) {
780  ret[i] = lock.GetGi(data);
781  loaded[i] = true;
782  }
783  continue;
784  }
785  }
786  }
787 
788  return true;
789 }
790 
791 
793  const TIds& ids, TLoaded& loaded, TLabels& ret)
794 {
795  size_t max_request_size = GetMaxIdsRequestSize();
796  if ( max_request_size <= 1 ) {
797  return CReader::LoadLabels(result, ids, loaded, ret);
798  }
799 
800  size_t count = ids.size();
801  CID2_Request_Packet packet;
802  size_t packet_start = 0;
803 
804  for ( size_t i = 0; i < count; ++i ) {
805  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
806  continue;
807  }
808  CLoadLockLabel lock(result, ids[i]);
809  if ( lock.IsLoadedLabel() ) {
810  ret[i] = lock.GetLabel();
811  loaded[i] = true;
812  continue;
813  }
814 
817  req->SetRequest().SetGet_seq_id();
818  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
820  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all);
821  }
822  else {
823  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_label);
824  }
825  if ( packet.Set().empty() ) {
826  packet_start = i;
827  }
828  packet.Set().push_back(req);
829  if ( packet.Set().size() == max_request_size ) {
830  x_ProcessPacket(result, packet, 0);
831  size_t count = i+1;
832  for ( size_t i = packet_start; i < count; ++i ) {
833  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
834  continue;
835  }
836  CLoadLockLabel lock(result, ids[i]);
837  if ( lock.IsLoadedLabel() ) {
838  ret[i] = lock.GetLabel();
839  loaded[i] = true;
840  continue;
841  }
842  else {
844  CLoadLockSeqIds ids_lock(result, ids[i]);
845  if ( ids_lock.IsLoaded() ) {
846  string label = ids_lock.GetSeq_ids().FindLabel();
847  lock.SetLoadedLabel(label,
848  ids_lock.GetExpirationTime());
849  ret[i] = label;
850  loaded[i] = true;
851  }
852  }
853  }
854  packet.Set().clear();
855  }
856  }
857 
858  if ( !packet.Set().empty() ) {
859  x_ProcessPacket(result, packet, 0);
860 
861  for ( size_t i = packet_start; i < count; ++i ) {
862  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
863  continue;
864  }
865  CLoadLockLabel lock(result, ids[i]);
866  if ( lock.IsLoadedLabel() ) {
867  ret[i] = lock.GetLabel();
868  loaded[i] = true;
869  continue;
870  }
871  else {
873  CLoadLockSeqIds ids_lock(result, ids[i]);
874  if ( ids_lock.IsLoaded() ) {
875  string label = ids_lock.GetSeq_ids().FindLabel();
876  lock.SetLoadedLabel(label,
877  ids_lock.GetExpirationTime());
878  ret[i] = label;
879  loaded[i] = true;
880  }
881  }
882  }
883  }
884 
885  return true;
886 }
887 
888 
890  const TIds& ids, TLoaded& loaded, TTaxIds& ret)
891 {
892  size_t max_request_size = GetMaxIdsRequestSize();
893  if ( max_request_size <= 1 ||
895  return CReader::LoadTaxIds(result, ids, loaded, ret);
896  }
897 
898  size_t count = ids.size();
899  CID2_Request_Packet packet;
900  size_t packet_start = 0;
901 
902  for ( size_t i = 0; i < count; ++i ) {
903  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
904  continue;
905  }
907  return CReader::LoadTaxIds(result, ids, loaded, ret);
908  }
909  CLoadLockTaxId lock(result, ids[i]);
910  if ( lock.IsLoadedTaxId() ) {
911  ret[i] = lock.GetTaxId();
912  loaded[i] = true;
913  continue;
914  }
915 
918  req->SetRequest().SetGet_seq_id();
919  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
920  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_taxid);
921  if ( packet.Set().empty() ) {
922  packet_start = i;
923  }
924  packet.Set().push_back(req);
925  if ( packet.Set().size() == max_request_size ) {
926  x_ProcessPacket(result, packet, 0);
927  size_t count = i+1;
928  for ( size_t i = packet_start; i < count; ++i ) {
929  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
930  continue;
931  }
932  CLoadLockTaxId lock(result, ids[i]);
933  if ( lock.IsLoadedTaxId() ) {
934  ret[i] = lock.GetTaxId();
935  loaded[i] = true;
936  continue;
937  }
938  else {
940  }
941  }
942  packet.Set().clear();
943  }
944  }
945 
946  if ( !packet.Set().empty() ) {
947  x_ProcessPacket(result, packet, 0);
948 
949  for ( size_t i = packet_start; i < count; ++i ) {
950  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
951  continue;
952  }
953  CLoadLockTaxId lock(result, ids[i]);
954  if ( lock.IsLoadedTaxId() ) {
955  ret[i] = lock.GetTaxId();
956  loaded[i] = true;
957  continue;
958  }
959  else {
961  }
962  }
963  }
964 
965  return true;
966 }
967 
968 
970  const TIds& ids, TLoaded& loaded,
971  THashes& ret, TKnown& known)
972 {
973  size_t max_request_size = GetMaxIdsRequestSize();
974  if ( max_request_size <= 1 ||
976  return CReader::LoadHashes(result, ids, loaded, ret, known);
977  }
978 
979  size_t count = ids.size();
980  CID2_Request_Packet packet;
981  size_t packet_start = 0;
982 
983  for ( size_t i = 0; i < count; ++i ) {
984  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
985  continue;
986  }
988  return CReader::LoadHashes(result, ids, loaded, ret, known);
989  }
990  CLoadLockHash lock(result, ids[i]);
991  if ( lock.IsLoadedHash() ) {
992  TSequenceHash hash = lock.GetHash();
993  if ( hash.hash_known ) {
994  ret[i] = hash.hash;
995  loaded[i] = true;
996  known[i] = true;
997  continue;
998  }
999  else if ( !hash.sequence_found ) {
1000  // no sequence at all
1001  continue;
1002  }
1003  }
1004 
1007  req->SetRequest().SetGet_seq_id();
1008  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
1009  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_hash);
1010  if ( packet.Set().empty() ) {
1011  packet_start = i;
1012  }
1013  packet.Set().push_back(req);
1014  if ( packet.Set().size() == max_request_size ) {
1015  x_ProcessPacket(result, packet, 0);
1016  size_t count = i+1;
1017  for ( size_t i = packet_start; i < count; ++i ) {
1018  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1019  continue;
1020  }
1021  CLoadLockHash lock(result, ids[i]);
1022  if ( lock.IsLoadedHash() ) {
1023  TSequenceHash hash = lock.GetHash();
1024  if ( hash.hash_known ) {
1025  ret[i] = hash.hash;
1026  loaded[i] = true;
1027  known[i] = true;
1028  continue;
1029  }
1030  else if ( !hash.sequence_found ) {
1031  // no sequence at all
1032  continue;
1033  }
1034  }
1035  else {
1037  }
1038  }
1039  packet.Set().clear();
1040  }
1041  }
1042 
1043  if ( !packet.Set().empty() ) {
1044  x_ProcessPacket(result, packet, 0);
1045 
1046  for ( size_t i = packet_start; i < count; ++i ) {
1047  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1048  continue;
1049  }
1050  CLoadLockHash lock(result, ids[i]);
1051  TSequenceHash hash = lock.GetHash();
1052  if ( hash.hash_known ) {
1053  ret[i] = hash.hash;
1054  loaded[i] = true;
1055  known[i] = true;
1056  continue;
1057  }
1058  else if ( !hash.sequence_found ) {
1059  // no sequence at all
1060  continue;
1061  }
1062  else {
1064  }
1065  }
1066  }
1067 
1068  return true;
1069 }
1070 
1071 
1073  const TIds& ids, TLoaded& loaded, TLengths& ret)
1074 {
1075  size_t max_request_size = GetMaxIdsRequestSize();
1076  if ( max_request_size <= 1 ||
1078  return CReader::LoadLengths(result, ids, loaded, ret);
1079  }
1080 
1081  size_t count = ids.size();
1082  CID2_Request_Packet packet;
1083  size_t packet_start = 0;
1084 
1085  for ( size_t i = 0; i < count; ++i ) {
1086  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1087  continue;
1088  }
1090  return CReader::LoadLengths(result, ids, loaded, ret);
1091  }
1092  CLoadLockLength lock(result, ids[i]);
1093  if ( lock.IsLoadedLength() ) {
1094  ret[i] = lock.GetLength();
1095  loaded[i] = true;
1096  continue;
1097  }
1098 
1101  req->SetRequest().SetGet_seq_id();
1102  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
1103  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all |
1105  if ( packet.Set().empty() ) {
1106  packet_start = i;
1107  }
1108  packet.Set().push_back(req);
1109  if ( packet.Set().size() == max_request_size ) {
1110  x_ProcessPacket(result, packet, 0);
1111  size_t count = i+1;
1112  for ( size_t i = packet_start; i < count; ++i ) {
1113  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1114  continue;
1115  }
1116  CLoadLockLength lock(result, ids[i]);
1117  if ( lock.IsLoadedLength() ) {
1118  ret[i] = lock.GetLength();
1119  loaded[i] = true;
1120  continue;
1121  }
1122  else {
1124  }
1125  }
1126  packet.Set().clear();
1127  }
1128  }
1129 
1130  if ( !packet.Set().empty() ) {
1131  x_ProcessPacket(result, packet, 0);
1132 
1133  for ( size_t i = packet_start; i < count; ++i ) {
1134  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1135  continue;
1136  }
1137  CLoadLockLength lock(result, ids[i]);
1138  if ( lock.IsLoadedLength() ) {
1139  ret[i] = lock.GetLength();
1140  loaded[i] = true;
1141  continue;
1142  }
1143  else {
1145  }
1146  }
1147  }
1148 
1149  return true;
1150 }
1151 
1152 
1154  const TIds& ids, TLoaded& loaded, TTypes& ret)
1155 {
1156  size_t max_request_size = GetMaxIdsRequestSize();
1157  if ( max_request_size <= 1 ||
1159  return CReader::LoadTypes(result, ids, loaded, ret);
1160  }
1161 
1162  size_t count = ids.size();
1163  CID2_Request_Packet packet;
1164  size_t packet_start = 0;
1165 
1166  for ( size_t i = 0; i < count; ++i ) {
1167  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1168  continue;
1169  }
1171  return CReader::LoadTypes(result, ids, loaded, ret);
1172  }
1173  CLoadLockType lock(result, ids[i]);
1174  if ( lock.IsLoadedType() ) {
1175  TSequenceType data = lock.GetType();
1176  if ( lock.IsFound(data) ) {
1177  ret[i] = lock.GetType(data);
1178  loaded[i] = true;
1179  }
1180  continue;
1181  }
1182 
1185  req->SetRequest().SetGet_seq_id();
1186  get_id.SetSeq_id().SetSeq_id().Assign(*ids[i].GetSeqId());
1187  get_id.SetSeq_id_type(CID2_Request_Get_Seq_id::eSeq_id_type_all |
1189  if ( packet.Set().empty() ) {
1190  packet_start = i;
1191  }
1192  packet.Set().push_back(req);
1193  if ( packet.Set().size() == max_request_size ) {
1194  x_ProcessPacket(result, packet, 0);
1195  size_t count = i+1;
1196  for ( size_t i = packet_start; i < count; ++i ) {
1197  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1198  continue;
1199  }
1200  CLoadLockType lock(result, ids[i]);
1201  if ( lock.IsLoadedType() ) {
1202  TSequenceType data = lock.GetType();
1203  if ( lock.IsFound(data) ) {
1204  ret[i] = lock.GetType(data);
1205  loaded[i] = true;
1206  }
1207  continue;
1208  }
1209  else {
1211  }
1212  }
1213  packet.Set().clear();
1214  }
1215  }
1216 
1217  if ( !packet.Set().empty() ) {
1218  x_ProcessPacket(result, packet, 0);
1219 
1220  for ( size_t i = packet_start; i < count; ++i ) {
1221  if ( loaded[i] || CReadDispatcher::CannotProcess(ids[i]) ) {
1222  continue;
1223  }
1224  CLoadLockType lock(result, ids[i]);
1225  if ( lock.IsLoadedType() ) {
1226  TSequenceType data = lock.GetType();
1227  if ( lock.IsFound(data) ) {
1228  ret[i] = lock.GetType(data);
1229  loaded[i] = true;
1230  }
1231  continue;
1232  }
1233  else {
1235  }
1236  }
1237  }
1238 
1239  return true;
1240 }
1241 
1242 
1244  const TIds& ids, TLoaded& loaded, TStates& ret)
1245 {
1246  size_t max_request_size = GetMaxIdsRequestSize();
1247  if ( max_request_size <= 1 ) {
1248  return CReader::LoadStates(result, ids, loaded, ret);
1249  }
1250 
1251  size_t count = ids.size();
1252  CID2_Request_Packet packet;
1253  size_t packet_start = 0;
1254 
1255  for ( size_t i = 0; i < count; ++i ) {
1256  if ( CReadDispatcher::SetBlobState(i, result, ids, loaded, ret) ) {
1257  continue;
1258  }
1259 
1261  x_SetResolve(req->SetRequest().SetGet_blob_id(), *ids[i].GetSeqId());
1262  if ( packet.Set().empty() ) {
1263  packet_start = i;
1264  }
1265  packet.Set().push_back(req);
1266  if ( packet.Set().size() == max_request_size ) {
1267  x_ProcessPacket(result, packet, 0);
1268  size_t count = i+1;
1269  for ( size_t i = packet_start; i < count; ++i ) {
1270  CReadDispatcher::SetBlobState(i, result, ids, loaded, ret);
1271  }
1272  packet.Set().clear();
1273  }
1274  }
1275 
1276  if ( !packet.Set().empty() ) {
1277  x_ProcessPacket(result, packet, 0);
1278 
1279  for ( size_t i = packet_start; i < count; ++i ) {
1280  CReadDispatcher::SetBlobState(i, result, ids, loaded, ret);
1281  }
1282  }
1283 
1284  return true;
1285 }
1286 
1287 
1289  const CSeq_id_Handle& seq_id,
1290  const SAnnotSelector* sel)
1291 {
1292  CLoadLockBlobIds ids(result, seq_id, sel);
1293  if ( ids.IsLoaded() ) {
1294  return true;
1295  }
1296 
1297  CID2_Request req;
1298  CID2_Request_Get_Blob_Id& get_blob_id = req.SetRequest().SetGet_blob_id();
1299  x_SetResolve(get_blob_id, *seq_id.GetSeqId());
1300  if ( sel && sel->IsIncludedAnyNamedAnnotAccession() ) {
1301  CID2_Request_Get_Blob_Id::TSources& srcs = get_blob_id.SetSources();
1303  srcs.push_back(it->first);
1304  if (it->first == "SNP") {
1306  if (snp_scale_limit == CSeq_id::eSNPScaleLimit_Default) {
1307  snp_scale_limit = GetSNP_Scale_Limit();
1308  }
1309  if (snp_scale_limit != CSeq_id::eSNPScaleLimit_Default) {
1310  CRef<CID2_Param> param(new CID2_Param);
1311  param->SetName("snp:scale-limit");
1312  param->SetValue().push_back(CSeq_id::GetSNPScaleLimit_Name(snp_scale_limit));
1313  req.SetParams().Set().push_back(param);
1314  }
1315  }
1316  }
1317  }
1318  x_ProcessRequest(result, req, sel);
1319  return true;
1320 }
1321 
1322 
1324  const CBlob_id& blob_id)
1325 {
1326  CLoadLockBlobState lock(result, blob_id);
1327  if ( lock.IsLoadedBlobState() ) {
1328  return true;
1329  }
1330  CID2_Request req;
1331  CID2_Request_Get_Blob_Info& req2 = req.SetRequest().SetGet_blob_info();
1332  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1333  x_ProcessRequest(result, req, 0);
1334  if ( CProcessor_ExtAnnot::IsExtAnnot(blob_id) ) {
1335  // workaround for possible incorrect reply on request for non-existent
1336  // external annotations
1337  if ( !lock.IsLoadedBlobState() ) {
1338  ERR_POST_X(5, "ExtAnnot blob state is not loaded: "<<blob_id);
1339  result.SetLoadedBlobState(blob_id, 0);
1340  }
1341  }
1342  return true;
1343 }
1344 
1345 
1347  const CBlob_id& blob_id)
1348 {
1349  CLoadLockBlobVersion lock(result, blob_id);
1350  if ( lock.IsLoadedBlobVersion() ) {
1351  return true;
1352  }
1353  CID2_Request req;
1354  CID2_Request_Get_Blob_Info& req2 = req.SetRequest().SetGet_blob_info();
1355  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1356  x_ProcessRequest(result, req, 0);
1357  if ( CProcessor_ExtAnnot::IsExtAnnot(blob_id) ) {
1358  // workaround for possible incorrect reply on request for non-existent
1359  // external annotations
1360  if ( !lock.IsLoadedBlobVersion() ) {
1361  ERR_POST_X(9, "ExtAnnot blob version is not loaded: "<<blob_id);
1362  result.SetLoadedBlobVersion(blob_id, 0);
1363  }
1364  }
1365  return true;
1366 }
1367 
1368 
1370  const CSeq_id_Handle& seq_id,
1372  const SAnnotSelector* sel)
1373 {
1374  CLoadLockBlobIds ids(result, seq_id, sel);
1375  if ( !ids.IsLoaded() ) {
1377  !(mask & fBlobHasAllLocal) ) {
1378  if ( !LoadSeq_idBlob_ids(result, seq_id, sel) ) {
1379  return false;
1380  }
1381  }
1382  }
1383  if ( ids.IsLoaded() ) {
1384  // shortcut - we know Seq-id -> Blob-id resolution
1385  return LoadBlobs(result, ids, mask, sel);
1386  }
1388  return CReader::LoadBlobs(result, seq_id, mask, sel);
1389  }
1390  else {
1391  CID2_Request req;
1392  CID2_Request_Get_Blob_Info& req2 = req.SetRequest().SetGet_blob_info();
1393  x_SetResolve(req2.SetBlob_id().SetResolve().SetRequest(),
1394  *seq_id.GetSeqId());
1395  x_SetDetails(req2.SetGet_data(), mask);
1396  x_SetExclude_blobs(req2, seq_id, result);
1397  x_ProcessRequest(result, req, sel);
1398  return ids.IsLoaded();
1399  }
1400 }
1401 
1402 
1404  const CLoadLockBlobIds& blobs,
1406  const SAnnotSelector* sel)
1407 {
1408  size_t max_request_size = GetMaxChunksRequestSize();
1409  CID2_Request_Packet packet;
1410  CFixedBlob_ids blob_ids = blobs.GetBlob_ids();
1411  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1412  const CBlob_Info& info = *it;
1413  const CBlob_id& blob_id = *info.GetBlob_id();
1414  if ( !info.Matches(mask, sel) ) {
1415  continue; // skip this blob
1416  }
1417  CLoadLockBlob blob(result, blob_id);
1418  if ( blob.IsLoadedBlob() ) {
1419  continue;
1420  }
1421 
1422  if ( info.IsSetAnnotInfo() ) {
1424  _ASSERT(blob.IsLoadedBlob());
1425  continue;
1426  }
1427 
1428  if ( CProcessor_ExtAnnot::IsExtAnnot(blob_id) ) {
1429  dynamic_cast<const CProcessor_ExtAnnot&>
1431  .Process(result, blob_id, kMain_ChunkId);
1432  _ASSERT(blob.IsLoadedBlob());
1433  continue;
1434  }
1435 
1437  packet.Set().push_back(req);
1439  req->SetRequest().SetGet_blob_info();
1440  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1441  x_SetDetails(req2.SetGet_data(), mask);
1442  if ( LimitChunksRequests(max_request_size) &&
1443  packet.Get().size() >= max_request_size ) {
1444  x_ProcessPacket(result, packet, sel);
1445  packet.Set().clear();
1446  }
1447  }
1448  if ( !packet.Get().empty() ) {
1449  x_ProcessPacket(result, packet, sel);
1450  }
1451  return true;
1452 }
1453 
1454 
1456  const TBlobId& blob_id)
1457 {
1458  CLoadLockBlob blob(result, blob_id);
1459  if ( blob.IsLoadedBlob() ) {
1460  return true;
1461  }
1462 
1463  if ( CProcessor_ExtAnnot::IsExtAnnot(blob_id) ) {
1464  dynamic_cast<const CProcessor_ExtAnnot&>
1466  .Process(result, blob_id, kMain_ChunkId);
1467  _ASSERT(blob.IsLoadedBlob());
1468  return true;
1469  }
1470 
1471  CID2_Request req;
1472  CID2_Request_Get_Blob_Info& req2 = req.SetRequest().SetGet_blob_info();
1473  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1474  req2.SetGet_data();
1475  x_ProcessRequest(result, req, 0);
1476  return true;
1477 }
1478 
1479 
1481  const CBlob_id& blob_id,
1482  TChunkId chunk_id)
1483 {
1484  CLoadLockBlob blob(result, blob_id, chunk_id);
1485  if ( blob.IsLoadedChunk() ) {
1486  return true;
1487  }
1488 
1489  CID2_Request req;
1490  if ( chunk_id == kDelayedMain_ChunkId ) {
1491  CID2_Request_Get_Blob_Info& req2 = req.SetRequest().SetGet_blob_info();
1492  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1493  req2.SetGet_data();
1494  x_ProcessRequest(result, req, 0);
1495  if ( !blob.IsLoadedChunk() ) {
1496  CLoadLockSetter setter(blob);
1497  if ( !setter.IsLoaded() ) {
1498  ERR_POST_X(2, "ExtAnnot chunk is not loaded: "<<blob_id);
1499  setter.SetLoaded();
1500  }
1501  }
1502  }
1503  else {
1504  CID2S_Request_Get_Chunks& req2 = req.SetRequest().SetGet_chunks();
1505  x_SetResolve(req2.SetBlob_id(), blob_id);
1506 
1507  if ( blob.GetKnownBlobVersion() > 0 ) {
1508  req2.SetBlob_id().SetVersion(blob.GetKnownBlobVersion());
1509  }
1511  req2.SetChunks().push_back(CID2S_Chunk_Id(chunk_id));
1512  x_ProcessRequest(result, req, 0);
1513  }
1514  return true;
1515 }
1516 
1517 
1519  CID2_Request_Packet& packet,
1520  vector<TChunkId>& chunks,
1521  const CBlob_id& blob_id)
1522 {
1523  CLoadLockBlob blob(result, blob_id);
1524  NON_CONST_ITERATE(vector<TChunkId>, it, chunks) {
1525  blob.SelectChunk(*it);
1526  if ( !blob.IsLoadedChunk() ) {
1527  CLoadLockSetter setter(blob);
1528  if ( !setter.IsLoaded() ) {
1529  ERR_POST_X(3, "ExtAnnot chunk is not loaded: " << blob_id);
1530  setter.SetLoaded();
1531  }
1532  }
1533  }
1534  packet.Set().clear();
1535  chunks.clear();
1536 }
1537 
1538 
1540  CID2_Request_Packet& packet,
1541  CReader::TBlobChunkIds& chunk_ids)
1542 {
1543  for ( auto& blob_chunks : chunk_ids ) {
1544  LoadedChunksPacket(result, packet, blob_chunks.second, blob_chunks.first);
1545  }
1546  packet.Set().clear();
1547  chunk_ids.clear();
1548 }
1549 
1550 
1552  const CBlob_id& blob_id,
1553  const TChunkIds& chunk_ids)
1554 {
1555  if ( chunk_ids.size() == 1 ) {
1556  return LoadChunk(result, blob_id, chunk_ids[0]);
1557  }
1558  size_t max_request_size = GetMaxChunksRequestSize();
1559  if ( SeparateChunksRequests(max_request_size) ) {
1560  return CReader::LoadChunks(result, blob_id, chunk_ids);
1561  }
1562  CLoadLockBlob blob(result, blob_id);
1563  _ASSERT(blob.IsLoadedBlob());
1564 
1565  CID2_Request_Packet packet;
1566 
1567  CRef<CID2_Request> chunks_req(new CID2_Request);
1568  CID2S_Request_Get_Chunks& get_chunks =
1569  chunks_req->SetRequest().SetGet_chunks();
1570 
1571  x_SetResolve(get_chunks.SetBlob_id(), blob_id);
1572  if ( blob.GetKnownBlobVersion() > 0 ) {
1573  get_chunks.SetBlob_id().SetVersion(blob.GetKnownBlobVersion());
1574  }
1575  get_chunks.SetSplit_version(blob.GetSplitInfo().GetSplitVersion());
1576  CID2S_Request_Get_Chunks::TChunks& chunks = get_chunks.SetChunks();
1577 
1578  vector<TChunkId> ext_chunks;
1579  ITERATE(TChunkIds, id, chunk_ids) {
1580  blob.SelectChunk(*id);
1581  if ( blob.IsLoadedChunk() ) {
1582  continue;
1583  }
1584  if ( *id == kDelayedMain_ChunkId ) {
1585  CRef<CID2_Request> ext_req(new CID2_Request);
1586  CID2_Request_Get_Blob_Info& ext_req_data =
1587  ext_req->SetRequest().SetGet_blob_info();
1588  x_SetResolve(ext_req_data.SetBlob_id().SetBlob_id(), blob_id);
1589  ext_req_data.SetGet_data();
1590  packet.Set().push_back(ext_req);
1591  ext_chunks.push_back(*id);
1592  if ( LimitChunksRequests(max_request_size) &&
1593  packet.Get().size() >= max_request_size ) {
1594  // Request collected chunks
1595  x_ProcessPacket(result, packet, 0);
1596  LoadedChunksPacket(result, packet, ext_chunks, blob_id);
1597  }
1598  }
1599  else {
1600  chunks.push_back(CID2S_Chunk_Id(*id));
1601  if ( LimitChunksRequests(max_request_size) &&
1602  chunks.size() >= max_request_size ) {
1603  // Process collected chunks
1604  x_ProcessRequest(result, *chunks_req, 0);
1605  chunks.clear();
1606  }
1607  }
1608  }
1609  if ( !chunks.empty() ) {
1610  if ( LimitChunksRequests(max_request_size) &&
1611  packet.Get().size() + chunks.size() > max_request_size ) {
1612  // process chunks separately from packet
1613  x_ProcessRequest(result, *chunks_req, 0);
1614  }
1615  else {
1616  // Use the same packet for chunks
1617  packet.Set().push_back(chunks_req);
1618  }
1619  }
1620  if ( !packet.Get().empty() ) {
1621  x_ProcessPacket(result, packet, 0);
1622  LoadedChunksPacket(result, packet, ext_chunks, blob_id);
1623  }
1624  return true;
1625 }
1626 
1627 
1629  const TBlobChunkIds& chunk_ids)
1630 {
1631  size_t max_request_size = GetMaxChunksRequestSize();
1632  if ( SeparateChunksRequests(max_request_size) ) {
1633  return CReader::LoadChunks(result, chunk_ids);
1634  }
1635  CID2_Request_Packet packet;
1636  TBlobChunkIds requested_chunks;
1637  size_t requested_count = 0;
1638  for ( auto& blob_chunks : chunk_ids ) {
1639  const CBlob_id& blob_id = blob_chunks.first;
1640  CLoadLockBlob blob(result, blob_id);
1641  _ASSERT(blob.IsLoadedBlob());
1642 
1643  CID2S_Request_Get_Chunks::TChunks* chunks_list = 0;
1644  for ( auto chunk_id : blob_chunks.second ) {
1645  blob.SelectChunk(chunk_id);
1646  if ( blob.IsLoadedChunk() ) {
1647  continue;
1648  }
1649  if ( chunk_id == kDelayedMain_ChunkId ) {
1650  _ASSERT(!chunks_list);
1651  // add blob request
1653  CID2_Request_Get_Blob_Info& req_data = req->SetRequest().SetGet_blob_info();
1654  x_SetResolve(req_data.SetBlob_id().SetBlob_id(), blob_id);
1655  req_data.SetGet_data();
1656  packet.Set().push_back(req);
1657  requested_chunks.push_back(make_pair(blob_id, TChunkIds()));
1658  }
1659  else {
1660  // need to request chunks
1661  if ( !chunks_list ) {
1662  // create chunk request
1664  CID2S_Request_Get_Chunks& get_chunks = req->SetRequest().SetGet_chunks();
1665  x_SetResolve(get_chunks.SetBlob_id(), blob_id);
1666  if ( blob.GetKnownBlobVersion() > 0 ) {
1667  get_chunks.SetBlob_id().SetVersion(blob.GetKnownBlobVersion());
1668  }
1669  get_chunks.SetSplit_version(blob.GetSplitInfo().GetSplitVersion());
1670  packet.Set().push_back(req);
1671  chunks_list = &get_chunks.SetChunks();
1672  requested_chunks.push_back(make_pair(blob_id, TChunkIds()));
1673  }
1674  chunks_list->push_back(CID2S_Chunk_Id(chunk_id));
1675  }
1676  // flush packed if it's too big
1677  requested_chunks.back().second.push_back(chunk_id);
1678  ++requested_count;
1679  if ( LimitChunksRequests(max_request_size) &&
1680  requested_count >= max_request_size ) {
1681  // Process collected chunks
1682  x_ProcessPacket(result, packet, 0);
1683  LoadedChunksPacket(result, packet, requested_chunks);
1684  requested_count = 0;
1685  chunks_list = 0;
1686  }
1687  }
1688  }
1689  // flush final packet
1690  if ( requested_count ) {
1691  x_ProcessPacket(result, packet, 0);
1692  LoadedChunksPacket(result, packet, requested_chunks);
1693  requested_count = 0;
1694  }
1695  return true;
1696 }
1697 
1698 
1700  const TBlobIds& blob_infos)
1701 {
1702  size_t max_request_size = GetMaxChunksRequestSize();
1703  CID2_Request_Packet packet;
1704  for ( auto& info : blob_infos ) {
1705  const CBlob_id& blob_id = *info.GetBlob_id();
1706  CLoadLockBlob blob(result, blob_id);
1707  if ( blob.IsLoadedBlob() ) {
1708  continue;
1709  }
1710 
1711  if ( info.IsSetAnnotInfo() ) {
1713  _ASSERT(blob.IsLoadedBlob());
1714  continue;
1715  }
1716 
1717  if ( CProcessor_ExtAnnot::IsExtAnnot(blob_id) ) {
1718  dynamic_cast<const CProcessor_ExtAnnot&>
1720  .Process(result, blob_id, kMain_ChunkId);
1721  _ASSERT(blob.IsLoadedBlob());
1722  continue;
1723  }
1724 
1726  packet.Set().push_back(req);
1727  CID2_Request_Get_Blob_Info& req2 = req->SetRequest().SetGet_blob_info();
1728  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1730  if ( LimitChunksRequests(max_request_size) &&
1731  packet.Get().size() >= max_request_size ) {
1732  x_ProcessPacket(result, packet, 0);
1733  packet.Set().clear();
1734  }
1735  }
1736  // flush final packet
1737  if ( !packet.Get().empty() ) {
1738  x_ProcessPacket(result, packet, 0);
1739  }
1740  return true;
1741 }
1742 
1743 
1745  const TSeqIds& seq_ids)
1746 {
1747  size_t max_request_size = GetMaxChunksRequestSize();
1748  if ( SeparateChunksRequests(max_request_size) ) {
1749  ITERATE(TSeqIds, id, seq_ids) {
1750  LoadSeq_idBlob_ids(result, *id, 0);
1751  }
1752  return true;
1753  }
1754  CID2_Request_Packet packet;
1755  ITERATE(TSeqIds, id, seq_ids) {
1756  CLoadLockBlobIds ids(result, *id, 0);
1757  if ( ids.IsLoaded() ) {
1758  continue;
1759  }
1760 
1762  x_SetResolve(req->SetRequest().SetGet_blob_id(), *id->GetSeqId());
1763  packet.Set().push_back(req);
1764  if ( LimitChunksRequests(max_request_size) &&
1765  packet.Get().size() >= max_request_size ) {
1766  // Request collected chunks
1767  x_ProcessPacket(result, packet, 0);
1768  packet.Set().clear();
1769  }
1770  }
1771  if ( !packet.Get().empty() ) {
1772  x_ProcessPacket(result, packet, 0);
1773  }
1774  return true;
1775 }
1776 
1777 
1779  const TSeqIds& seq_ids)
1780 {
1781  size_t max_request_size = GetMaxChunksRequestSize();
1782  if ( SeparateChunksRequests(max_request_size) ) {
1783  return CReader::LoadBlobSet(result, seq_ids);
1784  }
1785 
1786  bool loaded_blob_ids = false;
1787  size_t processed_requests = 0;
1789  if ( !x_LoadSeq_idBlob_idsSet(result, seq_ids) ) {
1790  return false;
1791  }
1792  loaded_blob_ids = true;
1793  }
1794 
1795  set<CBlob_id> load_blob_ids;
1796  CID2_Request_Packet packet;
1797  ITERATE(TSeqIds, id, seq_ids) {
1798  if ( !loaded_blob_ids &&
1800  if ( !x_LoadSeq_idBlob_idsSet(result, seq_ids) ) {
1801  return false;
1802  }
1803  loaded_blob_ids = true;
1804  }
1805  CLoadLockBlobIds ids(result, *id, 0);
1806  if ( ids && ids.IsLoaded() ) {
1807  // shortcut - we know Seq-id -> Blob-id resolution
1808  CFixedBlob_ids blob_ids = ids.GetBlob_ids();
1809  ITERATE ( CFixedBlob_ids, it, blob_ids ) {
1810  const CBlob_Info& info = *it;
1811  const CBlob_id& blob_id = *info.GetBlob_id();
1812  if ( (info.GetContentsMask() & fBlobHasCore) == 0 ) {
1813  continue; // skip this blob
1814  }
1815  CLoadLockBlob blob(result, blob_id);
1816  if ( blob.IsLoadedBlob() ) {
1817  continue;
1818  }
1819  if ( !load_blob_ids.insert(blob_id).second ) {
1820  continue;
1821  }
1824  req->SetRequest().SetGet_blob_info();
1825  x_SetResolve(req2.SetBlob_id().SetBlob_id(), blob_id);
1827  packet.Set().push_back(req);
1828  if ( LimitChunksRequests(max_request_size) &&
1829  packet.Get().size() >= max_request_size ) {
1830  processed_requests += packet.Set().size();
1831  x_ProcessPacket(result, packet, 0);
1832  packet.Set().clear();
1833  }
1834  }
1835  }
1836  else {
1839  req->SetRequest().SetGet_blob_info();
1840  x_SetResolve(req2.SetBlob_id().SetResolve().SetRequest(),
1841  *id->GetSeqId());
1843  x_SetExclude_blobs(req2, *id, result);
1844  packet.Set().push_back(req);
1845  if ( LimitChunksRequests(max_request_size) &&
1846  packet.Get().size() >= max_request_size ) {
1847  processed_requests += packet.Set().size();
1848  x_ProcessPacket(result, packet, 0);
1849  packet.Set().clear();
1850  }
1851  }
1852  }
1853  if ( !packet.Get().empty() ) {
1854  processed_requests += packet.Get().size();
1855  x_ProcessPacket(result, packet, 0);
1856  }
1857  if ( !processed_requests && !loaded_blob_ids ) {
1858  return false;
1859  }
1860  return true;
1861 }
1862 
1863 
1865  CID2_Request& req,
1866  const SAnnotSelector* sel)
1867 {
1868  CID2_Request_Packet packet;
1869  packet.Set().push_back(Ref(&req));
1870  x_ProcessPacket(result, packet, sel);
1871 }
1872 
1873 
1875 {
1878  vector<const CID2_Request*> requests;
1879 };
1880 
1881 
1883 {
1885  vector<TRequestReplies> replies;
1886 };
1887 
1888 
1890 {
1892  CID2Processor::TReplies replies; // in backward order to use pop_back()
1893 };
1894 
1895 
1897 {
1898  vector<SId2ProcessorStage> stages;
1899  unique_ptr<CReaderAllocatedConnection> conn;
1900 
1902  return conn? *conn: 0;
1903  }
1904 };
1905 
1906 
1908 {
1909  if (params.IsSetEnableSNP()) {
1910  SetVDB_SNP_Enabled(params.GetEnableSNP());
1911  }
1912  if (params.IsSetEnableWGS()) {
1913  SetVDB_WGS_Enabled(params.GetEnableWGS());
1914  }
1915  if (params.IsSetEnableCDD()) {
1916  SetVDB_CDD_Enabled(params.GetEnableCDD());
1917  }
1918 }
1919 
1920 
1922 {
1923  if ( request.GetRequest().IsInit() ) {
1924  CRef<CID2_Param> param(new CID2_Param);
1925  param->SetName("log:client_name");
1926  param->SetValue().push_back(GetDiagContext().GetAppName());
1927  request.SetParams().Set().push_back(param);
1928  if ( 1 ) {
1929  CRef<CID2_Param> param(new CID2_Param);
1930  param->SetName("id2:allow");
1931  // allow new blob-state field in several ID2 replies
1932  param->SetValue().push_back("*.blob-state");
1933  if ( GetVDB_WGS_Enabled() ) {
1934  // enable VDB-based WGS sequences
1935  param->SetValue().push_back("vdb-wgs");
1936  }
1937  if ( GetVDB_SNP_Enabled() ) {
1938  // enable VDB-based SNP sequences
1939  param->SetValue().push_back("vdb-snp");
1940  }
1941  if ( GetVDB_CDD_Enabled() ) {
1942  // enable VDB-based CDD sequences
1943  param->SetValue().push_back("vdb-cdd");
1944  }
1945  request.SetParams().Set().push_back(param);
1946  }
1947  auto scale_limit = GetSNP_Scale_Limit();
1948  if (scale_limit != CSeq_id::eSNPScaleLimit_Default) {
1949  CRef<CID2_Param> param(new CID2_Param);
1950  param->SetName("snp:scale-limit");
1951  param->SetValue().push_back(CSeq_id::GetSNPScaleLimit_Name(scale_limit));
1952  request.SetParams().Set().push_back(param);
1953  }
1954  }
1956  if ( rctx.IsSetSessionID() ) {
1957  CRef<CID2_Param> param(new CID2_Param);
1958  param->SetName("session_id");
1959  param->SetValue().push_back(rctx.GetSessionID());
1960  request.SetParams().Set().push_back(param);
1961  }
1962  if ( rctx.IsSetHitID() ) {
1963  CRef<CID2_Param> param(new CID2_Param);
1964  param->SetName("log:ncbi_phid");
1965  param->SetValue().push_back(rctx.GetNextSubHitID());
1966  request.SetParams().Set().push_back(param);
1967  }
1968  if ( rctx.IsSetClientIP() ) {
1969  CRef<CID2_Param> param(new CID2_Param);
1970  param->SetName("log:client_ip");
1971  param->SetValue().push_back(rctx.GetClientIP());
1972  request.SetParams().Set().push_back(param);
1973  }
1974 }
1975 
1976 
1977 #define x_GetReaderName(conn) \
1978  (x_ConnDescription((conn)).empty()? "CPubseq2Reader": "CId2Reader")
1979 
1980 
1982  const CID2_Request_Packet& packet,
1983  const char* msg)
1984 {
1985  if ( GetDebugLevel() >= eTraceConn ) {
1987  s << msg;
1988  if ( GetDebugLevel() >= eTraceASN ) {
1989  s << ": " << MSerial_AsnText << packet;
1990  }
1991  else {
1992  s << " ID2-Request-Packet";
1993  }
1994  s << "...";
1995  }
1996 }
1997 
1998 
2000  CID2_Reply& reply,
2001  const char* msg)
2002 {
2003  if ( GetDebugLevel() >= eTraceConn ) {
2005  s << msg;
2006  if ( GetDebugLevel() >= eTraceASN ) {
2007  if ( GetDebugLevel() >= eTraceBlobData ) {
2008  s << ": " << MSerial_AsnText << reply;
2009  }
2010  else {
2011  CTypeIterator<CID2_Reply_Data> iter = Begin(reply);
2012  if ( iter && iter->IsSetData() ) {
2014  save.swap(iter->SetData());
2015  size_t size = 0, count = 0, max_chunk = 0;
2016  ITERATE ( CID2_Reply_Data::TData, i, save ) {
2017  ++count;
2018  size_t chunk = (*i)->size();
2019  size += chunk;
2020  max_chunk = max(max_chunk, chunk);
2021  }
2022  s << ": " << MSerial_AsnText << reply <<
2023  "Data: " << size << " bytes in " <<
2024  count << " chunks with " <<
2025  max_chunk << " bytes in chunk max";
2026  save.swap(iter->SetData());
2027  }
2028  else {
2029  s << ": " << MSerial_AsnText << reply;
2030  }
2031  }
2032  }
2033  else {
2034  s << " ID2-Reply.";
2035  }
2036  }
2037  if ( GetDebugLevel() >= eTraceBlob ) {
2038  for ( CTypeConstIterator<CID2_Reply_Data> it(Begin(reply));
2039  it; ++it ) {
2040  if ( it->IsSetData() ) {
2041  try {
2043  }
2044  catch ( CException& exc ) {
2045  ERR_POST_X(1, "Exception while dumping data: "
2046  <<exc);
2047  }
2048  }
2049  }
2050  }
2051 }
2052 
2053 
2055  CID2_Request_Packet& packet)
2056 {
2058  x_DumpPacket(conn, packet);
2059  try {
2060  x_SendPacket(conn, packet);
2061  }
2062  catch ( CException& exc ) {
2063  NCBI_RETHROW(exc, CLoaderException, eConnectionFailed,
2064  "failed to send request: "+
2066  }
2067  if ( GetDebugLevel() >= eTraceConn ) {
2069  s << "Sent ID2-Request-Packet.";
2070  }
2071 }
2072 
2073 
2075 {
2076  if ( GetDebugLevel() >= eTraceConn ) {
2078  s << "Receiving ID2-Reply...";
2079  }
2080  CRef<CID2_Reply> reply(new CID2_Reply);
2081  try {
2082  x_ReceiveReply(conn, *reply);
2083  }
2084  catch ( CException& exc ) {
2085  NCBI_RETHROW(exc, CLoaderException, eConnectionFailed,
2086  "reply deserialization failed: "+
2088  }
2089  x_DumpReply(conn, *reply);
2091  return reply;
2092 }
2093 
2094 
2097  CID2_Request_Packet& packet)
2098 {
2100  x_DumpPacket(0, packet, "Processing");
2101  size_t proc_count = m_Processors.size();
2102  state.stages.reserve(proc_count);
2103  for ( size_t i = 0; i < proc_count; ++i ) {
2104  if ( packet.Get().empty() ) {
2105  return;
2106  }
2107  state.stages.resize(i+1);
2109  SId2ProcessorStage& stage = state.stages[i];
2110  stage.packet_context = info.processor->ProcessPacket(info.context, packet, stage.replies);
2111  if ( GetDebugLevel() >= eTraceConn &&
2112  !stage.replies.empty() ) {
2113  x_DumpPacket(0, packet, "Filtered");
2114  for ( auto& it : stage.replies ) {
2115  x_DumpReply(0, *it, "Got from processor");
2116  }
2117  }
2118  reverse(stage.replies.begin(), stage.replies.end());
2119  }
2120  if ( packet.Get().empty() ) {
2121  return;
2122  }
2123  state.conn.reset(new CConn(result, this));
2124  TConn conn = state.GetConn();
2125  try {
2126  if ( GetDebugLevel() >= eTraceConn ) {
2128  s << "Sending ID2-Request-Packet...";
2129  }
2130  x_SendPacket(conn, packet);
2131  if ( GetDebugLevel() >= eTraceConn ) {
2133  s << "Sent ID2-Request-Packet.";
2134  }
2135  }
2136  catch ( CException& exc ) {
2137  NCBI_RETHROW(exc, CLoaderException, eConnectionFailed,
2138  "failed to send request: "+
2140  }
2141 }
2142 
2143 
2145 {
2146  if ( pos < state.stages.size() ) {
2147  SId2ProcessorStage& stage = state.stages[pos];
2149  while ( stage.replies.empty() ) {
2151  info.processor->ProcessReply(info.context, stage.packet_context, *reply, stage.replies);
2152  if ( GetDebugLevel() >= eTraceConn &&
2153  (stage.replies.size() != 1 || stage.replies[0] != reply) ) {
2154  x_DumpReply(0, *reply, "Filtered by processor");
2155  for ( auto& it : stage.replies ) {
2156  x_DumpReply(0, *it, "New from processor");
2157  }
2158  }
2159  reverse(stage.replies.begin(), stage.replies.end());
2160  }
2161  CRef<CID2_Reply> reply = stage.replies.back();
2162  stage.replies.pop_back();
2163  return reply;
2164  }
2165  else {
2166  _ASSERT(state.conn);
2167  TConn conn = state.GetConn();
2168  for (;;) {
2169  if ( GetDebugLevel() >= eTraceConn ) {
2171  s << "Receiving ID2-Reply...";
2172  }
2173  CRef<CID2_Reply> reply(new CID2_Reply);
2174  try {
2175  x_ReceiveReply(conn, *reply);
2176  }
2177  catch ( CException& exc ) {
2178  NCBI_RETHROW(exc, CLoaderException, eConnectionFailed,
2179  "reply deserialization failed: "+
2181  }
2182  x_DumpReply(conn, *reply);
2183  if ( reply->IsSetDiscard() ) {
2184  continue;
2185  }
2186  return reply;
2187  }
2188  }
2189 }
2190 
2191 
2193 {
2196  return reply;
2197 }
2198 
2199 
2201  CID2_Request_Packet& packet)
2202 {
2203  // Fill request context information
2204  if ( !packet.Get().empty() ) {
2205  x_SetContextData(*packet.Set().front());
2206  }
2207 
2208  // prepare serial nums and result state
2209  for ( auto& i : packet.Get() ) {
2210  info.requests.push_back(i.GetPointer());
2211  }
2212  info.request_count = static_cast<int>(info.requests.size());
2213  info.remaining_count = info.request_count;
2214  int end_serial_num =
2215  static_cast<int>(m_RequestSerialNumber.Add(info.request_count));
2216  while ( end_serial_num <= info.request_count ) {
2217  // int overflow, adjust to 1
2218  {{
2219  DEFINE_STATIC_FAST_MUTEX(sx_Mutex);
2220  CFastMutexGuard guard(sx_Mutex);
2221  int num = static_cast<int>(m_RequestSerialNumber.Get());
2222  if ( num <= info.request_count ) {
2224  }
2225  }}
2226  end_serial_num =
2227  static_cast<int>(m_RequestSerialNumber.Add(info.request_count));
2228  }
2229  info.start_serial_num = end_serial_num - info.request_count;
2230  {{
2231  int cur_serial_num = info.start_serial_num;
2233  (*it)->SetSerial_number(cur_serial_num++);
2234  }
2235  }}
2236 }
2237 
2238 
2240  CConn* conn,
2241  SId2PacketInfo& packet,
2242  const CID2_Reply& reply)
2243 {
2244  int num = reply.IsSetSerial_number()? reply.GetSerial_number() - packet.start_serial_num: -1;
2245  if ( reply.IsSetDiscard() ) {
2246  // discard whole reply for now
2247  return -1;
2248  }
2249  if ( num < 0 || num >= packet.request_count || !packet.requests[num] ) {
2250  // unknown serial num - bad reply
2251  string descr;
2252  if ( conn ) {
2253  descr = x_ConnDescription(*conn);
2254  }
2255  else {
2256  descr = " (processor)";
2257  }
2258  if ( TErrorFlags error = x_GetError(result, reply) ) {
2259  if ( error & fError_inactivity_timeout ) {
2260  if ( conn ) {
2261  conn->Restart();
2262  }
2263  NCBI_THROW_FMT(CLoaderException, eRepeatAgain,
2264  "CId2ReaderBase: connection timed out"<<descr);
2265  }
2266  if ( error & fError_bad_connection ) {
2267  NCBI_THROW_FMT(CLoaderException, eConnectionFailed,
2268  "CId2ReaderBase: connection failed"<<descr);
2269  }
2270  if ( error & fError_failed_command ) {
2271  NCBI_THROW_FMT(CLoaderException, eOtherError,
2272  "CId2ReaderBase: failed command"<<descr);
2273  }
2274  }
2275  else if ( reply.GetReply().IsEmpty() ) {
2276  ERR_POST_X(8, "CId2ReaderBase: bad reply serial number: "<<descr);
2277  return num;
2278  }
2279  NCBI_THROW_FMT(CLoaderException, eOtherError,
2280  "CId2ReaderBase: bad reply serial number: "<<descr);
2281  }
2282  return num;
2283 }
2284 
2285 
2287  int num,
2288  const CID2_Reply& reply)
2289 {
2290  if ( reply.IsSetEnd_of_reply() ) {
2291  info.requests[num] = 0;
2292  --info.remaining_count;
2293  return true;
2294  }
2295  return false;
2296 }
2297 
2298 
2300  CID2_Request_Packet& packet,
2301  const SAnnotSelector* sel)
2302 {
2303  SId2PacketInfo packet_info;
2304  x_AssignSerialNumbers(packet_info, packet);
2305 
2306  vector<SId2LoadedSet> loaded_sets(packet_info.request_count);
2307 
2309  CRef<CID2_Reply> reply;
2310  try {
2311  // send request
2312  x_SendID2Packet(result, state, packet);
2313 
2314  // process replies
2315  while ( packet_info.remaining_count > 0 ) {
2316  reply = x_ReceiveID2Reply(state);
2317  int num = x_GetReplyIndex(result, state.conn.get(), packet_info, *reply);
2318  if ( num >= 0 ) {
2319  try {
2320  x_ProcessReply(result, loaded_sets[num], *reply, *packet_info.requests[num]);
2321  }
2322  catch ( CLoaderException& /*rethrown*/ ) {
2323  throw;
2324  }
2325  catch ( CException& exc ) {
2326  NCBI_RETHROW(exc, CLoaderException, eOtherError,
2327  "CId2ReaderBase: failed to process reply: "+
2328  x_ConnDescription(state.GetConn()));
2329  }
2330  if ( x_DoneReply(packet_info, num, *reply) ) {
2331  x_UpdateLoadedSet(result, loaded_sets[num], sel);
2332  }
2333  }
2334  reply.Reset();
2335  }
2336  if ( state.conn ) {
2337  x_EndOfPacket(*state.conn);
2338  }
2339  }
2340  catch ( exception& /*rethrown*/ ) {
2341  if ( GetDebugLevel() >= eTraceError ) {
2342  CDebugPrinter s(state.GetConn(), x_GetReaderName(state.GetConn()));
2343  s << "Error processing request: " << MSerial_AsnText << packet;
2344  if ( reply &&
2345  (reply->IsSetSerial_number() ||
2346  reply->IsSetParams() ||
2347  reply->IsSetError() ||
2348  reply->IsSetEnd_of_reply() ||
2349  reply->IsSetReply()) ) {
2350  try {
2351  s << "Last reply: " << MSerial_AsnText << *reply;
2352  }
2353  catch ( exception& /*ignored*/ ) {
2354  }
2355  }
2356  }
2357  throw;
2358  }
2359  if ( state.conn ) {
2360  state.conn->Release();
2361  }
2362 }
2363 
2364 
2366  TConn /*conn*/,
2367  CID2_Reply& reply)
2368 {
2369  stream >> reply;
2370 }
2371 
2372 
2374 {
2375  // do nothing by default
2376 }
2377 
2378 
2381  const SAnnotSelector* sel)
2382 {
2384  data.m_Seq_ids ) {
2385  SetAndSaveSeq_idSeq_ids(result, it->first,
2387  it->second.second,
2388  it->second.first));
2389  }
2390  data.m_Seq_ids.clear();
2391  ITERATE ( SId2LoadedSet::TBlob_idSet, it, data.m_Blob_ids ) {
2392  CLoadLockBlobIds ids(result, it->first, sel);
2393  if ( ids.IsLoaded() ) {
2394  continue;
2395  }
2396  int state = it->second.first;
2397  TBlobIds blob_ids;
2398  ITERATE ( SId2LoadedSet::TBlob_ids, it2, it->second.second ) {
2399  CConstRef<CBlob_id> blob_id(new CBlob_id(it2->first));
2400  CBlob_Info blob_info(blob_id, it2->second.m_ContentMask);
2401  const SId2BlobInfo::TAnnotInfo& ainfos = it2->second.m_AnnotInfo;
2402  CRef<CBlob_Annot_Info> blob_annot_info;
2403  ITERATE ( SId2BlobInfo::TAnnotInfo, it3, ainfos ) {
2404  CID2S_Seq_annot_Info& annot_info = it3->GetNCObject();
2405  if ( !blob_annot_info ) {
2406  blob_annot_info = new CBlob_Annot_Info;
2407  }
2408  if ( (it2->second.m_ContentMask & fBlobHasNamedAnnot) &&
2409  annot_info.IsSetName() ) {
2410  blob_annot_info->AddNamedAnnotName(annot_info.GetName());
2411  // Heuristics to determine incorrect annot info records.
2412  if ( (annot_info.IsSetAlign() || annot_info.IsSetFeat()) &&
2413  annot_info.IsSetGraph() && ainfos.size() == 1 &&
2414  !ExtractZoomLevel(annot_info.GetName(), 0, 0) ) {
2415  // graphs are suppozed to be zoom tracks
2416  if ( GetDebugLevel() >= eTraceASN ) {
2417  CDebugPrinter s(0, x_GetReaderName(0));
2418  s << "Adding zoom tracks for "
2419  << MSerial_AsnText << annot_info;
2420  }
2421  for ( int zoom = 10; zoom < 1000000; zoom *= 10 ) {
2422  CRef<CID2S_Seq_annot_Info> zoom_info;
2423  zoom_info = SerialClone(annot_info);
2424  zoom_info->ResetFeat();
2425  zoom_info->ResetAlign();
2426  zoom_info->SetName(CombineWithZoomLevel(annot_info.GetName(), zoom));
2427  blob_annot_info->AddAnnotInfo(*zoom_info);
2428  }
2429  annot_info.ResetGraph();
2430  }
2431  }
2432 
2433  if ( annot_info.IsSetName() &&
2434  annot_info.IsSetSeq_loc() &&
2435  (annot_info.IsSetAlign() ||
2436  annot_info.IsSetGraph() ||
2437  annot_info.IsSetFeat()) ) {
2438  // complete annot info
2439  blob_annot_info->AddAnnotInfo(annot_info);
2440  }
2441  }
2442  if ( blob_annot_info &&
2443  !(blob_annot_info->GetAnnotInfo().empty() &&
2444  blob_annot_info->GetNamedAnnotNames().empty()) ) {
2445  blob_info.SetAnnotInfo(blob_annot_info);
2446  }
2447  blob_ids.push_back(blob_info);
2448  }
2449  SetAndSaveSeq_idBlob_ids(result, it->first, sel, ids,
2450  CFixedBlob_ids(eTakeOwnership, blob_ids,
2451  state));
2452  }
2453 }
2454 
2455 
2457  TErrorFlags& error_flags,
2458  EErrorFlags test_flag,
2459  const char* marker1,
2460  const char* marker2)
2461 {
2462  if ( !error.IsSetMessage() ) {
2463  // no message to parse
2464  return;
2465  }
2466  if ( error_flags & test_flag ) {
2467  // already set
2468  return;
2469  }
2470  SIZE_TYPE pos = NStr::FindNoCase(error.GetMessage(), marker1);
2471  if ( pos == NPOS) {
2472  // no marker
2473  return;
2474  }
2475  if ( marker2 &&
2476  NStr::FindNoCase(error.GetMessage(), marker2, pos) == NPOS ) {
2477  // no second marker
2478  return;
2479  }
2480  error_flags |= test_flag;
2481 }
2482 
2483 
2486  const CID2_Error& error)
2487 {
2488  TErrorFlags error_flags = 0;
2489  switch ( error.GetSeverity() ) {
2491  error_flags |= fError_warning;
2492  if ( error.IsSetMessage() ) {
2493  const string& msg = error.GetMessage();
2494  if ( msg.find("PTIS_FAILURE") != NPOS ) {
2495  EGBErrorAction action = result.GetPTISErrorAction();
2496  if ( action == eGBErrorAction_throw ) {
2497  NCBI_THROW_FMT(CLoaderException, eConnectionFailed, msg);
2498  }
2499  if ( action == eGBErrorAction_report ) {
2500  ERR_POST_X(16, Warning<<msg);
2501  }
2502  }
2503  }
2504  break;
2506  error_flags |= fError_failed_command;
2507  break;
2509  error_flags |= fError_bad_connection;
2510  if ( error.IsSetMessage() ) {
2511  sx_CheckErrorFlag(error, error_flags,
2512  fError_inactivity_timeout, "timed", "out");
2513  }
2514  break;
2516  error_flags |= fError_bad_connection;
2517  break;
2519  error_flags |= fError_no_data;
2520  break;
2522  error_flags |= fError_restricted | fError_no_data;
2523  break;
2526  error_flags |= fError_bad_command;
2527  break;
2529  error_flags |= fError_bad_command;
2530  break;
2531  }
2532  if ( error.IsSetRetry_delay() ) {
2533  result.AddRetryDelay(error.GetRetry_delay());
2534  }
2535  return error_flags;
2536 }
2537 
2538 
2541 {
2542  TErrorFlags error_flags = 0;
2543  switch ( error.GetSeverity() ) {
2545  error_flags |= fError_warning;
2546  if ( error.IsSetMessage() ) {
2547  sx_CheckErrorFlag(error, error_flags,
2548  fError_warning_dead, "obsolete");
2549  sx_CheckErrorFlag(error, error_flags,
2550  fError_suppressed_perm, "removed");
2551  sx_CheckErrorFlag(error, error_flags,
2552  fError_suppressed_perm, "suppressed");
2553  sx_CheckErrorFlag(error, error_flags,
2554  fError_suppressed_perm, "superceded"); // temp?
2555  sx_CheckErrorFlag(error, error_flags,
2556  fError_suppressed_temp, "superseded"); // perm?
2557  sx_CheckErrorFlag(error, error_flags,
2559  "Unknown satellite number 20 for bioseq info");
2560  if ( error_flags & fError_restricted ) {
2561  error_flags |= fError_no_data;
2562  }
2563  }
2564  break;
2566  error_flags |= fError_failed_command;
2567  break;
2569  error_flags |= fError_bad_connection;
2570  break;
2572  error_flags |= fError_bad_connection;
2573  break;
2575  error_flags |= fError_no_data;
2576  break;
2578  error_flags |= fError_no_data;
2579  if ( error.IsSetMessage() ) {
2580  sx_CheckErrorFlag(error, error_flags,
2581  fError_withdrawn, "withdrawn");
2582  sx_CheckErrorFlag(error, error_flags,
2583  fError_withdrawn, "removed");
2584  }
2585  if ( !(error_flags & fError_withdrawn) ) {
2586  error_flags |= fError_restricted;
2587  }
2588  break;
2591  error_flags |= fError_bad_command;
2592  break;
2594  error_flags |= fError_bad_command;
2595  break;
2596  }
2597  return error_flags;
2598 }
2599 
2600 
2603  const CID2_Reply& reply)
2604 {
2605  TErrorFlags errors = 0;
2606  if ( reply.IsSetError() ) {
2607  ITERATE ( CID2_Reply::TError, it, reply.GetError() ) {
2608  errors |= x_GetError(result, **it);
2609  }
2610  }
2611  return errors;
2612 }
2613 
2614 
2617 {
2618  TErrorFlags errors = 0;
2619  if ( reply.IsSetError() ) {
2620  ITERATE ( CID2_Reply::TError, it, reply.GetError() ) {
2621  errors |= x_GetMessageError(**it);
2622  }
2623  }
2624  return errors;
2625 }
2626 
2627 
2630  SId2LoadedSet& loaded_set,
2631  int id2_state)
2632 {
2633  TBlobState blob_state = 0;
2634  if ( id2_state & (1<<eID2_Blob_State_suppressed_temp) ) {
2636  }
2637  if ( id2_state & (1<<eID2_Blob_State_suppressed) ) {
2639  }
2640  if ( id2_state & (1<<eID2_Blob_State_dead) ) {
2641  blob_state |= CBioseq_Handle::fState_dead;
2642  }
2643  if ( id2_state & (1<<eID2_Blob_State_protected) ) {
2645  blob_state |= CBioseq_Handle::fState_no_data;
2646  }
2647  if ( id2_state & (1<<eID2_Blob_State_withdrawn) ) {
2648  blob_state |= CBioseq_Handle::fState_withdrawn;
2649  blob_state |= CBioseq_Handle::fState_no_data;
2650  }
2651  if ( blob_state ) {
2652  loaded_set.m_BlobStates[blob_id] |= blob_state;
2653  }
2654  return blob_state;
2655 }
2656 
2657 
2658 
2661  SId2LoadedSet& loaded_set,
2662  const CID2_Reply& reply,
2663  TErrorFlags* errors_ptr)
2664 {
2666  loaded_set.m_BlobStates.find(blob_id);
2667  if ( it != loaded_set.m_BlobStates.end() ) {
2668  return it->second;
2669  }
2670 
2671  TBlobState blob_state = 0;
2672  TErrorFlags errors = x_GetMessageError(reply);
2673  if ( errors_ptr ) {
2674  *errors_ptr = errors;
2675  }
2676  if ( errors & fError_no_data ) {
2677  blob_state |= CBioseq_Handle::fState_no_data;
2678  if ( errors & fError_restricted ) {
2680  }
2681  if ( errors & fError_withdrawn ) {
2682  blob_state |= CBioseq_Handle::fState_withdrawn;
2683  }
2684  }
2685  if ( errors & fError_warning_dead ) {
2686  blob_state |= CBioseq_Handle::fState_dead;
2687  }
2688  if ( errors & fError_suppressed_perm ) {
2690  }
2691  else if ( errors & fError_suppressed_temp ) {
2693  }
2694  return blob_state;
2695 }
2696 
2697 
2699  SId2LoadedSet& loaded_set,
2700  const CID2_Reply& main_reply,
2701  const CID2_Request& request)
2702 {
2703  if ( auto error = x_GetError(result, main_reply) ) {
2704  if ( error & fError_bad_connection ) {
2705  NCBI_THROW(CLoaderException, eConnectionFailed,
2706  "CId2ReaderBase: connection failed");
2707  }
2708  if ( error & fError_failed_command ) {
2709  ERR_POST_X(17, "CId2ReaderBase: failed command reply: "<<
2710  MSerial_AsnText<<main_reply<<
2711  MSerial_AsnText<<request);
2712  NCBI_THROW(CLoaderException, eOtherError,
2713  "CId2ReaderBase: failed command");
2714  }
2715  }
2716  auto& reply = main_reply.GetReply();
2717  switch ( reply.Which() ) {
2719  x_ProcessGetSeqId(result, loaded_set, main_reply,
2720  reply.GetGet_seq_id().GetRequest(),
2721  &reply.GetGet_seq_id());
2722  break;
2724  x_ProcessGetBlobId(result, loaded_set, main_reply,
2725  reply.GetGet_blob_id());
2726  break;
2728  x_ProcessGetBlobSeqIds(result, loaded_set, main_reply,
2729  reply.GetGet_blob_seq_ids());
2730  break;
2732  x_ProcessGetBlob(result, loaded_set, main_reply,
2733  reply.GetGet_blob());
2734  break;
2736  x_ProcessGetSplitInfo(result, loaded_set, main_reply,
2737  reply.GetGet_split_info());
2738  break;
2740  x_ProcessGetChunk(result, loaded_set, main_reply,
2741  reply.GetGet_chunk());
2742  break;
2744  x_ProcessEmptyReply(result, loaded_set, main_reply, request);
2745  break;
2746  default:
2747  break;
2748  }
2749 }
2750 
2751 
2753  SId2LoadedSet& loaded_set,
2754  const CID2_Reply& main_reply,
2755  const CID2_Request& main_request)
2756 {
2757  TErrorFlags errors = x_GetMessageError(main_reply);
2758  if ( errors & fError_no_data ) {
2759  auto& request = main_request.GetRequest();
2760  switch ( request.Which() ) {
2762  x_ProcessGetSeqId(result, loaded_set, main_reply, request.GetGet_seq_id(), 0);
2763  break;
2765  if ( request.GetGet_blob_id().IsSetSeq_id() ) {
2766  auto& req_id = request.GetGet_blob_id().GetSeq_id().GetSeq_id();
2767  if ( req_id.IsSeq_id() ) {
2769  return;
2770  }
2771  }
2772  break;
2774  if ( request.GetGet_blob_info().GetBlob_id().IsResolve() ) {
2775  auto& req_id = request.GetGet_blob_info().GetBlob_id().GetResolve().GetRequest().GetSeq_id().GetSeq_id();
2776  if ( req_id.IsSeq_id() ) {
2778  return;
2779  }
2780  }
2781  break;
2782  default:
2783  break;
2784  }
2785  }
2786 }
2787 
2788 
2790  SId2LoadedSet& loaded_set,
2791  const CID2_Reply& main_reply,
2792  const CID2_Request_Get_Seq_id& request,
2793  const CID2_Reply_Get_Seq_id* reply)
2794 {
2795  // we can save this data in cache
2796  const CID2_Seq_id& req_id = request.GetSeq_id();
2797  switch ( req_id.Which() ) {
2798  case CID2_Seq_id::e_Seq_id:
2799  x_ProcessGetSeqIdSeqId(result, loaded_set, main_reply,
2801  request, reply);
2802  break;
2803 
2804  default:
2805  break;
2806  }
2807 }
2808 
2809 
2810 static bool sx_IsSpecialId(const CSeq_id& id)
2811 {
2812  if ( !id.IsGeneral() ) {
2813  return false;
2814  }
2815  const string& db = id.GetGeneral().GetDb();
2816  return db == kSpecialId_length || db == kSpecialId_type;
2817 }
2818 
2819 
2822  SId2LoadedSet& loaded_set,
2823  const CID2_Reply& main_reply,
2824  const CSeq_id_Handle& seq_id,
2825  const CID2_Request_Get_Seq_id& req,
2826  const CID2_Reply_Get_Seq_id* reply)
2827 {
2828  int state = 0;
2829  TErrorFlags errors = x_GetMessageError(main_reply);
2830  if ( (errors & fError_no_data) &&
2831  (req.GetSeq_id_type() == req.eSeq_id_type_any ||
2832  (req.GetSeq_id_type()&req.eSeq_id_type_all)==req.eSeq_id_type_all) ) {
2834  // no Seq-ids
2835  if ( errors & fError_restricted ) {
2837  }
2838  if ( errors & fError_withdrawn ) {
2840  }
2842 
2843  if ( req.GetSeq_id_type() & req.eSeq_id_type_gi ) {
2845  }
2846  if ( req.GetSeq_id_type() & req.eSeq_id_type_text ) {
2848  }
2849  if ( req.GetSeq_id_type() & req.eSeq_id_type_label ) {
2850  SetAndSaveSeq_idLabel(result, seq_id, "");
2851  }
2852  if ( req.GetSeq_id_type() & req.eSeq_id_type_taxid ) {
2854  }
2855  if ( req.GetSeq_id_type() & req.eSeq_id_type_hash ) {
2857  }
2858  if ( req.GetSeq_id_type() & req.eSeq_id_type_seq_length ) {
2860  }
2861  if ( req.GetSeq_id_type() & req.eSeq_id_type_seq_mol ) {
2863  }
2864  return;
2865  }
2866  bool got_no_ids = false;
2867  if ( (req.GetSeq_id_type()&req.eSeq_id_type_all)==req.eSeq_id_type_all ) {
2868  CReader::TSeqIds seq_ids;
2869  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2870  if ( req.GetSeq_id_type() != req.eSeq_id_type_all &&
2871  sx_IsSpecialId(**it) ) {
2872  continue;
2873  }
2874  seq_ids.push_back(CSeq_id_Handle::GetHandle(**it));
2875  }
2876  if ( !reply || reply->IsSetEnd_of_reply() ) {
2877  got_no_ids = seq_ids.empty();
2880  seq_ids,
2881  state));
2882  }
2883  else {
2884  loaded_set.m_Seq_ids[seq_id].first = state;
2885  loaded_set.m_Seq_ids[seq_id].second.swap(seq_ids);
2886  }
2887  }
2888  if ( req.GetSeq_id_type() & req.eSeq_id_type_gi ) {
2889  TSequenceGi ret;
2890  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2891  if ( (**it).IsGi() ) {
2892  ret.gi = (**it).GetGi();
2893  break;
2894  }
2895  }
2896  ret.sequence_found = !got_no_ids;
2897  SetAndSaveSeq_idGi(result, seq_id, ret);
2898  }
2899  if ( req.GetSeq_id_type() & req.eSeq_id_type_text ) {
2900  TSequenceAcc ret;
2901  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2902  if ( (**it).GetTextseq_Id() ) {
2903  ret.acc_ver = CSeq_id_Handle::GetHandle(**it);
2904  break;
2905  }
2906  }
2907  ret.sequence_found = !got_no_ids;
2908  SetAndSaveSeq_idAccVer(result, seq_id, ret);
2909  }
2910  if ( req.GetSeq_id_type() & req.eSeq_id_type_label ) {
2911  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2912  const CSeq_id& id = **it;
2913  if ( id.IsGeneral() ) {
2914  const CDbtag& dbtag = id.GetGeneral();
2915  const CObject_id& obj_id = dbtag.GetTag();
2916  if ( obj_id.IsStr() && dbtag.GetDb() == kSpecialId_label ) {
2917  SetAndSaveSeq_idLabel(result, seq_id, obj_id.GetStr());
2918  break;
2919  }
2920  }
2921  }
2922  }
2923  if ( req.GetSeq_id_type() & req.eSeq_id_type_taxid ) {
2924  TTaxId taxid = INVALID_TAX_ID;
2925  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2926  const CSeq_id& id = **it;
2927  if ( id.IsGeneral() ) {
2928  const CDbtag& dbtag = id.GetGeneral();
2929  const CObject_id& obj_id = dbtag.GetTag();
2930  if ( obj_id.IsId() && dbtag.GetDb() == kSpecialId_taxid ) {
2931  taxid = TAX_ID_FROM(CObject_id::TId, obj_id.GetId());
2932  break;
2933  }
2934  }
2935  }
2936  if ( taxid != INVALID_TAX_ID ) {
2937  SetAndSaveSeq_idTaxId(result, seq_id, taxid);
2938  }
2939  }
2940  if ( req.GetSeq_id_type() & req.eSeq_id_type_hash ) {
2942  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2943  const CSeq_id& id = **it;
2944  if ( id.IsGeneral() ) {
2945  const CDbtag& dbtag = id.GetGeneral();
2946  const CObject_id& obj_id = dbtag.GetTag();
2947  if ( obj_id.IsId() && dbtag.GetDb() == kSpecialId_hash ) {
2948  hash.hash = obj_id.GetId();
2949  hash.sequence_found = true;
2950  hash.hash_known = true;
2951  break;
2952  }
2953  }
2954  }
2956  }
2957  if ( req.GetSeq_id_type() & req.eSeq_id_type_seq_length ) {
2958  TSeqPos length = kInvalidSeqPos;
2959  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2960  const CSeq_id& id = **it;
2961  if ( id.IsGeneral() ) {
2962  const CDbtag& dbtag = id.GetGeneral();
2963  const CObject_id& obj_id = dbtag.GetTag();
2964  if ( obj_id.IsId() && dbtag.GetDb() == kSpecialId_length ) {
2965  length = TSeqPos(obj_id.GetId());
2966  break;
2967  }
2968  }
2969  }
2970  if ( length != kInvalidSeqPos || got_no_ids ) {
2971  SetAndSaveSequenceLength(result, seq_id, length);
2972  }
2973  }
2974  if ( req.GetSeq_id_type() & req.eSeq_id_type_seq_mol ) {
2976  if ( reply ) ITERATE ( CID2_Reply_Get_Seq_id::TSeq_id, it, reply->GetSeq_id() ) {
2977  const CSeq_id& id = **it;
2978  if ( id.IsGeneral() ) {
2979  const CDbtag& dbtag = id.GetGeneral();
2980  const CObject_id& obj_id = dbtag.GetTag();
2981  if ( obj_id.IsId() && dbtag.GetDb() == kSpecialId_type ) {
2982  type.type = CSeq_inst::EMol(obj_id.GetId());
2983  type.sequence_found = true;
2984  break;
2985  }
2986  }
2987  }
2988  if ( type.sequence_found || got_no_ids ) {
2990  }
2991  }
2992 }
2993 
2994 
2997  SId2LoadedSet& loaded_set,
2998  const CID2_Reply& main_reply,
2999  const CID2_Reply_Get_Blob_Id& reply)
3000 {
3001  const CSeq_id& seq_id = reply.GetSeq_id();
3003  const CID2_Blob_Id& src_blob_id = reply.GetBlob_id();
3004  CBlob_id blob_id = GetBlobId(src_blob_id);
3005  TErrorFlags errors = 0;
3006  TBlobState blob_state;
3007  if ( reply.IsSetBlob_state() ) {
3008  blob_state = x_GetBlobStateFromID2(blob_id, loaded_set,
3009  reply.GetBlob_state());
3010  }
3011  else {
3012  blob_state = x_GetBlobState(blob_id, loaded_set, main_reply, &errors);
3013  }
3014  if ( blob_state & CBioseq_Handle::fState_no_data ) {
3015  SetAndSaveNoSeq_idBlob_ids(result, idh, 0, blob_state);
3016  return;
3017  }
3018  if ( (blob_state == 0) && (errors & fError_warning) ) {
3019  blob_state |= CBioseq_Handle::fState_other_error;
3020  }
3021 
3022  SId2LoadedSet::TBlob_idsInfo& ids = loaded_set.m_Blob_ids[idh];
3023  ids.first |= blob_state;
3024  if ( blob_state ) {
3025  loaded_set.m_BlobStates[blob_id] |= blob_state;
3026  }
3027  TContentsMask mask = 0;
3028  {{ // TODO: temporary logic, this info should be returned by server
3029  if ( (blob_id.GetSubSat() == CID2_Blob_Id::eSub_sat_main && !reply.IsSetAnnot_info()) ||
3033  }
3034  else {
3035  if ( seq_id.IsGeneral() ) {
3036  const CObject_id& obj_id = seq_id.GetGeneral().GetTag();
3037  if ( obj_id.IsId() &&
3038  obj_id.GetId8() == Uint4(blob_id.GetSatKey()) ) {
3040  }
3041  else {
3043  }
3044  }
3045  else {
3047  }
3048  }
3049  }}
3050  SId2BlobInfo& blob_info = ids.second[blob_id];
3051  if ( reply.IsSetAnnot_info() && mask == fBlobHasExtAnnot ) {
3052  blob_info.m_AnnotInfo = reply.GetAnnot_info();
3053  ITERATE ( SId2BlobInfo::TAnnotInfo, it, blob_info.m_AnnotInfo ) {
3054  const CID2S_Seq_annot_Info& info = **it;
3055  if ( info.IsSetName() && NStr::StartsWith(info.GetName(), "NA") ) {
3057  if ( info.IsSetFeat() ) {
3059  }
3060  if ( info.IsSetGraph() ) {
3062  }
3063  if ( info.IsSetAlign() ) {
3065  }
3066  }
3067  }
3068  }
3069  blob_info.m_ContentMask = mask;
3070  if ( src_blob_id.IsSetVersion() && src_blob_id.GetVersion() > 0 ) {
3071  SetAndSaveBlobVersion(result, blob_id, src_blob_id.GetVersion());
3072  }
3073 }
3074 
3075 
3077  CReaderRequestResult& /* result */,
3078  SId2LoadedSet& /*loaded_set*/,
3079  const CID2_Reply& /*main_reply*/,
3080  const CID2_Reply_Get_Blob_Seq_ids&/*reply*/)
3081 {
3082 /*
3083  if ( reply.IsSetIds() ) {
3084  CID2_Blob_Seq_ids ids;
3085  x_ReadData(reply.GetIds(), Begin(ids));
3086  ITERATE ( CID2_Blob_Seq_ids::Tdata, it, ids.Get() ) {
3087  if ( !(*it)->IsSetReplaced() ) {
3088  result.AddBlob_id((*it)->GetSeq_id(),
3089  GetBlobId(reply.GetBlob_id()), "");
3090  }
3091  }
3092  }
3093 */
3094 }
3095 
3096 
3099  SId2LoadedSet& loaded_set,
3100  const CID2_Reply& main_reply,
3101  const CID2_Reply_Get_Blob& reply)
3102 {
3103  TChunkId chunk_id = kMain_ChunkId;
3104  const CID2_Blob_Id& src_blob_id = reply.GetBlob_id();
3105  TBlobId blob_id = GetBlobId(src_blob_id);
3106 
3107  TBlobVersion blob_version = 0;
3108  if ( src_blob_id.IsSetVersion() && src_blob_id.GetVersion() > 0 ) {
3109  blob_version = src_blob_id.GetVersion();
3110  SetAndSaveBlobVersion(result, blob_id, blob_version);
3111  }
3112 
3113  TBlobState blob_state;
3114  if ( reply.IsSetBlob_state() ) {
3115  blob_state = x_GetBlobStateFromID2(blob_id, loaded_set,
3116  reply.GetBlob_state());
3117  }
3118  else {
3119  blob_state = x_GetBlobState(blob_id, loaded_set, main_reply);
3120  }
3121  if ( blob_state & CBioseq_Handle::fState_no_data ) {
3122  SetAndSaveNoBlob(result, blob_id, chunk_id, blob_state);
3123  return;
3124  }
3125 
3126  if ( !blob_version ) {
3127  CLoadLockBlobVersion lock(result, blob_id);
3128  if ( !lock.IsLoadedBlobVersion() ) {
3129  // need some reference blob version to work with
3130  // but not save it into cache
3131  SetAndSaveBlobVersion(result, blob_id, 0);
3132  //state.SetLoadedBlobVersion(0);
3133  }
3134  }
3135 
3136  if ( !reply.IsSetData() ) {
3137  // assume only blob info reply
3138  if ( blob_state ) {
3139  loaded_set.m_BlobStates[blob_id] |= blob_state;
3140  }
3141  return;
3142  }
3143 
3144  const CID2_Reply_Data& data = reply.GetData();
3145  if ( data.GetData().empty() ) {
3146  if ( reply.GetSplit_version() != 0 &&
3147  data.GetData_type() == data.eData_type_seq_entry ) {
3148  // Skeleton Seq-entry could be attached to the split-info
3149  ERR_POST_X(6, Warning << "CId2ReaderBase: ID2-Reply-Get-Blob: "
3150  "no data in reply: "<<blob_id);
3151  return;
3152  }
3153  ERR_POST_X(7, "CId2ReaderBase: ID2-Reply-Get-Blob: "
3154  "no data in reply: "<<blob_id);
3155  SetAndSaveNoBlob(result, blob_id, chunk_id, blob_state);
3156  return;
3157  }
3158 
3159  if ( reply.GetSplit_version() != 0 ) {
3160  // split info will follow
3161  // postpone parsing this blob
3162  loaded_set.m_Skeletons[blob_id] = &data;
3163  return;
3164  }
3165 
3166  CLoadLockBlob blob(result, blob_id);
3167  if ( blob.IsLoadedBlob() ) {
3168  if ( blob.NeedsDelayedMainChunk() ) {
3169  chunk_id = kDelayedMain_ChunkId;
3170  blob.SelectChunk(chunk_id);
3171  }
3172  if ( blob.IsLoadedChunk() ) {
3174  ERR_POST_X(4, Info << "CId2ReaderBase: ID2-Reply-Get-Blob: "
3175  "blob already loaded: "<<blob_id);
3176  return;
3177  }
3178  }
3179 
3180  if ( blob_state ) {
3181  result.SetAndSaveBlobState(blob_id, blob_state);
3182  }
3183 
3184  if ( reply.GetBlob_id().GetSub_sat() == CID2_Blob_Id::eSub_sat_snp ) {
3186  .ProcessBlobFromID2Data(result, blob_id, chunk_id, data);
3187  }
3188  else {
3189  dynamic_cast<const CProcessor_ID2&>
3191  .ProcessData(result, blob_id, blob_state, chunk_id, data);
3192  }
3193  _ASSERT(blob.IsLoadedChunk());
3194 }
3195 
3196 
3199  SId2LoadedSet& loaded_set,
3200  const CID2_Reply& main_reply,
3201  const CID2S_Reply_Get_Split_Info& reply)
3202 {
3203  TChunkId chunk_id = kMain_ChunkId;
3204  const CID2_Blob_Id& src_blob_id = reply.GetBlob_id();
3205  TBlobId blob_id = GetBlobId(src_blob_id);
3206  TBlobVersion blob_version = 0;
3207  if ( src_blob_id.IsSetVersion() && src_blob_id.GetVersion() > 0 ) {
3208  blob_version = src_blob_id.GetVersion();
3209  SetAndSaveBlobVersion(result, blob_id, blob_version);
3210  }
3211  if ( !reply.IsSetData() ) {
3212  ERR_POST_X(11, "CId2ReaderBase: ID2S-Reply-Get-Split-Info: "
3213  "no data in reply: "<<blob_id);
3214  return;
3215  }
3216 
3217  if ( !blob_version ) {
3218  CLoadLockBlobVersion lock(result, blob_id);
3219  if ( !lock.IsLoadedBlobVersion() ) {
3220  // need some reference blob version to work with
3221  // but not save it into cache
3222  SetAndSaveBlobVersion(result, blob_id, 0);
3223  //state.SetLoadedBlobVersion(0);
3224  }
3225  }
3226 
3227  CLoadLockBlob blob(result, blob_id);
3228  if ( blob.IsLoadedBlob() ) {
3229  if ( blob.NeedsDelayedMainChunk() ) {
3230  chunk_id = kDelayedMain_ChunkId;
3231  blob.SelectChunk(chunk_id);
3232  }
3233  if ( blob.IsLoadedChunk() ) {
3235  ERR_POST_X(10, Info<<"CId2ReaderBase: ID2S-Reply-Get-Split-Info: "
3236  "blob already loaded: " << blob_id);
3237  return;
3238  }
3239  }
3240 
3241  TBlobState blob_state;
3242  if ( reply.IsSetBlob_state() ) {
3243  blob_state = x_GetBlobStateFromID2(blob_id, loaded_set,
3244  reply.GetBlob_state());
3245  }
3246  else {
3247  blob_state = x_GetBlobState(blob_id, loaded_set, main_reply);
3248  }
3249  if ( blob_state & CBioseq_Handle::fState_no_data ) {
3250  SetAndSaveNoBlob(result, blob_id, chunk_id, blob_state);
3251  return;
3252  }
3253 
3255  {{
3257  loaded_set.m_Skeletons.find(blob_id);
3258  if ( iter != loaded_set.m_Skeletons.end() ) {
3259  skel = iter->second;
3260  }
3261  }}
3262 
3263  if ( blob_state ) {
3264  result.SetAndSaveBlobState(blob_id, blob_state);
3265  }
3266 
3267  dynamic_cast<const CProcessor_ID2&>
3269  .ProcessData(result, blob_id, blob_state, chunk_id,
3270  reply.GetData(), reply.GetSplit_version(), skel);
3271 
3272  _ASSERT(blob.IsLoadedChunk());
3273  loaded_set.m_Skeletons.erase(blob_id);
3274 }
3275 
3276 
3279  SId2LoadedSet& /*loaded_set*/,
3280  const CID2_Reply& /*main_reply*/,
3281  const CID2S_Reply_Get_Chunk& reply)
3282 {
3283  TBlobId blob_id = GetBlobId(reply.GetBlob_id());
3284  if ( !reply.IsSetData() ) {
3285  ERR_POST_X(14, "CId2ReaderBase: ID2S-Reply-Get-Chunk: "
3286  "no data in reply: "<<blob_id);
3287  return;
3288  }
3289 
3290  if ( !CLoadLockBlob(result, blob_id).IsLoadedBlob() ) {
3291  ERR_POST_X(13, "CId2ReaderBase: ID2S-Reply-Get-Chunk: "
3292  "blob is not loaded yet: " << blob_id);
3293  return;
3294  }
3295 
3296  dynamic_cast<const CProcessor_ID2&>
3298  .ProcessData(result, blob_id, 0, reply.GetChunk_id(), reply.GetData());
3299 }
3300 
3301 
3302 /////////////////////////////////////////////////////////////////////////////
3303 /////////////////////////////////////////////////////////////////////////////
3304 /////////////////////////////////////////////////////////////////////////////
3305 
3306 
ncbi::TMaskedQueryRegions mask
void SetAnnotInfo(CRef< CBlob_Annot_Info > &annot_info)
void SetSubSat(TSubSat v)
Definition: blob_id.hpp:109
TSat GetSat() const
Definition: blob_id.hpp:56
TSatKey GetSatKey() const
Definition: blob_id.hpp:64
void SetSatKey(TSatKey v)
Definition: blob_id.hpp:113
TSubSat GetSubSat() const
Definition: blob_id.hpp:60
void SetSat(TSat v)
Definition: blob_id.hpp:105
Definition: Dbtag.hpp:53
vector< CRef< CID2_Reply > > TReplies
CID2S_Chunk_Id –.
CID2S_Reply_Get_Chunk –.
CID2S_Reply_Get_Split_Info –.
CID2S_Request_Get_Chunks –.
CID2S_Seq_annot_Info –.
CID2_Blob_Id –.
Definition: ID2_Blob_Id.hpp:66
CID2_Error –.
Definition: ID2_Error.hpp:66
CID2_Get_Blob_Details –.
CID2_Param –.
Definition: ID2_Param.hpp:66
CID2_Reply_Get_Blob_Id –.
CID2_Reply_Get_Blob_Seq_ids –.
CID2_Reply_Get_Blob –.
CID2_Reply_Get_Seq_id –.
CID2_Reply –.
Definition: ID2_Reply.hpp:66
CID2_Request_Get_Blob_Id –.
CID2_Request_Get_Blob_Info –.
CID2_Request_Get_Seq_id –.
CID2_Request_Packet –.
CID2_Request –.
Definition: ID2_Request.hpp:66
CID2_Seq_id –.
Definition: ID2_Seq_id.hpp:66
virtual void x_ReceiveReply(TConn conn, CID2_Reply &reply)=0
TBlobState x_GetBlobStateFromID2(const CBlob_id &blob_id, SId2LoadedSet &loaded_set, int id2_state)
bool LoadLabels(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLabels &ret)
void x_SetResolve(CID2_Request_Get_Blob_Id &get_blob_id, const CSeq_id &seq_id)
void x_SendID2Packet(CReaderRequestResult &result, SId2ProcessingState &state, CID2_Request_Packet &packet)
static void SetVDB_CDD_Enabled(bool enabled=true)
bool LoadHashes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, THashes &ret, TKnown &known)
bool LoadSeq_idLabel(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
static bool GetVDB_SNP_Enabled()
bool LoadSeq_idTaxId(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
bool LoadChunk(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id)
void x_AssignSerialNumbers(SId2PacketInfo &info, CID2_Request_Packet &packet)
TProcessors m_Processors
bool LoadBulkIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TBulkIds &ret)
bool LoadTaxIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTaxIds &ret)
bool LoadChunks(CReaderRequestResult &result, const TBlobId &blob_id, const TChunkIds &chunk_ids)
bool x_LoadSeq_idBlob_idsSet(CReaderRequestResult &result, const TSeqIds &seq_ids)
static TBlobId GetBlobId(const CID2_Blob_Id &blob_id)
bool LoadSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
bool LoadLengths(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TLengths &ret)
void x_ProcessGetBlobSeqIds(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2_Reply_Get_Blob_Seq_ids &reply)
virtual void x_SendPacket(TConn conn, const CID2_Request_Packet &packet)=0
TErrorFlags x_GetMessageError(const CID2_Error &error)
void x_SetContextData(CID2_Request &request)
TErrorFlags x_GetError(CReaderRequestResult &result, const CID2_Error &error)
void x_ProcessGetChunk(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2S_Reply_Get_Chunk &reply)
bool LoadAccVers(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TIds &ret)
bool LoadTypes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTypes &ret)
bool LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
bool x_DoneReply(SId2PacketInfo &info, int num, const CID2_Reply &reply)
atomic< TAvoidRequests > m_AvoidRequest
void x_ProcessGetSplitInfo(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2S_Reply_Get_Split_Info &reply)
static bool GetVDB_CDD_Enabled()
bool LoadBlobVersion(CReaderRequestResult &result, const TBlobId &blob_id)
static int GetDebugLevel(void)
TBlobState x_GetBlobState(const CBlob_id &blob_id, SId2LoadedSet &loaded_set, const CID2_Reply &reply, TErrorFlags *errors_ptr=0)
void x_DumpPacket(TConn conn, const CID2_Request_Packet &packet, const char *msg="Sending")
void x_ProcessGetBlob(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2_Reply_Get_Blob &reply)
static void SetSNP_Scale_Limit(CSeq_id::ESNPScaleLimit value)
void x_ProcessGetSeqId(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2_Request_Get_Seq_id &request, const CID2_Reply_Get_Seq_id *reply)
static void SetVDB_SNP_Enabled(bool enabled=true)
void x_SetExclude_blobs(CID2_Request_Get_Blob_Info &get_blob_info, const CSeq_id_Handle &idh, CReaderRequestResult &result)
void x_UpdateLoadedSet(CReaderRequestResult &result, SId2LoadedSet &data, const SAnnotSelector *sel)
void x_SetDetails(CID2_Get_Blob_Details &details, TContentsMask mask)
bool LoadBlobSet(CReaderRequestResult &result, const TSeqIds &seq_ids)
CRef< CID2_Reply > x_ReceiveID2ReplyStage(SId2ProcessingState &state, size_t pos)
void x_ProcessRequest(CReaderRequestResult &result, CID2_Request &req, const SAnnotSelector *sel)
virtual void SetParams(const CReaderParams &params)
void x_ProcessEmptyReply(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2_Request &main_request)
void x_DumpReply(TConn conn, CID2_Reply &reply, const char *msg="Received")
bool LoadBlobState(CReaderRequestResult &result, const TBlobId &blob_id)
virtual string x_ConnDescription(TConn conn) const =0
bool LoadSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
bool LoadSeq_idSeq_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
CRef< CID2_Reply > x_ReceiveFromConnection(TConn conn)
virtual void x_EndOfPacket(TConn conn)
static void sx_CheckErrorFlag(const CID2_Error &error, TErrorFlags &error_flags, EErrorFlags test_flag, const char *marker1, const char *marker2=0)
CRef< CID2_Reply > x_ReceiveID2Reply(SId2ProcessingState &state)
CAtomicCounter_WithAutoInit m_RequestSerialNumber
static void SetVDB_WGS_Enabled(bool enabled=true)
bool LoadSequenceLength(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
static bool GetVDB_WGS_Enabled()
void x_ProcessGetBlobId(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2_Reply_Get_Blob_Id &reply)
void x_ProcessReply(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CID2_Request &main_request)
bool LoadGis(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TGis &ret)
void x_ProcessPacket(CReaderRequestResult &result, CID2_Request_Packet &packet, const SAnnotSelector *sel)
void x_ProcessGetSeqIdSeqId(CReaderRequestResult &result, SId2LoadedSet &loaded_set, const CID2_Reply &main_reply, const CSeq_id_Handle &seq_id, const CID2_Request_Get_Seq_id &request, const CID2_Reply_Get_Seq_id *reply)
int x_GetReplyIndex(CReaderRequestResult &result, CConn *conn, SId2PacketInfo &packet, const CID2_Reply &reply)
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.
bool LoadStates(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TStates &ret)
bool LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
bool LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
static CSeq_id::ESNPScaleLimit GetSNP_Scale_Limit(void)
bool LoadBlob(CReaderRequestResult &result, const TBlobId &blob_id)
void x_SendToConnection(TConn conn, CID2_Request_Packet &packet)
static bool IsFound(const TData &data)
TData GetAccVer(void) const
static const CSeq_id_Handle & GetAcc(const TData &data)
bool IsLoadedAccVer(void) const
TData GetBlob_ids(void) const
bool IsLoadedBlobState(void) const
bool IsLoadedBlobVersion(void) const
void SelectChunk(TChunkId chunk_id)
bool NeedsDelayedMainChunk(void) const
bool IsLoadedChunk(void) const
const CTSE_Split_Info & GetSplitInfo(void) const
bool IsLoadedBlob(void) const
TBlobVersion GetKnownBlobVersion(void) const
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
bool SetLoadedLabel(const TData &data)
TData GetLabel(void) const
TData GetLength(void) const
bool IsLoadedLength(void) const
TData GetSeq_ids(void) const
void SetLoaded(void)
bool IsLoaded(void) const
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.
CObjectIStream –.
Definition: objistr.hpp:93
TId8 GetId8(void) const
Definition: Object_id.cpp:164
static TPluginManager * Get(void)
static void LoadBlob(CReaderRequestResult &result, const CBlob_Info &blob_info)
static bool IsExtAnnot(const TBlobId &blob_id)
static void DumpDataAsText(const CID2_Reply_Data &data, CNcbiOstream &out)
static void OffsetAllGisToOM(CBeginInfo obj, CTSE_SetObjectInfo *set_info=0)
Definition: processors.cpp:590
@ eType_ExtAnnot
Definition: processor.hpp:81
@ eType_Seq_entry_SNP
Definition: processor.hpp:72
void ProcessBlobFromID2Data(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, const CID2_Reply_Data &data) const
Definition: processors.cpp:262
static void OffsetAllGisFromOM(CBeginInfo obj)
Definition: processors.cpp:584
const CProcessor & GetProcessor(CProcessor::EType type) const
Definition: dispatcher.cpp:219
static bool SetBlobState(size_t i, CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TStates &ret)
CWriter * GetWriter(const CReaderRequestResult &result, CWriter::EType type) const
Definition: dispatcher.cpp:204
static bool CannotProcess(const CSeq_id_Handle &sih)
Definition: dispatcher.cpp:261
bool GetEnableSNP(void) const
Definition: reader.hpp:57
bool GetEnableCDD(void) const
Definition: reader.hpp:67
bool GetEnableWGS(void) const
Definition: reader.hpp:62
bool IsSetEnableCDD(void) const
Definition: reader.hpp:66
bool IsSetEnableSNP(void) const
Definition: reader.hpp:56
bool IsSetEnableWGS(void) const
Definition: reader.hpp:61
vector< CBlob_id > TLoadedBlob_ids
CDataLoader::STypeFound TSequenceType
Definition: reader.hpp:194
vector< CSeq_id_Handle > TSeqIds
Definition: reader.hpp:96
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
vector< TIds > TBulkIds
Definition: reader.hpp:125
CReaderAllocatedConnection CConn
Definition: reader.hpp:355
void SetAndSaveNoSeq_idBlob_ids(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const SAnnotSelector *sel, const CLoadLockGi &gi_lock) const
Definition: reader.cpp:1206
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 bool LoadTypes(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTypes &ret)
Definition: reader.cpp:822
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
int TBlobVersion
Definition: reader.hpp:91
vector< CBlob_Info > TBlobIds
Definition: reader.hpp:97
vector< int > TStates
Definition: reader.hpp:129
virtual bool LoadTaxIds(CReaderRequestResult &result, const TIds &ids, TLoaded &loaded, TTaxIds &ret)
Definition: reader.cpp:754
void SetAndSaveNoBlob(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, TBlobState blob_state)
Definition: reader.cpp:1065
virtual bool LoadSequenceType(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:628
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
unsigned TConn
Definition: reader.hpp:87
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
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
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
vector< CSeq_inst::EMol > TTypes
Definition: reader.hpp:133
vector< int > THashes
Definition: reader.hpp:130
virtual bool LoadSeq_idGi(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:490
vector< CSeq_id_Handle > TIds
Definition: reader.hpp:123
CDataLoader::SAccVerFound TSequenceAcc
Definition: reader.hpp:192
virtual bool LoadSeq_idAccVer(CReaderRequestResult &result, const CSeq_id_Handle &seq_id)
Definition: reader.cpp:509
CDataLoader::SHashFound TSequenceHash
Definition: reader.hpp:195
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
void SetAndSaveSequenceHash(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, const TSequenceHash &hash) const
Definition: reader.cpp:1285
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
int TContentsMask
Definition: reader.hpp:94
int TBlobState
Definition: reader.hpp:90
vector< TTaxId > TTaxIds
Definition: reader.hpp:128
virtual bool LoadBlobs(CReaderRequestResult &result, const CSeq_id_Handle &seq_id, TContentsMask mask, const SAnnotSelector *sel)
Definition: reader.cpp:903
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
CDataLoader::SGiFound TSequenceGi
Definition: reader.hpp:193
vector< bool > TKnown
Definition: reader.hpp:131
CSafeStatic<>::
TSplitVersion GetSplitVersion(void) const
Template class for iteration on objects of class C (non-medifiable version)
Definition: iterator.hpp:767
Template class for iteration on objects of class C.
Definition: iterator.hpp:673
@ eBlobWriter
Definition: writer.hpp:65
void erase(iterator pos)
Definition: map.hpp:167
container_type::const_iterator const_iterator
Definition: map.hpp:53
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
void swap(this_type &m)
Definition: map.hpp:118
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
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
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
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 TAX_ID_FROM(T, value)
Definition: ncbimisc.hpp:1111
@ eTakeOwnership
An object can take ownership of another.
Definition: ncbi_types.h:136
void Set(TValue new_value) THROWS_NONE
Set atomic counter value.
Definition: ncbicntr.hpp:185
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
Definition: ncbicntr.hpp:278
TValue Get(void) const THROWS_NONE
Get atomic counter value.
Definition: ncbicntr.hpp:168
CDiagContext & GetDiagContext(void)
Get diag context instance.
Definition: logging.cpp:818
string GetSessionID(void) const
Session ID.
const string & GetNextSubHitID(CTempString prefix=CTempString())
Get current hit id appended with auto-incremented sub-hit id.
bool IsSetSessionID(void) const
static CRequestContext & GetRequestContext(void)
Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()
Definition: ncbidiag.cpp:1901
string GetClientIP(void) const
Client IP/hostname.
bool IsSetHitID(EHitIDSource src=eHitID_Any) const
Check if there's an explicit hit id or the default one.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
bool IsSetClientIP(void) const
#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
#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
C * SerialClone(const C &src)
Create on heap a clone of the source object.
Definition: serialbase.hpp:512
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
CConstRef< CSeq_id > GetSeqId(void) const
static const char * GetSNPScaleLimit_Name(ESNPScaleLimit value)
Definition: Seq_id.cpp:3549
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
ESNPScaleLimit
SNP annotation scale limits.
Definition: Seq_id.hpp:847
@ eSNPScaleLimit_Default
Definition: Seq_id.hpp:848
CBeginInfo Begin(C &obj)
Get starting point of object hierarchy.
Definition: iterator.hpp:1004
bool IsIncludedAnyNamedAnnotAccession(void) const
check if any named annot accession is included in the search
string CombineWithZoomLevel(const string &acc, int zoom_level)
Combine accession string and zoom level into a string with separator.
TSNPScaleLimit GetSNPScaleLimit(void) const
bool ExtractZoomLevel(const string &full_name, string *acc_ptr, int *zoom_level_ptr)
Extract optional zoom level suffix from named annotation string.
const TNamedAnnotAccessions & GetNamedAnnotAccessions(void) const
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#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
#define NcbiCout
Definition: ncbistre.hpp:543
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
#define NPOS
Definition: ncbistr.hpp:133
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
virtual void Process(SOCK sock)=0
Runs asynchronously (from a separate thread) for each request.
#define DEFINE_STATIC_FAST_MUTEX(id)
Define static fast mutex and initialize it.
Definition: ncbimtx.hpp:496
static const char label[]
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
bool IsId(void) const
Check if variant Id is selected.
Definition: Object_id_.hpp:264
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
bool IsSetAnnot_info(void) const
annotation types in this blob annotation are unknown if this field is omitted Check if a value has be...
TVersion GetVersion(void) const
Get the Version member data.
TSat_key GetSat_key(void) const
Get the Sat_key member data.
const TError & GetError(void) const
Get the Error member data.
Definition: ID2_Reply_.hpp:891
void SetBlob_id(TBlob_id &value)
Assign a value to Blob_id data member.
bool IsSetBlob_state(void) const
state bits of the blob, 0 or missing means regular live data Check if a value has been assigned to Bl...
void SetSplit_version(TSplit_version value)
Assign a value to Split_version data member.
bool IsSetBlob_state(void) const
state bits of the blob, 0 or missing means regular live data Check if a value has been assigned to Bl...
TSeq_id_type GetSeq_id_type(void) const
Get the Seq_id_type member data.
TChunks & SetChunks(void)
Assign a value to Chunks data member.
const TSeq_id & GetSeq_id(void) const
Get the Seq_id member data.
const TSeq_id & GetSeq_id(void) const
Get the Seq_id member data.
list< CRef< CID2_Error > > TError
Definition: ID2_Reply_.hpp:461
const TBlob_id & GetBlob_id(void) const
Get the Blob_id member data.
void SetGet_data(TGet_data &value)
Assign a value to Get_data data member.
bool IsSetDiscard(void) const
Check if a value has been assigned to Discard data member.
Definition: ID2_Reply_.hpp:958
bool IsSetBlob_state(void) const
state bits of the blob, 0 or missing means regular live data Check if a value has been assigned to Bl...
TSources & SetSources(void)
Assign a value to Sources data member.
bool IsEmpty(void) const
Check if variant Empty is selected.
Definition: ID2_Reply_.hpp:751
bool IsSetVersion(void) const
version of blob, optional in some requests Check if a value has been assigned to Version data member.
const TAnnot_info & GetAnnot_info(void) const
Get the Annot_info member data.
void SetParams(TParams &value)
Assign a value to Params data member.
TBlob_state GetBlob_state(void) const
Get the Blob_state member data.
const TBlob_id & GetBlob_id(void) const
Get the Blob_id member data.
const TSeq_id & GetSeq_id(void) const
Get the variant data.
bool IsSetData(void) const
chunk data not set if error occurred Check if a value has been assigned to Data data member.
const TChunk_id & GetChunk_id(void) const
Get the Chunk_id member data.
void SetSat_key(TSat_key value)
Assign a value to Sat_key data member.
TBlob_state GetBlob_state(void) const
Get the Blob_state member data.
list< vector< char > * > TData
TBlob_state GetBlob_state(void) const
Get the Blob_state member data.
const TReply & GetReply(void) const
Get the Reply member data.
Definition: ID2_Reply_.hpp:940
E_Choice Which(void) const
Which variant is currently selected.
const TBlob_id & GetBlob_id(void) const
Get the Blob_id member data.
TSplit_version GetSplit_version(void) const
Get the Split_version member data.
const TSeq_id & GetSeq_id(void) const
Get the Seq_id member data.
CID2_Request_Get_Seq_id TGet_seq_id
Tdata & Set(void)
Assign a value to data member.
TSub_sat GetSub_sat(void) const
Get the Sub_sat member data.
TSerial_number GetSerial_number(void) const
Get the Serial_number member data.
Definition: ID2_Reply_.hpp:830
bool IsSetEnd_of_reply(void) const
this Seq-id is the last one in the request Check if a value has been assigned to End_of_reply data me...
const TSeq_id & GetSeq_id(void) const
Get the Seq_id member data.
const TData & GetData(void) const
Get the Data member data.
list< CRef< CID2_Request > > Tdata
bool IsSetSerial_number(void) const
request's serial number, copy from request Check if a value has been assigned to Serial_number data m...
Definition: ID2_Reply_.hpp:811
bool IsSetError(void) const
Check if a value has been assigned to Error data member.
Definition: ID2_Reply_.hpp:879
void SetSat(TSat value)
Assign a value to Sat data member.
const TRequest & GetRequest(void) const
Get the Request member data.
const TData & GetData(void) const
Get the Data member data.
bool IsInit(void) const
Check if variant Init is selected.
void SetRequest(TRequest &value)
Assign a value to Request data member.
bool IsSetData(void) const
blob split info not set if error occurred Check if a value has been assigned to Data data member.
void SetBlob_id(TBlob_id &value)
Assign a value to Blob_id data member.
TSat GetSat(void) const
Get the Sat member data.
void SetSub_sat(TSub_sat value)
Assign a value to Sub_sat data member.
const TBlob_id & GetBlob_id(void) const
Get the Blob_id member data.
list< CRef< CSeq_id > > TSeq_id
bool IsSetEnd_of_reply(void) const
true if this reply is the last one for the request false if more replies will follow Check if a value...
Definition: ID2_Reply_.hpp:904
void SetSeq_id(TSeq_id &value)
Assign a value to Seq_id data member.
void SetExternal(void)
Set NULL data member (assign 'NULL' value to External data member).
TSplit_version GetSplit_version(void) const
Get the Split_version member data.
bool IsSetData(void) const
whole blob or blob skeleton not set if error occurred Check if a value has been assigned to Data data...
const TData & GetData(void) const
Get the Data member data.
const Tdata & Get(void) const
Get the member data.
@ eSeq_id_type_hash
return a sequence hash as integer in general id with db "HASH"
@ eSeq_id_type_any
return any qualified Seq-id
@ eSeq_id_type_taxid
return a sequence taxonomy ID as integer in general id with db "TAXID"
@ eSeq_id_type_seq_length
return a sequence Seq-inst.length as int in general id with db "Seq-inst.length"
@ eSeq_id_type_seq_mol
return a sequence Seq-inst.mol as int in general id with db "Seq-inst.mol"
@ eSeq_id_type_text
text Seq-id (accession etc) is preferred
@ eSeq_id_type_label
return a sequence string label as string in general id with db "LABEL"
@ eSeq_id_type_all
return all qualified Seq-ids of the sequence
@ eSeverity_no_data
resolve request gives no data probably temporarily (see retry-delay field)
Definition: ID2_Error_.hpp:89
@ eSeverity_restricted_data
data exists but client doesn't have permission to get it
Definition: ID2_Error_.hpp:90
@ eSeverity_failed_command
command cannot be completed this time
Definition: ID2_Error_.hpp:86
@ eSeverity_failed_server
server cannot be used for a while
Definition: ID2_Error_.hpp:88
@ eSeverity_warning
nothing harmful happened
Definition: ID2_Error_.hpp:85
@ eSeverity_unsupported_command
this request type is not supported by server
Definition: ID2_Error_.hpp:91
@ eSeverity_invalid_arguments
error in request packet, cannot retry
Definition: ID2_Error_.hpp:92
@ eSeverity_failed_connection
connection cannot be reused, reconnect is required
Definition: ID2_Error_.hpp:87
@ eID2_Blob_State_dead
@ eID2_Blob_State_suppressed
@ eID2_Blob_State_protected
@ eID2_Blob_State_suppressed_temp
@ eID2_Blob_State_withdrawn
bool IsSetSeq_loc(void) const
Check if a value has been assigned to Seq_loc data member.
bool IsSetName(void) const
name is set if this is named annot name may be empty which differ from unnamed annot Check if a value...
bool IsSetGraph(void) const
Check if a value has been assigned to Graph data member.
bool IsSetAlign(void) const
Check if a value has been assigned to Align data member.
const TName & GetName(void) const
Get the Name member data.
bool IsSetFeat(void) const
Check if a value has been assigned to Feat data member.
void ResetGraph(void)
Reset Graph data member.
bool IsGeneral(void) const
Check if variant General is selected.
Definition: Seq_id_.hpp:877
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_id_.hpp:746
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
@ e_not_set
No variant selected.
Definition: Seq_id_.hpp:94
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
Definition of all error codes used in objtools libraries.
int i
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
string s_Value(TValue value)
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Static variables safety - create on demand, destroy on application termination.
Multi-threading – mutexes; rw-locks; semaphore.
T max(T x_, T y_)
EGBErrorAction
Definition: blob_id.hpp:205
@ eGBErrorAction_report
Definition: blob_id.hpp:207
@ eGBErrorAction_throw
Definition: blob_id.hpp:208
@ kMain_ChunkId
Definition: blob_id.hpp:147
@ kDelayedMain_ChunkId
Definition: blob_id.hpp:149
@ fBlobHasNamedFeat
Definition: blob_id.hpp:168
@ fBlobHasNamedAnnot
Definition: blob_id.hpp:178
@ fBlobHasCore
Definition: blob_id.hpp:155
@ fBlobHasExtAnnot
Definition: blob_id.hpp:175
@ fBlobHasAllLocal
Definition: blob_id.hpp:196
@ fBlobHasNamedAlign
Definition: blob_id.hpp:169
@ fBlobHasNamedGraph
Definition: blob_id.hpp:170
Helper classes and templates to implement plugins.
#define DEFAULT_DEBUG_LEVEL
static const char kSpecialId_type[]
static void LoadedChunksPacket(CReaderRequestResult &result, CID2_Request_Packet &packet, vector< TChunkId > &chunks, const CBlob_id &blob_id)
NCBI_PARAM_ENUM_DEF_EX(objects::CSeq_id::ESNPScaleLimit, GENBANK, ID2SNP_SCALE_LIMIT, objects::CSeq_id::eSNPScaleLimit_Default, eParam_NoThread, GENBANK_ID2SNP_SCALE_LIMIT)
static const char kSpecialId_taxid[]
#define x_GetReaderName(conn)
static size_t GetMaxIdsRequestSize(void)
static size_t GetMaxChunksRequestSize(void)
typedef NCBI_PARAM_TYPE(GENBANK, ID2SNP_SCALE_LIMIT) TID2SNP_Scale_Limit
static const char kSpecialId_length[]
static const char kSpecialId_label[]
NCBI_PARAM_DECL(int, GENBANK, ID2_DEBUG)
static bool sx_IsSpecialId(const CSeq_id &id)
static bool LimitChunksRequests(size_t max_request_size=GetMaxChunksRequestSize())
NCBI_PARAM_ENUM_DECL(objects::CSeq_id::ESNPScaleLimit, GENBANK, ID2SNP_SCALE_LIMIT)
NCBI_DEFINE_ERR_SUBCODE_X(17)
NCBI_PARAM_ENUM_ARRAY(objects::CSeq_id::ESNPScaleLimit, GENBANK, ID2SNP_SCALE_LIMIT)
static bool SeparateChunksRequests(size_t max_request_size=GetMaxChunksRequestSize())
static const char kSpecialId_hash[]
NCBI_PARAM_DEF_EX(int, GENBANK, ID2_DEBUG, CId2ReaderBase::eTraceError, eParam_NoThread, GENBANK_ID2_DEBUG)
static bool GetSeqId(const T &d, set< string > &labels, const string name="", bool detect=false, bool found=false)
Defines CRequestContext class for NCBI C++ diagnostic API.
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,...
SAnnotSelector –.
TAnnotInfo m_AnnotInfo
CId2ReaderBase::TContentsMask m_ContentMask
list< CRef< CID2S_Seq_annot_Info > > TAnnotInfo
TSkeletons m_Skeletons
map< CSeq_id_Handle, TSeq_idsInfo > TSeq_idSeq_idsSet
pair< int, CReader::TSeqIds > TSeq_idsInfo
TBlob_idSet m_Blob_ids
map< CBlob_id, CConstRef< CID2_Reply_Data > > TSkeletons
TSeq_idSeq_idsSet m_Seq_ids
map< string, TSeq_idsInfo > TStringSeq_idsSet
pair< int, TBlob_ids > TBlob_idsInfo
map< CSeq_id_Handle, TBlob_idsInfo > TBlob_idSet
map< CBlob_id, SId2BlobInfo > TBlob_ids
TBlobStates m_BlobStates
map< CBlob_id, int > TBlobStates
vector< const CID2_Request * > requests
CID2Processor::TReplies TRequestReplies
vector< TRequestReplies > replies
CReader::TConn GetConn() const
vector< SId2ProcessorStage > stages
unique_ptr< CReaderAllocatedConnection > conn
CRef< CID2ProcessorPacketContext > packet_context
CID2Processor::TReplies replies
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 Mon Apr 22 04:02:50 2024 by modify_doxy.py rev. 669887