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

Go to the SVN repository for this file.

1 #ifndef PSG_CACHE_BLOB_PROP__HPP
2 #define PSG_CACHE_BLOB_PROP__HPP
3 
4 /* $Id: psg_cache_blob_prop.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: blob_prop table cache
32  *
33  */
34 
35 #include <functional>
36 #include <memory>
37 #include <set>
38 #include <string>
39 #include <vector>
40 
41 #include <corelib/ncbistl.hpp>
42 
45 
46 #include "psg_cache_base.hpp"
47 
49 
52 {
53  public:
55 
56  explicit CPubseqGatewayCacheBlobProp(const string& file_name);
58  void Open(const set<int>& sat_ids);
59 
60  vector<CBlobRecord> Fetch(CBlobFetchRequest const& request);
61  vector<CBlobRecord> FetchLast(CBlobFetchRequest const& request);
63 
64  static string PackKey(int32_t sat_key);
65  static string PackKey(int32_t sat_key, int64_t last_modified);
66  static bool UnpackKey(const char* key, size_t key_sz, int64_t& last_modified);
67  static bool UnpackKey(const char* key, size_t key_sz, int64_t& last_modified, int32_t& sat_key);
68 
69  private:
70  bool x_ExtractRecord(CBlobRecord& record, lmdb::val const& value) const;
71 
72  // Checks #STATUS[sat] database for "DISABLED" key
73  // returns False
74  // -- If #STATUS[sat] does not exist
75  // -- If "DISABLED" key exists and is equal string("yes")
77  vector<unique_ptr<lmdb::dbi, function<void(lmdb::dbi*)>>> m_Dbis;
78 };
79 
81 
82 #endif // PSG_CACHE_BLOB_PROP__HPP
#define END_IDBLOB_SCOPE
Definition: IdCassScope.hpp:40
#define BEGIN_IDBLOB_SCOPE
Definition: IdCassScope.hpp:39
void EnumerateBlobProp(int32_t sat, TBlobPropEnumerateFn fn)
CPubseqGatewayCacheBlobProp(const string &file_name)
function< bool(int32_t, int64_t)> TBlobPropEnumerateFn
static bool UnpackKey(const char *key, size_t key_sz, int64_t &last_modified)
bool x_ExtractRecord(CBlobRecord &record, lmdb::val const &value) const
vector< unique_ptr< lmdb::dbi, function< void(lmdb::dbi *)> > > m_Dbis
~CPubseqGatewayCacheBlobProp() override
bool x_CanOpenSatDatabase(int32_t sat, CLMDBReadOnlyTxn &rtxn)
static string PackKey(int32_t sat_key)
vector< CBlobRecord > FetchLast(CBlobFetchRequest const &request)
vector< CBlobRecord > Fetch(CBlobFetchRequest const &request)
Resource class for `MDB_dbi` handles.
Definition: lmdb++.h:1395
Wrapper class for `MDB_val` structures.
Definition: lmdb++.h:948
const char * file_name[]
#define bool
Definition: bool.h:34
Int4 int32_t
Int8 int64_t
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
The NCBI C++/STL use hints.
Modified on Wed May 22 11:29:06 2024 by modify_doxy.py rev. 669887