XRootD
XrdCephBuffer::ExtentHolder Class Reference

Designed to hold individual extents, but itself provide Extent-like capabilities Useful in cases of combining extends, or needing to hold a range of extends and extract information about (or aggregated from) the contained objects. Could be useful to inherit from Extent if improvements needed. More...

#include <BufferUtils.hh>

+ Collaboration diagram for XrdCephBuffer::ExtentHolder:

Public Member Functions

 ExtentHolder ()
 
 ExtentHolder (const ExtentContainer &extents)
 
 ExtentHolder (size_t elements)
 reserve memory only More...
 
 ~ExtentHolder ()
 
Extent asExtent () const
 
off_t begin () const
 
size_t bytesContained () const
 
size_t bytesMissing () const
 
bool empty () const
 Total range in bytes of the extents. More...
 
off_t end () const
 
const ExtentContainerextents () const
 
ExtentContainer getExtents () const
 
ExtentContainer getSortedExtents () const
 
size_t len () const
 
void push_back (const Extent &in)
 
size_t size () const
 number of extent elements More...
 
void sort ()
 inplace sort by offset of contained extents More...
 

Protected Attributes

off_t m_begin {0}
 
off_t m_end {0}
 
ExtentContainer m_extents
 

Detailed Description

Designed to hold individual extents, but itself provide Extent-like capabilities Useful in cases of combining extends, or needing to hold a range of extends and extract information about (or aggregated from) the contained objects. Could be useful to inherit from Extent if improvements needed.

Definition at line 109 of file BufferUtils.hh.

Constructor & Destructor Documentation

◆ ExtentHolder() [1/3]

ExtentHolder::ExtentHolder ( )

Definition at line 81 of file BufferUtils.cc.

81 {}

◆ ExtentHolder() [2/3]

ExtentHolder::ExtentHolder ( size_t  elements)
explicit

reserve memory only

Definition at line 83 of file BufferUtils.cc.

84 {
85  m_extents.reserve(elements);
86 }

References m_extents.

◆ ExtentHolder() [3/3]

ExtentHolder::ExtentHolder ( const ExtentContainer extents)
explicit

Definition at line 88 of file BufferUtils.cc.

89 {
90  m_extents.reserve(extents.size());
91  for (ExtentContainer::const_iterator vit = m_extents.cbegin(); vit != m_extents.cend(); ++vit) {
92  push_back(*vit);
93  }
94 
95 }
void push_back(const Extent &in)
Definition: BufferUtils.cc:101
const ExtentContainer & extents() const
Definition: BufferUtils.hh:133

References extents(), m_extents, and push_back().

+ Here is the call graph for this function:

◆ ~ExtentHolder()

ExtentHolder::~ExtentHolder ( )

Definition at line 96 of file BufferUtils.cc.

97 {
98  m_extents.clear();
99 }

References m_extents.

Member Function Documentation

◆ asExtent()

Extent ExtentHolder::asExtent ( ) const

Definition at line 114 of file BufferUtils.cc.

114  {
115  // if (!size()) return Extent(0,0);
116  // ExtentContainer se = getSortedExtents();
117  // off_t b = se.front().begin();
118  // off_t e = se.back().end();
119 
120  return Extent(m_begin, m_end-m_begin);
121 
122 }

References m_begin, and m_end.

Referenced by bytesMissing().

+ Here is the caller graph for this function:

◆ begin()

off_t XrdCephBuffer::ExtentHolder::begin ( ) const
inline

Definition at line 117 of file BufferUtils.hh.

117 {return m_begin;}

References m_begin.

Referenced by XrdCephOssReadVFile::ReadV().

+ Here is the caller graph for this function:

◆ bytesContained()

size_t ExtentHolder::bytesContained ( ) const

Definition at line 124 of file BufferUtils.cc.

124  {
125  size_t nbytes{0};
126  for (ExtentContainer::const_iterator vit = m_extents.cbegin(); vit != m_extents.cend(); ++vit) {
127  nbytes += vit->len();
128  }
129  return nbytes;
130 }

References m_extents.

Referenced by bytesMissing(), XrdCephBuffer::XrdCephReadVBasic::convert(), and XrdCephOssReadVFile::ReadV().

+ Here is the caller graph for this function:

◆ bytesMissing()

size_t ExtentHolder::bytesMissing ( ) const

Definition at line 132 of file BufferUtils.cc.

132  {
133  size_t bytesUsed = bytesContained();
134  size_t totalRange = asExtent().len(); //might be expensive to call
135  return totalRange - bytesUsed;
136 }
size_t bytesContained() const
Definition: BufferUtils.cc:124
size_t len() const
Definition: BufferUtils.hh:66

