ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
pool::DbToken Class Reference

Db objects: DbToken, DbToken.h, POOLCore/DbToken.h. More...

#include <DbToken.h>

Inheritance diagram for pool::DbToken:
Collaboration diagram for pool::DbToken:

Public Types

enum  { TOKEN_FULL_KEY = 1<<0, TOKEN_CONT_KEY = 1<<1, TOKEN_ITERATOR = 1<<2 }
 Default token key enumeration. More...
 

Public Member Functions

 DbToken ()
 Standard constructor. More...
 
virtual bool equal (const Token &pTok) const
 Fast token comparison: operator equal. More...
 
virtual bool less (const Token &pTok) const
 Fast token comparison: operator less. More...
 
void setKey (int which)
 Produce the keys only on demand. More...
 
void setKeyEx (int which, const Guid &guid)
 Copy the key. More...
 
void setUserKey (int i, const Guid &guid)
 Set a user key. More...
 
void setTypeInfo (const DbTypeInfo *t)
 Update type information. More...
 
const DbTypeInfotypeInfo () const
 Access type information. More...
 
void setLocal (bool val)
 Set local flag. More...
 
bool isLocal () const
 Access local flag. More...
 
void addTypeSetting (int val)
 Add type setting. More...
 
void removeTypeSetting (int val)
 Add type setting. More...
 
const GuidfullKey () const
 Access to user key identifying full token. More...
 
const GuidcontKey () const
 Access to user key #1. More...
 
const Guiduserkey (int i) const
 Access to optional user keys #2. More...
 
bool operator< (const Token &refToken) const
 Operator < to allow ordering. More...
 
bool operator> (const Token &refToken) const
 Operator > to allow ordering. More...
 
bool operator== (const Token &refToken) const
 Equality operator. More...
 
bool operator!= (const Token &refToken) const
 Equality operator. More...
 
int release ()
 Release token: Decrease reference count and eventually delete. More...
 
int addRef ()
 Increase reference count. More...
 
const GuiddbID () const
 Access database identifier. More...
 
TokensetDb (const Guid &db)
 Set database name. More...
 
TokensetDb (const std::string &db)
 
const std::string & contID () const
 Access container identifier. More...
 
TokensetCont (const std::string &cnt)
 Set container name. More...
 
const GuidclassID () const
 Access database identifier. More...
 
TokensetClassID (const Guid &cl_id)
 Access database identifier. More...
 
int technology () const
 Access technology type. More...
 
TokensetTechnology (int t)
 Set technology type. More...
 
const OID_toid () const
 Access object identifier. More...
 
OID_toid ()
 Access object identifier. More...
 
TokensetOid (const OID_t &oid)
 Set object identifier. More...
 
int type () const
 Access token type. More...
 
TokensetType (int t)
 Set token type. More...
 
const std::string & auxString () const
 Access auxiliary string. More...
 
TokensetAuxString (const std::string &auxString)
 Set auxiliary string. More...
 
virtual const std::string toString () const
 Retrieve the string representation of the token. More...
 
virtual const std::string key () const
 Retrieve token key. More...
 
TokenfromString (const std::string_view from)
 Build from the string representation of a token. More...
 
const Tokenset (Token *pToken) const
 Set token information. More...
 
const TokensetData (Token *pToken) const
 Set all the data part of the token. More...
 

Static Public Member Functions

static void makeKey (const Token *tok, int which, Guid &guid)
 Produce the token keys only on demand for export. More...
 
static int numInstances ()
 expose Token instance counter for debugging More...
 

Private Attributes

Guid m_keyFull
 Buffer to hold user key identifying full token. More...
 
Guid m_contKey
 Buffer to hold user key #1. More...
 
std::vector< Guidm_ukeys
 Optional other user keys. More...
 
const DbTypeInfom_info
 Database type information cache. More...
 
bool m_local
 Flag to indicate if toekn is local or foreign. More...
 
int m_refCount
 Reference count. More...
 
unsigned int m_technology
 Technology identifier. More...
 
Guid m_dbID
 Database identifier. More...
 
std::string m_cntID
 Container identifier. More...
 
Guid m_classID
 Object global identifier. More...
 
OID_t m_oid
 Persistent object identifier. More...
 
int m_type
 Token type. More...
 
std::string m_auxString
 Auxiliary string. More...
 

Detailed Description

Db objects: DbToken, DbToken.h, POOLCore/DbToken.h.

Description:

