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

Go to the SVN repository for this file.

1 #ifndef OBJECTS_OBJMGR_IMPL___TSE_SPLIT_INFO__HPP
2 #define OBJECTS_OBJMGR_IMPL___TSE_SPLIT_INFO__HPP
3 
4 /* $Id: tse_split_info.hpp 100045 2023-06-06 20:50:22Z vasilche $
5 * ===========================================================================
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 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * Split TSE info
33 *
34 */
35 
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <corelib/ncbimtx.hpp>
39 
41 
43 
44 #include <vector>
45 #include <map>
46 
49 
50 class CTSE_Info;
51 class CTSE_Chunk_Info;
52 class CBioseq_Info;
53 class CSeq_entry_Info;
54 class CDataSource;
55 class CDataLoader;
56 class CTSE_SetObjectInfo;
57 
58 class ITSE_Assigner;
59 class CBioseqUpdater;
60 
61 struct SAnnotObjectsIndex;
62 
64 {
65 public:
67  typedef int TBlobVersion;
68  typedef int TSplitVersion;
70  typedef vector<TChunkId> TChunkIds;
72  typedef vector<pair<CSeq_id_Handle, TChunkId> > TSeqIdToChunks;
81  typedef vector<CSeq_id_Handle> TSeqIds;
83 
84  CTSE_Split_Info(void);
86  ~CTSE_Split_Info(void);
87 
88  // interface to TSE
89  TBlobId GetBlobId(void) const;
90  TBlobVersion GetBlobVersion(void) const;
91  TSplitVersion GetSplitVersion(void) const;
92  void SetSplitVersion(TSplitVersion version);
93  CInitMutexPool& GetMutexPool(void);
94  CDataLoader& GetDataLoader(void) const;
95 
96  // TSE connection
97  void x_DSAttach(CDataSource& ds);
98  void x_DSDetach(CDataSource& ds);
99  void x_TSEAttach(CTSE_Info& tse_info, CRef<ITSE_Assigner>& assigner);
100  void x_TSEDetach(CTSE_Info& tse_info);
101 
102  CRef<ITSE_Assigner> GetAssigner(const CTSE_Info& tse);
103 
104  // chunk connection
105  void AddChunk(CTSE_Chunk_Info& chunk_info);
106  CTSE_Chunk_Info& GetChunk(TChunkId chunk_id);
107  const CTSE_Chunk_Info& GetChunk(TChunkId chunk_id) const;
108  CTSE_Chunk_Info& GetSkeletonChunk(void);
109  void LoadChunk(TChunkId id) const;
110  void LoadChunks(const TChunkIds& ids) const;
111 
112  bool x_HasDelayedMainChunk(void) const;
113  bool x_NeedsDelayedMainChunk(void) const;
114  void x_LoadDelayedMainChunk(void) const;
115 
116  // split information
117  void x_AddDescInfo(const TDescInfo& info, TChunkId chunk_id);
118  void x_AddAnnotPlace(const TPlace& place, TChunkId chunk_id);
119  void x_AddBioseqPlace(TBioseq_setId place_id, TChunkId chunk_id);
120  void x_AddSeq_data(const TLocationSet& location, CTSE_Chunk_Info& chunk);
121  void x_AddAssemblyInfo(const TAssemblyInfo& info, TChunkId chunk_id);
122 
123  // id indexing
124  void x_UpdateCore(void);
125  void x_SetBioseqChunkId(TChunkId chunk_id);
126  void x_SetContainedId(const TBioseqId& id, TChunkId chunk_id, bool bioseq);
127  void x_SetContainedSeqIds(const vector<TBioseqId>& seq_ids,
128  const set<TBioseqId>& annot_ids,
129  TChunkId chunk_id);
130 
131  bool x_CanAddBioseq(const TBioseqId& id) const;
132 
133  void x_UpdateAnnotIndex(void);
134  void x_UpdateAnnotIndex(CTSE_Chunk_Info& chunk);
135  void x_UpdateFeatIdIndex(CSeqFeatData::E_Choice type,
136  EFeatIdType id_type);
137  void x_UpdateFeatIdIndex(CSeqFeatData::ESubtype subtype,
138  EFeatIdType id_type);
139 
140  // append ids with all Bioseqs Seq-ids from this Split-Info
141  void GetBioseqsIds(TSeqIds& ids) const;
142 
143  // bioseq lookup
144  bool ContainsBioseqs() const { return m_ContainsBioseqs.load(memory_order_relaxed); }
145  bool ContainsBioseq(const CSeq_id_Handle& id) const;
146 
147  // loading requests
148  void x_GetRecords(const CSeq_id_Handle& id, bool bioseq) const;
149  void x_LoadChunk(TChunkId chunk_id) const;
150  void x_LoadChunks(const TChunkIds& chunk_ids) const;
151  void x_AddChunksForGetRecords(vector<CConstRef<CTSE_Chunk_Info>>& chunks,
152  const CSeq_id_Handle& id) const;
153  static void x_LoadChunks(CDataLoader* loader,
154  const vector<CConstRef<CTSE_Chunk_Info>>& chunks);
155 
156  // loading results
157  void x_LoadDescr(const TPlace& place, const CSeq_descr& descr);
158  void x_LoadAnnot(const TPlace& place, const CSeq_annot& annot, int chunk_id);
159  void x_LoadBioseqs(const TPlace& place, const list< CRef<CBioseq> >& bioseqs, int chunk_id);
160  void x_LoadSequence(const TPlace& place, TSeqPos pos,
161  const TSequence& sequence);
162  void x_LoadAssembly(const TBioseqId& seq_id,
163  const TAssembly& assembly);
164  void x_LoadSeq_entry(CSeq_entry& entry, CTSE_SetObjectInfo* set_info = 0);
165 
166  // update in-memory size
167  void x_AddUsedMemory(size_t size);
168 
169  void x_SetBioseqUpdater(CRef<CBioseqUpdater> updater);
170 
171 protected:
172  TSeqIdToChunks::const_iterator x_FindChunk(const CSeq_id_Handle& id) const;
173 
174 private:
175  // identification of the blob
180 
181  // all TSEs using this split info
183 
184  // mutex to serialize chunk addition
186 
187  // Split chunks
191 
192  // loading
195  mutable bool m_SeqIdToChunksSorted;
196  atomic<bool> m_ContainsBioseqs;
198 
199 private:
202 };
203 
204 
205 inline
207 {
208  x_LoadChunk(id);
209 }
210 
211 
212 inline
214 {
215  x_LoadChunks(ids);
216 }
217 
218 
221 
222 #endif//OBJECTS_OBJMGR_IMPL___TSE_SPLIT_INFO__HPP
CMutex –.
Definition: ncbimtx.hpp:749
CObject –.
Definition: ncbiobj.hpp:180
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
Definition: Seq_entry.hpp:56
pair< TBioseqId, TBioseq_setId > TPlace
list< CRef< CSeq_align > > TAssembly
pair< TDescTypeMask, TPlace > TDescInfo
vector< TLocation > TLocationSet
list< CRef< CSeq_literal > > TSequence
void LoadChunks(const TChunkIds &ids) const
CTSE_Chunk_Info::TBioseqId TBioseqId
CTSE_Chunk_Info::TBioseq_setId TBioseq_setId
CTSE_Chunk_Info::TChunkId TChunkId
CDataSource * m_DataLoader
void x_SetBioseqChunkId(TChunkId chunk_id)
void x_LoadChunks(const TChunkIds &chunk_ids) const
map< CTSE_Info *, CRef< ITSE_Assigner > > TTSE_Set
CTSE_Chunk_Info::TAssembly TAssembly
TBlobVersion m_BlobVersion
CInitMutexPool m_MutexPool
CBlobIdKey TBlobId
TSeqIdToChunks m_SeqIdToChunks
TSplitVersion m_SplitVersion
CTSE_Chunk_Info::TDescInfo TDescInfo
void LoadChunk(TChunkId id) const
atomic< bool > m_ContainsBioseqs
CTSE_Chunk_Info::TLocationSet TLocationSet
TChunkId m_BioseqChunkId
void x_LoadChunk(TChunkId chunk_id) const
bool ContainsBioseqs() const
vector< TChunkId > TChunkIds
CTSE_Split_Info & operator=(const CTSE_Split_Info &)
CTSE_Chunk_Info::TSequence TSequence
vector< CSeq_id_Handle > TSeqIds
CTSE_Chunk_Info::TPlace TPlace
vector< pair< CSeq_id_Handle, TChunkId > > TSeqIdToChunks
CTSE_Split_Info(const CTSE_Split_Info &)
map< TChunkId, CRef< CTSE_Chunk_Info > > TChunks
CTSE_Chunk_Info::TAssemblyInfo TAssemblyInfo
Definition: map.hpp:338
Definition: set.hpp:45
static const char location[]
Definition: config.c:97
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#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 NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
E_Choice
Choice variants.
static MDB_envinfo info
Definition: mdb_load.c:37
static int version
Definition: mdb_load.c:29
const struct ncbi::grid::netcache::search::fields::SIZE size
Multi-threading – mutexes; rw-locks; semaphore.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
int TChunkId
Definition: blob_id.hpp:145
Definition: type.c:6
Modified on Sat Apr 20 12:18:07 2024 by modify_doxy.py rev. 669887