NCBI C++ ToolKit
processor.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef PROCESSOR__HPP_INCLUDED
2 #define PROCESSOR__HPP_INCLUDED
3 /* */
4 
5 /* $Id: processor.hpp 91641 2020-11-23 18:09:39Z sadyrovr $
6 * ===========================================================================
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 * ===========================================================================
27 *
28 * Author: Eugene Vasilchenko
29 *
30 * File Description: blob stream processor interface
31 *
32 */
33 
34 #include <corelib/ncbiobj.hpp>
35 #include <corelib/ncbi_limits.h>
36 #include <corelib/ncbi_param.hpp>
39 
41 
42 class CObjectIStream;
43 class CBeginInfo;
44 class CStopWatch;
45 
47 
48 class CBlob_id;
51 class CReadDispatcher;
52 class CWriter;
53 class CID2_Reply_Data;
54 class CLoadLockBlob;
55 class CLoadLockSetter;
56 class CTSE_Chunk_Info;
57 class CTSE_SetObjectInfo;
58 class CDataLoader;
59 struct STimeSizeStatistics;
60 
62 {
63 public:
64  typedef CBlob_id TBlobId;
65  typedef int TBlobState;
66  typedef int TBlobVersion;
67  typedef int TChunkId;
68  enum EType {
69  eType_ID1, // ID1server-back
70  eType_ID1_SNP, // ID1server-back with SNPs
71  eType_Seq_entry, // Seq-entry, ASN.1 binary
72  eType_Seq_entry_SNP, // Seq-entry with SNPs, ASN.1 binary
73  eType_St_Seq_entry, // State word + Seq-entry, ASN.1 binary
74  eType_St_Seq_entry_SNPT, // With additional SNP table
75  eType_ID2, // Any ID2 reply data
76  eType_ID2AndSkel, // Two ID2 reply data objects, Split&Skel
77  eType_ID2_SE, // ID2 reply data with Seq-entry
78  eType_ID2_Split, // ID2 reply data with Split-info (+version)
79  eType_ID2_Chunk, // ID2 reply data with Chunk
80  eType_ID2_SNP, // ID2 reply data with SNP Seq-entry
81  eType_ExtAnnot, // Special kind of external annotations
82  eType_AnnotInfo // Special kind of named annotations
83  };
84  typedef unsigned TMagic;
85 
86  virtual ~CProcessor(void);
87 
88  virtual EType GetType(void) const = 0;
89  virtual TMagic GetMagic(void) const = 0;
90 
92  const TBlobId& blob_id,
93  TChunkId chunk_id,
94  CNcbiIstream& stream) const;
95  virtual void ProcessObjStream(CReaderRequestResult& result,
96  const TBlobId& blob_id,
97  TChunkId chunk_id,
98  CObjectIStream& obj_stream) const;
99 
100  void ProcessBlobFromID2Data(CReaderRequestResult& result,
101  const TBlobId& blob_id,
102  TChunkId chunk_id,
103  const CID2_Reply_Data& data) const;
104 
105  static void RegisterAllProcessors(CReadDispatcher& dispatcher);
106 
107  static bool TryStringPack(void);
108  static bool TrySNPSplit(void);
109  static bool TrySNPTable(void);
110 
111  static void SetSeqEntryReadHooks(CObjectIStream& in);
112  static void SetSNPReadHooks(CObjectIStream& in);
113 
115  const TBlobId& blob_id,
116  TChunkId chunk_id,
117  CLoadLockBlob& blob);
118 
119  static TIntId GetGiOffset(void);
120  static void OffsetGi(TGi& gi, TIntId gi_offset)
121  {
122  if ( gi != ZERO_GI ) {
123  gi = gi + GI_FROM(TIntId, gi_offset);
124  }
125  }
126 #ifdef NCBI_STRICT_GI
127  static void OffsetGi(TIntId& gi, TIntId gi_offset)
128  {
129  if ( gi ) {
130  gi = gi + gi_offset;
131  }
132  }
133 #endif
134  static bool OffsetId(CSeq_id& id, TIntId gi_offset);
135  static bool OffsetId(CSeq_id_Handle& id, TIntId gi_offset);
136  static void OffsetAllGis(CBeginInfo obj, TIntId gi_offset);
137  static void OffsetAllGis(CTSE_SetObjectInfo& set_info, TIntId gi_offset);
138 
140  {
141  OffsetGi(gi, -GetGiOffset());
142  return gi;
143  }
144  static TGi ConvertGiToOM(TGi gi)
145  {
146  OffsetGi(gi, GetGiOffset());
147  return gi;
148  }
150  {
151  OffsetId(id, -GetGiOffset());
152  return id;
153  }
154  static void OffsetGiToOM(TGi& gi)
155  {
156  OffsetGi(gi, GetGiOffset());
157  }
158  static void OffsetIdToOM(CSeq_id& id)
159  {
160  OffsetId(id, GetGiOffset());
161  }
162  static void OffsetAllGisFromOM(CBeginInfo obj);
163  static void OffsetAllGisToOM(CBeginInfo obj, CTSE_SetObjectInfo* set_info = 0);
164 
165 protected:
166  CProcessor(CReadDispatcher& dispatcher);
167 
169 
170  CWriter* GetWriter(const CReaderRequestResult& result) const;
171 
172  static int CollectStatistics(void); // 0 - no stats, >1 - verbose
173  static void LogStat(CReaderRequestResultRecursion& recursion,
174  const CBlob_id& blob_id,
176  const char* descr,
177  double size);
178  static void LogStat(CReaderRequestResultRecursion& recursion,
179  const CBlob_id& blob_id,
180  int chunk_id,
182  const char* descr,
183  double size);
184  static void LogStat(CReaderRequestResultRecursion& recursion,
185  const CBlob_id& blob_id,
187  const char* descr,
189  {
190  LogStat(recursion, blob_id, stat_type, descr, double(size));
191  }
192  static void LogStat(CReaderRequestResultRecursion& recursion,
193  const CBlob_id& blob_id,
194  int chunk_id,
196  const char* descr,
198  {
199  LogStat(recursion, blob_id, chunk_id, stat_type, descr, double(size));
200  }
201  static void LogStat(CReaderRequestResultRecursion& recursion,
202  const CBlob_id& blob_id,
204  const char* descr,
205  size_t size)
206  {
207  LogStat(recursion, blob_id, stat_type, descr, double(size));
208  }
209  static void LogStat(CReaderRequestResultRecursion& recursion,
210  const CBlob_id& blob_id,
211  int chunk_id,
213  const char* descr,
214  size_t size)
215  {
216  LogStat(recursion, blob_id, chunk_id, stat_type, descr, double(size));
217  }
218 };
219 
220 
221 // Parameters' declarations
222 NCBI_PARAM_DECL(bool, GENBANK, SNP_PACK_STRINGS);
223 NCBI_PARAM_DECL(bool, GENBANK, SNP_SPLIT);
224 NCBI_PARAM_DECL(bool, GENBANK, SNP_TABLE);
225 NCBI_PARAM_DECL(bool, GENBANK, USE_MEMORY_POOL);
226 NCBI_PARAM_DECL(int, GENBANK, READER_STATS);
227 NCBI_PARAM_DECL(bool, GENBANK, CACHE_RECOMPRESS);
228 NCBI_PARAM_DECL(bool, GENBANK, ADD_WGS_MASTER);
229 NCBI_PARAM_DECL(Int8, GENBANK, GI_OFFSET);
230 
233 
234 #endif//PROCESSOR__HPP_INCLUDED
int ProcessStream(istream &in, ostream &out)
Class holding information about root of non-modifiable object hierarchy Do not use it directly.
Definition: iterator.hpp:58
CObjectIStream –.
Definition: objistr.hpp:93
CObject –.
Definition: ncbiobj.hpp:180
static void SetLoaded(CReaderRequestResult &result, const TBlobId &blob_id, TChunkId chunk_id, CLoadLockBlob &blob)
CBlob_id TBlobId
Definition: processor.hpp:64
static TGi ConvertGiFromOM(TGi gi)
Definition: processor.hpp:139
unsigned TMagic
Definition: processor.hpp:84
static void LogStat(CReaderRequestResultRecursion &recursion, const CBlob_id &blob_id, int chunk_id, CGBRequestStatistics::EStatType stat_type, const char *descr, CNcbiStreampos size)
Definition: processor.hpp:192
@ eType_St_Seq_entry
Definition: processor.hpp:73
@ eType_Seq_entry
Definition: processor.hpp:71
@ eType_ID2AndSkel
Definition: processor.hpp:76
@ eType_ExtAnnot
Definition: processor.hpp:81
@ eType_St_Seq_entry_SNPT
Definition: processor.hpp:74
@ eType_ID2_Chunk
Definition: processor.hpp:79
@ eType_Seq_entry_SNP
Definition: processor.hpp:72
@ eType_ID2_Split
Definition: processor.hpp:78
static TGi ConvertGiToOM(TGi gi)
Definition: processor.hpp:144
static void OffsetGiToOM(TGi &gi)
Definition: processor.hpp:154
static void LogStat(CReaderRequestResultRecursion &recursion, const CBlob_id &blob_id, CGBRequestStatistics::EStatType stat_type, const char *descr, size_t size)
Definition: processor.hpp:201
static void OffsetIdToOM(CSeq_id &id)
Definition: processor.hpp:158
int TChunkId
Definition: processor.hpp:67
static void LogStat(CReaderRequestResultRecursion &recursion, const CBlob_id &blob_id, int chunk_id, CGBRequestStatistics::EStatType stat_type, const char *descr, size_t size)
Definition: processor.hpp:209
static void OffsetGi(TGi &gi, TIntId gi_offset)
Definition: processor.hpp:120
static CSeq_id_Handle ConvertIdFromOM(CSeq_id_Handle id)
Definition: processor.hpp:149
static void LogStat(CReaderRequestResultRecursion &recursion, const CBlob_id &blob_id, CGBRequestStatistics::EStatType stat_type, const char *descr, CNcbiStreampos size)
Definition: processor.hpp:184
int TBlobState
Definition: processor.hpp:65
virtual EType GetType(void) const =0
virtual TMagic GetMagic(void) const =0
int TBlobVersion
Definition: processor.hpp:66
CReadDispatcher * m_Dispatcher
Definition: processor.hpp:168
static void OffsetGi(TIntId &gi, TIntId gi_offset)
Definition: processor.hpp:127
CStopWatch –.
Definition: ncbitime.hpp:1937
char data[12]
Definition: iconv.c:80
#define GI_FROM(T, value)
Definition: ncbimisc.hpp:1086
Int8 TIntId
Definition: ncbimisc.hpp:999
#define ZERO_GI
Definition: ncbimisc.hpp:1088
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
IO_PREFIX::streampos CNcbiStreampos
Portable alias for streampos.
Definition: ncbistre.hpp:134
#define NCBI_XREADER_EXPORT
Definition: ncbi_export.h:1371
const struct ncbi::grid::netcache::search::fields::SIZE size
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
std::istream & in(std::istream &in_, double &x_)
NCBI_PARAM_DECL(bool, GENBANK, SNP_PACK_STRINGS)
else result
Definition: token2.c:20
Modified on Sun Jul 14 04:55:01 2024 by modify_doxy.py rev. 669887