Definition of an optimized token used internally in the Database. This token implementation generates an MD5 checksum over the token information. This should be advantageous for long tokens compared to the horrible full lookup of the string exceeding typically 300 chars.

Author
M.Frank
Version
1.0

Definition at line 42 of file DbToken.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Default token key enumeration.

Enumerator
TOKEN_FULL_KEY 
TOKEN_CONT_KEY 
TOKEN_ITERATOR 

Definition at line 45 of file DbToken.h.

45  {TOKEN_FULL_KEY = 1<<0,
46  TOKEN_CONT_KEY = 1<<1,
47  TOKEN_ITERATOR = 1<<2
48  };

Constructor & Destructor Documentation

◆ DbToken()

pool::DbToken::DbToken ( )
inline

Standard constructor.

Definition at line 64 of file DbToken.h.

64 : m_info(0), m_local(false) {}

Member Function Documentation

◆ addRef()

int Token::addRef ( )
inlineinherited

Increase reference count.

Definition at line 62 of file Token.h.

62 { return ++m_refCount; }

◆ addTypeSetting()

void pool::DbToken::addTypeSetting ( int  val)
inline

Add type setting.

Definition at line 84 of file DbToken.h.

84 { setType(type() | val); }

◆ auxString()

const std::string& Token::auxString ( ) const
inlineinherited

Access auxiliary string.

Definition at line 91 of file Token.h.

91 { return m_auxString; }

◆ classID()

const Guid& Token::classID ( ) const
inlineinherited

Access database identifier.

Definition at line 73 of file Token.h.

73 { return m_classID; }

◆ contID()

const std::string& Token::contID ( ) const
inlineinherited

Access container identifier.

Definition at line 69 of file Token.h.

69 { return m_cntID; }

◆ contKey()

const Guid& pool::DbToken::contKey ( ) const
inline

Access to user key #1.

Definition at line 90 of file DbToken.h.

90 { return m_contKey; }

◆ dbID()

const Guid& Token::dbID ( ) const
inlineinherited

Access database identifier.

Definition at line 64 of file Token.h.

64 { return m_dbID; }

◆ equal()

virtual bool pool::DbToken::equal ( const Token pTok) const
virtual

Fast token comparison: operator equal.

Reimplemented from Token.

◆ fromString()

Token & Token::fromString ( const std::string_view  from)
inherited

Build from the string representation of a token.

Definition at line 147 of file Token.cxx.

147  {
148  m_auxString.clear();
149  size_t pos = 0;
150  while (pos < src.size()) {
151  size_t start = src.find('[', pos);
152  if (start == std::string_view::npos) break;
153  size_t eq = src.find('=', start);
154  size_t end = src.find(']', start);
155  if (eq != std::string_view::npos && end != std::string_view::npos) {
156  std::string_view label = src.substr(start, eq - start + 1);
157  if (label == LABEL_DB) {
158  m_dbID.fromString(src.substr(eq + 1, end - eq - 1));
159  } else if (label == LABEL_CNT) {
160  m_cntID = std::string(src.substr(eq + 1, end - eq - 1));
161  } else if (label == LABEL_CLID) {
162  m_classID.fromString(src.substr(eq + 1, end - eq - 1));
163  } else if (label == LABEL_TECH) {
164  std::string_view num_str = src.substr(eq + 1, end - eq - 1);
165  int tech = 0;
166  std::from_chars(num_str.data(), num_str.data() + num_str.size(), tech, 16);
167  m_technology = tech;
168  } else if (label == LABEL_OID) {
169  std::string_view oid_str = src.substr(eq + 1, end - eq - 1);
170  size_t dash = oid_str.find('-');
171  if (dash != std::string_view::npos) {
172  std::string_view first_str = oid_str.substr(0, dash);
173  std::string_view second_str = oid_str.substr(dash + 1);
174 
175  // Check if this is legacy format (8 digits) vs modern format (16 digits)
176  // Legacy format: 5 + 8 + 1 + 8 + 1 = 23 characters total for [OID=XXXXXXXX-XXXXXXXX]
177  // Modern format: 5 + 16 + 1 + 16 + 1 = 39 characters total for [OID=XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXX]
178  bool is_legacy = (end - start + 1) == 23; // Total bracket length check
179 
180  uint64_t first = 0;
181  uint64_t second = 0;
182  std::from_chars(first_str.data(), first_str.data() + first_str.size(), first, 16);
183  std::from_chars(second_str.data(), second_str.data() + second_str.size(), second, 16);
184 
185  if (is_legacy) {
186  // Handle legacy format: extend 32-bit ~0x0 to 64-bit ~0x0LL
187  if (static_cast<uint32_t>(first) == ~0x0U) first = ~0x0ULL;
188  if (static_cast<uint32_t>(second) == ~0x0U) second = ~0x0ULL;
189  }
190 
191  m_oid.first = static_cast<long long int>(first);
192  m_oid.second = static_cast<long long int>(second);
193  }
194  } else {
195  m_auxString += src.substr(start, end - start + 1);
196  }
197  pos = end + 1;
198  } else {
199  break;
200  }
201  }
202  return *this;
203 }

◆ fullKey()

const Guid& pool::DbToken::fullKey ( ) const
inline

Access to user key identifying full token.

Definition at line 88 of file DbToken.h.

88 { return m_keyFull; }

◆ isLocal()

bool pool::DbToken::isLocal ( ) const
inline

Access local flag.

Definition at line 82 of file DbToken.h.

82 { return m_local; }

◆ key()

const std::string Token::key ( ) const
virtualinherited

Retrieve token key.

Retrieve the string representation of the token.

Definition at line 206 of file Token.cxx.

206  {
207  return std::format(
208  "[DB={}][CNT={}][CLID={}][TECH={:08X}]",
210  m_cntID,
212  m_technology & KEY_MASK
213  );
214 }

◆ less()

virtual bool pool::DbToken::less ( const Token pTok) const
virtual

Fast token comparison: operator less.

Reimplemented from Token.

◆ makeKey()

static void pool::DbToken::makeKey ( const Token tok,
int  which,
Guid guid 
)
static

Produce the token keys only on demand for export.

◆ numInstances()

int Token::numInstances ( )
staticinherited

expose Token instance counter for debugging

Definition at line 24 of file Token.cxx.

24 { return s_numCount; }

◆ oid() [1/2]

OID_t& Token::oid ( )
inlineinherited

Access object identifier.

Definition at line 83 of file Token.h.

83 { return m_oid; }

◆ oid() [2/2]

const OID_t& Token::oid ( ) const
inlineinherited

Access object identifier.

Definition at line 81 of file Token.h.

81 { return m_oid; }

◆ operator!=()

bool Token::operator!= ( const Token refToken) const
inlineinherited

Equality operator.

Definition at line 54 of file Token.h.

54 { return !equal(refToken); }

◆ operator<()

bool Token::operator< ( const Token refToken) const
inlineinherited

Operator < to allow ordering.

Definition at line 45 of file Token.h.

45 { return less(refToken); }

◆ operator==()

bool Token::operator== ( const Token refToken) const
inlineinherited

Equality operator.

Definition at line 52 of file Token.h.

52 { return equal(refToken); }

◆ operator>()

bool Token::operator> ( const Token refToken) const
inlineinherited

Operator > to allow ordering.

Definition at line 47 of file Token.h.

47  {
48  if (less(refToken)) return false;
49  return !equal(refToken);
50  }

◆ release()

int Token::release ( )
inherited

Release token: Decrease reference count and eventually delete.

Definition at line 80 of file Token.cxx.

80  {
81  int cnt = --m_refCount;
82  if (0 >= cnt) {
83  delete this;
84  }
85  return cnt;
86 }

◆ removeTypeSetting()

void pool::DbToken::removeTypeSetting ( int  val)
inline

Add type setting.

Definition at line 86 of file DbToken.h.

86 { setType(type() & ~val); }

◆ set()

const Token & Token::set ( Token pToken) const
inherited

Set token information.

Definition at line 216 of file Token.cxx.

216  {
217  pToken->m_technology = m_technology;
218  pToken->m_dbID = m_dbID;
219  pToken->m_cntID = m_cntID;
220  pToken->m_classID = m_classID;
221  pToken->m_oid.first = m_oid.first;
222  return *this;
223 }

◆ setAuxString()

Token& Token::setAuxString ( const std::string &  auxString)
inlineinherited

Set auxiliary string.

Definition at line 93 of file Token.h.

93 { m_auxString = auxString; return *this; }

◆ setClassID()

Token& Token::setClassID ( const Guid cl_id)
inlineinherited

Access database identifier.

Definition at line 75 of file Token.h.

75 { m_classID = cl_id; return *this; }

◆ setCont()

Token& Token::setCont ( const std::string &  cnt)
inlineinherited

Set container name.

Definition at line 71 of file Token.h.

71 { m_cntID = cnt; return *this; }

◆ setData()

const Token & Token::setData ( Token pToken) const
inherited

Set all the data part of the token.

Definition at line 225 of file Token.cxx.

225  {
226  this->set(pToken);
227  pToken->m_oid.second = m_oid.second;
228  pToken->m_type = m_type;
229  pToken->m_auxString = m_auxString;
230  return *this;
231 }

◆ setDb() [1/2]

Token& Token::setDb ( const Guid db)
inlineinherited

Set database name.

Definition at line 66 of file Token.h.

66 { m_dbID = db; return *this; }

◆ setDb() [2/2]

Token& Token::setDb ( const std::string &  db)
inlineinherited

Definition at line 67 of file Token.h.

67 { m_dbID.fromString(db); return *this; }

◆ setKey()

void pool::DbToken::setKey ( int  which)

Produce the keys only on demand.

◆ setKeyEx()

void pool::DbToken::setKeyEx ( int  which,
const Guid guid 
)

Copy the key.

◆ setLocal()

void pool::DbToken::setLocal ( bool  val)
inline

Set local flag.

Definition at line 80 of file DbToken.h.

80 { m_local = val; }

◆ setOid()

Token& Token::setOid ( const OID_t oid)
inlineinherited

Set object identifier.

Definition at line 85 of file Token.h.

85 { m_oid = oid; return *this; }

◆ setTechnology()

Token& Token::setTechnology ( int  t)
inlineinherited

Set technology type.

Definition at line 79 of file Token.h.

79 { m_technology = t; return *this; }

◆ setType()

Token& Token::setType ( int  t)
inlineinherited

Set token type.

Definition at line 89 of file Token.h.

89 { m_type = t; return *this; }

◆ setTypeInfo()

void pool::DbToken::setTypeInfo ( const DbTypeInfo t)
inline

Update type information.

Definition at line 76 of file DbToken.h.

76 { m_info = t; }

◆ setUserKey()

void pool::DbToken::setUserKey ( int  i,
const Guid guid 
)

Set a user key.

◆ technology()

int Token::technology ( ) const
inlineinherited

Access technology type.

Definition at line 77 of file Token.h.

77 { return m_technology; }

◆ toString()

const std::string Token::toString ( ) const
virtualinherited

Retrieve the string representation of the token.

Definition at line 134 of file Token.cxx.

134  {
135  return std::format(
136  "[DB={}][CNT={}][CLID={}][TECH={:08X}][OID={:016X}-{:016X}]{}",
138  m_cntID,
140  m_technology,
141  static_cast<uint64_t>(m_oid.first),
142  static_cast<uint64_t>(m_oid.second),
144  );
145 }

◆ type()

int Token::type ( ) const
inlineinherited

Access token type.

Definition at line 87 of file Token.h.

87 { return m_type; }

◆ typeInfo()

const DbTypeInfo* pool::DbToken::typeInfo ( ) const
inline

Access type information.

Definition at line 78 of file DbToken.h.

78 { return m_info; }

◆ userkey()

const Guid& pool::DbToken::userkey ( int  i) const
inline

Access to optional user keys #2.

Definition at line 92 of file DbToken.h.

92 { return m_ukeys[i]; }

Member Data Documentation

◆ m_auxString

std::string Token::m_auxString
privateinherited

Auxiliary string.

Definition at line 125 of file Token.h.

◆ m_classID

Guid Token::m_classID
privateinherited

Object global identifier.

Definition at line 119 of file Token.h.

◆ m_cntID

std::string Token::m_cntID
privateinherited

Container identifier.

Definition at line 117 of file Token.h.

◆ m_contKey

Guid pool::DbToken::m_contKey
private

Buffer to hold user key #1.

Definition at line 53 of file DbToken.h.

◆ m_dbID

Guid Token::m_dbID
privateinherited

Database identifier.

Definition at line 115 of file Token.h.

◆ m_info

const DbTypeInfo* pool::DbToken::m_info
private

Database type information cache.

Definition at line 57 of file DbToken.h.

◆ m_keyFull

Guid pool::DbToken::m_keyFull
private

Buffer to hold user key identifying full token.

Definition at line 51 of file DbToken.h.

◆ m_local

bool pool::DbToken::m_local
private

Flag to indicate if toekn is local or foreign.

