ATLAS Offline Software
Loading...
Searching...
No Matches
CollectionCursor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#include "CoralBase/Attribute.h"
5
6#include "CollectionCursor.h"
7#include "CollectionColumn.h"
8
11
12using namespace pool;
13
14
16 const CollectionRowBuffer& collectionRowBuffer,
17 ContainerMap& containers
18 )
19 : m_collectionRowBuffer( collectionRowBuffer ),
20 m_attrContainers( containers ),
21 m_tokenContainer( containers[CollectionColumn::tokenColumn().name()] ),
22 m_idx( -1 )
23{
24}
25
26
28{
29 if( ++m_idx >= size() ) {
30 return false;
31 }
32 // read the row
33 Token cnt_token(m_tokenContainer.token());
34 Token::OID_t oid { cnt_token.oid().first, (std::int64_t)m_idx };
35 for( auto& attr : m_collectionRowBuffer.attributeList() ) {
36 const std::string& attr_name = attr.specification().name();
37 DbContainer &container = m_attrContainers.at( attr_name );
38 void *obj = attr.addressOfData();
39 if( !container.load( &obj, nullptr, oid ).isSuccess() ) {
40 return false;
41 }
42 }
43
44 const std::string& newDHContName = std::format("{}(DataHeader)", APRDefaults::ReadConfig::getDataHeaderName( cnt_token.dbID().toString() ));
45 const std::string& oldDHContName = std::format("{}_DataHeader", APRDefaults::ReadConfig::getDataHeaderName( cnt_token.dbID().toString() ));
46 if( cnt_token.contID() == newDHContName || cnt_token.contID() == oldDHContName ) {
47 cnt_token.setOid(oid);
48 m_tokenStr = cnt_token.toString();
49 } else {
50 // read the Token
51 void *token_addr = &m_tokenStr;
52 if( !m_tokenContainer.load( &token_addr, nullptr, oid ).isSuccess() ) {
53 return false;
54 }
55 }
56 m_collectionRowBuffer.token().fromString( m_tokenStr );
57 return true;
58}
59
60
66
67
69{
70 return m_tokenContainer.size();
71}
72
73
74bool CollectionCursor::seek(std::size_t position)
75{
76 if( position >= size() ) {
77 return false;
78 }
79 m_idx = position-1;
80 return true;
81}
82
83
85{
86 return m_collectionRowBuffer.token();
87}
constexpr void toString(std::span< char, StrLen > buf, bool uppercase=true) const noexcept
Automatic conversion to string representation.
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:22
const std::string & contID() const
Access container identifier.
Definition Token.h:70
const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:135
Token & setOid(const OID_t &oid)
Set object identifier.
Definition Token.h:86
const OID_t & oid() const
Access object identifier.
Definition Token.h:82
const Guid & dbID() const
Access database identifier.
Definition Token.h:65
An implementation for retrieving a description of a column of a collection.
ContainerMap & m_attrContainers
bool next()
Advances the cursor to the next row of the result set.
CollectionRowBuffer m_collectionRowBuffer
Row buffer containing the Token and Attributes.
DbContainer & m_tokenContainer
Container for the event reference.
const CollectionRowBuffer & currentRow() const
Returns the selected Tokens and Attributes for the current row of the result set.
CollectionCursor(const CollectionRowBuffer &collectionRowBuffer, ContainerMap &attrContainers)
std::size_t size()
Return the size of the collection.
bool seek(std::size_t position)
Seeks the cursor to a given position in the collection.
const Token & eventRef() const
Returns the event reference Token for the current row.
std::string m_tokenStr
Temporary storage for Event Reference in string format as it is in RNTuple.
A class representing a row of a collection.
Description: Definition of the object describing a database container Handle managing a DbContainerOb...
Definition DbContainer.h:48
std::string getDataHeaderName(std::string_view databaseName)
std::map< std::string, DbContainer > ContainerMap