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

Go to the SVN repository for this file.

1 #ifndef CASS_BLOB_ID__HPP
2 #define CASS_BLOB_ID__HPP
3 
4 /* $Id: cass_blob_id.hpp 100918 2023-09-29 15:56:54Z satskyse $
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: Sergey Satskiy
30  *
31  * File Description: Cassandra processors blob id
32  *
33  */
34 
37 #include <string>
38 #include <optional>
39 
41 
42 
43 #include "pubseq_gateway_utils.hpp"
44 
45 
46 // Cassandra blob identifier consists of two integers: sat and sat key.
47 // The blob sat eventually needs to be resolved to a sat name.
49 {
52 
53  // The resolved sat and a flag if it is a secure keyspace appear later in the process
54  optional<SSatInfoEntry> m_Keyspace;
55  optional<bool> m_IsSecureKeyspace;
56 
58  m_Sat(-1), m_SatKey(-1)
59  {}
60 
61  SCass_BlobId(int sat, int sat_key) :
62  m_Sat(sat), m_SatKey(sat_key)
63  {}
64 
65  SCass_BlobId(const string & blob_id);
66 
67  SCass_BlobId(const SCass_BlobId &) = default;
68  SCass_BlobId(SCass_BlobId &&) = default;
69  SCass_BlobId & operator=(const SCass_BlobId &) = default;
71 
72  bool MapSatToKeyspace(void);
73 
74  string ToString(void) const
75  {
76  char buf[64];
77  long len;
78  string blob_id;
79 
81  blob_id.append(buf, len)
82  .append(1, '.');
84  blob_id.append(buf, len);
85  return blob_id;
86  }
87 
88  bool IsValid(void) const
89  {
90  return m_Sat >= 0 && m_SatKey >= 0;
91  }
92 
93  bool operator < (const SCass_BlobId & other) const
94  {
95  if (m_Sat == other.m_Sat)
96  return m_SatKey < other.m_SatKey;
97  return m_Sat < other.m_Sat;
98  }
99 
100  bool operator == (const SCass_BlobId & other) const
101  {
102  return m_Sat == other.m_Sat && m_SatKey == other.m_SatKey;
103  }
104 
105  bool operator != (const SCass_BlobId & other) const
106  {
107  return !this->operator==(other);
108  }
109 };
110 
111 
112 #endif // CASS_BLOB_ID__HPP
113 
USING_IDBLOB_SCOPE
int32_t TSatKey
Definition: record.hpp:61
int16_t TSat
Definition: record.hpp:60
char * buf
int len
long PSGToString(long signed_value, char *buf)
string ToString(void) const
CBioseqInfoRecord::TSat m_Sat
SCass_BlobId & operator=(SCass_BlobId &&)=default
optional< SSatInfoEntry > m_Keyspace
bool operator!=(const SCass_BlobId &other) const
bool IsValid(void) const
optional< bool > m_IsSecureKeyspace
bool operator==(const SCass_BlobId &other) const
SCass_BlobId(const SCass_BlobId &)=default
SCass_BlobId(SCass_BlobId &&)=default
SCass_BlobId(int sat, int sat_key)
bool MapSatToKeyspace(void)
bool operator<(const SCass_BlobId &other) const
SCass_BlobId & operator=(const SCass_BlobId &)=default
CBioseqInfoRecord::TSatKey m_SatKey
Modified on Wed May 15 15:06:13 2024 by modify_doxy.py rev. 669887