References asExtent(), bytesContained(), and XrdCephBuffer::Extent::len().

Referenced by XrdCephBuffer::XrdCephReadVBasic::convert(), and XrdCephOssReadVFile::ReadV().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty()

bool XrdCephBuffer::ExtentHolder::empty ( ) const
inline

Total range in bytes of the extents.

Definition at line 121 of file BufferUtils.hh.

121 {return m_extents.empty();}

References m_extents.

◆ end()

off_t XrdCephBuffer::ExtentHolder::end ( ) const
inline

Definition at line 118 of file BufferUtils.hh.

118 {return m_end;}

References m_end.

Referenced by XrdCephOssReadVFile::ReadV().

+ Here is the caller graph for this function:

◆ extents()

const ExtentContainer& XrdCephBuffer::ExtentHolder::extents ( ) const
inline

Definition at line 133 of file BufferUtils.hh.

133 {return m_extents;}

References m_extents.

Referenced by ExtentHolder(), XrdCephBuffer::XrdCephReadVBasic::convert(), and XrdCephBuffer::XrdCephReadVNoOp::convert().

+ Here is the caller graph for this function:

◆ getExtents()

ExtentContainer ExtentHolder::getExtents ( ) const

Definition at line 151 of file BufferUtils.cc.

151  {
152  ExtentContainer v;
153  v.assign(m_extents.begin(), m_extents.end() );
154  return v;
155 }
std::vector< Extent > ExtentContainer
Container defintion for Extents Typedef to provide a container of extents as a simple stl vector cont...
Definition: BufferUtils.hh:99

References m_extents.

◆ getSortedExtents()

ExtentContainer ExtentHolder::getSortedExtents ( ) const

Definition at line 144 of file BufferUtils.cc.

144  {
145  ExtentContainer v;
146  v.assign(m_extents.begin(), m_extents.end() );
147  std::sort(v.begin(), v.end());
148  return v;
149 }

References m_extents.

◆ len()

size_t XrdCephBuffer::ExtentHolder::len ( ) const
inline

Definition at line 119 of file BufferUtils.hh.

119 {return m_end - m_begin;}

References m_begin, and m_end.

Referenced by XrdCephOssReadVFile::ReadV().

+ Here is the caller graph for this function:

◆ push_back()

void ExtentHolder::push_back ( const Extent in)

Definition at line 101 of file BufferUtils.cc.

101  {
102  if (size()) {
103  m_begin = std::min(m_begin, in.begin());
104  m_end = std::max(m_end, in.end());
105  } else {
106  m_begin = in.begin();
107  m_end = in.end();
108  }
109  return m_extents.push_back(in);
110 }
size_t size() const
number of extent elements
Definition: BufferUtils.hh:122
off_t end() const
similar to stl vector end.
Definition: BufferUtils.hh:68
off_t begin() const
Same as offset, but a bit more stl container like.
Definition: BufferUtils.hh:67

References XrdCephBuffer::Extent::begin(), XrdCephBuffer::Extent::end(), m_begin, m_end, m_extents, and size().

Referenced by ExtentHolder(), XrdCephBuffer::XrdCephReadVBasic::convert(), XrdCephBuffer::XrdCephReadVNoOp::convert(), and XrdCephOssReadVFile::ReadV().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

size_t XrdCephBuffer::ExtentHolder::size ( ) const
inline

number of extent elements

Definition at line 122 of file BufferUtils.hh.

References m_extents.

Referenced by XrdCephBuffer::XrdCephReadVBasic::convert(), push_back(), and XrdCephOssReadVFile::ReadV().

+ Here is the caller graph for this function:

◆ sort()

void ExtentHolder::sort ( )

inplace sort by offset of contained extents

Definition at line 139 of file BufferUtils.cc.

139  {
140  std::sort(m_extents.begin(), m_extents.end());
141 }

References m_extents.

Member Data Documentation

◆ m_begin

off_t XrdCephBuffer::ExtentHolder::m_begin {0}
protected

Definition at line 144 of file BufferUtils.hh.

Referenced by asExtent(), begin(), len(), and push_back().

◆ m_end

off_t XrdCephBuffer::ExtentHolder::m_end {0}
protected

Definition at line 145 of file BufferUtils.hh.

Referenced by asExtent(), end(), len(), and push_back().

◆ m_extents

ExtentContainer XrdCephBuffer::ExtentHolder::m_extents
protected

The documentation for this class was generated from the following files: