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

Go to the SVN repository for this file.

1 #ifndef PSG_CACHE_BIOSEQ_INFO__HPP
2 #define PSG_CACHE_BIOSEQ_INFO__HPP
3 
4 /* $Id: psg_cache_bioseq_info.hpp 99744 2023-05-05 15:04:59Z saprykin $
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  * Authors: Dmitri Dmitrienko
30  *
31  * File Description: bioseq_info table cache
32  *
33  */
34 
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
39 #include "psg_cache_base.hpp"
40 
44 
46 
49 {
50  public:
51  explicit CPubseqGatewayCacheBioseqInfo(const string& file_name);
53  void Open();
54 
55  vector<CBioseqInfoRecord> Fetch(CBioseqInfoFetchRequest const& request);
56  vector<CBioseqInfoRecord> FetchLast(void);
57 
58  static string PackKey(const string& accession, int version);
59  static string PackKey(const string& accession, int version, int seq_id_type);
60  static string PackKey(const string& accession, int version, int seq_id_type, int64_t gi);
61  static bool UnpackKey(const char* key, size_t key_sz, int& version, int& seq_id_type, int64_t& gi);
62  static bool UnpackKey(
63  const char* key, size_t key_sz, string& accession, int& version, int& seq_id_type, int64_t& gi);
64 
65  private:
66  bool x_ExtractRecord(CBioseqInfoRecord& record, lmdb::val const& value) const;
67  string x_MakeLookupKey(CBioseqInfoFetchRequest const& request) const;
68  bool x_IsMatchingRecord(CBioseqInfoFetchRequest const& request, int version, int seq_id_type, int64_t gi) const;
69  void ResetDbi();
70  unique_ptr<lmdb::dbi, function<void(lmdb::dbi*)>> m_Dbi;
71 };
72 
74 
75 #endif // PSG_CACHE_BIOSEQ_INFO__HPP
#define END_IDBLOB_SCOPE
Definition: IdCassScope.hpp:40
#define BEGIN_IDBLOB_SCOPE
Definition: IdCassScope.hpp:39
unique_ptr< lmdb::dbi, function< void(lmdb::dbi *)> > m_Dbi
~CPubseqGatewayCacheBioseqInfo() override
vector< CBioseqInfoRecord > Fetch(CBioseqInfoFetchRequest const &request)
string x_MakeLookupKey(CBioseqInfoFetchRequest const &request) const
bool x_ExtractRecord(CBioseqInfoRecord &record, lmdb::val const &value) const
static string PackKey(const string &accession, int version)
bool x_IsMatchingRecord(CBioseqInfoFetchRequest const &request, int version, int seq_id_type, int64_t gi) const
static bool UnpackKey(const char *key, size_t key_sz, int &version, int &seq_id_type, int64_t &gi)
CPubseqGatewayCacheBioseqInfo(const string &file_name)
vector< CBioseqInfoRecord > FetchLast(void)
Resource class for `MDB_dbi` handles.
Definition: lmdb++.h:1395
Wrapper class for `MDB_val` structures.
Definition: lmdb++.h:948
const char * file_name[]
Int8 int64_t
const string version
version string
Definition: variables.hpp:66
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Modified on Fri Sep 20 14:58:25 2024 by modify_doxy.py rev. 669887