Definition at line 59 of file DbToken.h.

◆ m_oid

OID_t Token::m_oid
privateinherited

Persistent object identifier.

Definition at line 121 of file Token.h.

◆ m_refCount

int Token::m_refCount
privateinherited

Reference count.

Definition at line 111 of file Token.h.

◆ m_technology

unsigned int Token::m_technology
privateinherited

Technology identifier.

Definition at line 113 of file Token.h.

◆ m_type

int Token::m_type
privateinherited

Token type.

Definition at line 123 of file Token.h.

◆ m_ukeys

std::vector< Guid > pool::DbToken::m_ukeys
private

Optional other user keys.

Definition at line 55 of file DbToken.h.


The documentation for this class was generated from the following file:
Token::m_type
int m_type
Token type.
Definition: Token.h:123
vtune_athena.format
format
Definition: vtune_athena.py:14
pool::DbToken::m_keyFull
Guid m_keyFull
Buffer to hold user key identifying full token.
Definition: DbToken.h:51
Guid::fromString
constexpr void fromString(std::string_view s)
Automatic conversion from string representation.
Definition: Guid.h:143
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
WriteCellNoiseToCool.src
src
Definition: WriteCellNoiseToCool.py:513
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:42
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
Token::auxString
const std::string & auxString() const
Access auxiliary string.
Definition: Token.h:91
pool::DbToken::m_contKey
Guid m_contKey
Buffer to hold user key #1.
Definition: DbToken.h:53
Token::m_dbID
Guid m_dbID
Database identifier.
Definition: Token.h:115
python.SystemOfUnits.second
float second
Definition: SystemOfUnits.py:135
Token::m_technology
unsigned int m_technology
Technology identifier.
Definition: Token.h:113
Token::less
virtual bool less(const Token &pTok) const
Fast token comparison: operator less.
Definition: Token.cxx:114
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Guid::to_fixed_string
constexpr Guid::string to_fixed_string(bool uppercase=true) const
Definition: Guid.h:70
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
pool::DbToken::TOKEN_FULL_KEY
@ TOKEN_FULL_KEY
Definition: DbToken.h:45
Token::m_classID
Guid m_classID
Object global identifier.
Definition: Token.h:119
LABEL_OID
constexpr std::string_view LABEL_OID
Definition: Token.cxx:19
Token::m_cntID
std::string m_cntID
Container identifier.
Definition: Token.h:117
LABEL_TECH
constexpr std::string_view LABEL_TECH
Definition: Token.cxx:18
Token::setType
Token & setType(int t)
Set token type.
Definition: Token.h:89
Token::equal
virtual bool equal(const Token &pTok) const
Fast token comparison: operator equals.
Definition: Token.cxx:97
lumiFormat.i
int i
Definition: lumiFormat.py:85
LABEL_CNT
constexpr std::string_view LABEL_CNT
Definition: Token.cxx:16
add-xsec-uncert-quadrature-N.label
label
Definition: add-xsec-uncert-quadrature-N.py:104
pool::DbToken::TOKEN_ITERATOR
@ TOKEN_ITERATOR
Definition: DbToken.h:47
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
pool::DbToken::m_ukeys
std::vector< Guid > m_ukeys
Optional other user keys.
Definition: DbToken.h:55
Token::m_oid
OID_t m_oid
Persistent object identifier.
Definition: Token.h:121
Token::type
int type() const
Access token type.
Definition: Token.h:87
pool::DbToken::m_info
const DbTypeInfo * m_info
Database type information cache.
Definition: DbToken.h:57
LABEL_DB
constexpr std::string_view LABEL_DB
Definition: Token.cxx:15
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
LABEL_CLID
constexpr std::string_view LABEL_CLID
Definition: Token.cxx:17
Token::m_auxString
std::string m_auxString
Auxiliary string.
Definition: Token.h:125
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Token::oid
const OID_t & oid() const
Access object identifier.
Definition: Token.h:81
DeMoScan.first
bool first
Definition: DeMoScan.py:534
Token::m_refCount
int m_refCount
Reference count.
Definition: Token.h:111
Token::set
const Token & set(Token *pToken) const
Set token information.
Definition: Token.cxx:216
pool::DbToken::m_local
bool m_local
Flag to indicate if toekn is local or foreign.
Definition: DbToken.h:59
pool::DbToken::TOKEN_CONT_KEY
@ TOKEN_CONT_KEY
Definition: DbToken.h:46