XRootD
XrdCephReadVBasic.cc
Go to the documentation of this file.
1 
2 #include "XrdCephReadVBasic.hh"
3 #include "BufferUtils.hh"
4 
5 using namespace XrdCephBuffer;
6 
7 
9 
10  size_t totalBytes = m_usedBytes + m_wastedBytes;
11  float goodFrac_pct = totalBytes > 0 ? m_usedBytes/(totalBytes*100.) : 0;
12  BUFLOG("XrdCephReadVBasic: Summary: "
13  << " Used: " << m_usedBytes << " Wasted: " << m_wastedBytes << " goodFrac: "
14  << goodFrac_pct
15  );
16 }
17 
18 std::vector<ExtentHolder> XrdCephReadVBasic::convert(const ExtentHolder &extentsHolderInput)
19 {
20  std::vector<ExtentHolder> outputs;
21 
22  const ExtentContainer &extentsIn = extentsHolderInput.extents();
23 
24  ExtentContainer::const_iterator it_l = extentsIn.begin();
25  ExtentContainer::const_iterator it_r = extentsIn.begin();
26  ExtentContainer::const_iterator it_end = extentsIn.end();
27 
28  // Shortcut the process if range is small
29  if ((it_end->end() - it_l->begin()) <= m_minSize) {
30  ExtentHolder tmp(extentsIn);
31  outputs.push_back(tmp);
32  BUFLOG("XrdCephReadVBasic: Combine all extents: "
33  << tmp.size() << " "
34  << it_l->begin() << " " << it_end->end() );
35  return outputs;
36  }
37  size_t usedBytes(0);
38  size_t wastedBytes(0);
39 
40  // outer loop over extents
41  while (it_r != it_end)
42  {
43  ExtentHolder tmp;
44  int counter(0);
45  it_l = it_r;
46  // inner loop over each internal extent range
47  while (it_r != it_end) {
48  if ((it_r->end() - it_l->begin()) > m_maxSize) break; // start a new holder
49  tmp.push_back(*it_r); // just put it into an extent
50  ++it_r;
51  ++counter;
52  }
53  outputs.push_back(tmp);
54  usedBytes += tmp.bytesContained();
55  wastedBytes += tmp.bytesMissing();
56  }
57  m_usedBytes += usedBytes;
58  m_wastedBytes += wastedBytes;
59  BUFLOG("XrdCephReadVBasic: In size: " << extentsHolderInput.size() << " "
60  << extentsHolderInput.extents().size() << " " << outputs.size() << " "
61  << " useful bytes: " << usedBytes << " wasted bytes:" << wastedBytes);
62 
63 
64  return outputs;
65 } // convert
#define BUFLOG(x)
Definition: BufferUtils.hh:23
Designed to hold individual extents, but itself provide Extent-like capabilities Useful in cases of c...
Definition: BufferUtils.hh:109
size_t bytesContained() const
Definition: BufferUtils.cc:124
size_t size() const
number of extent elements
Definition: BufferUtils.hh:122
void push_back(const Extent &in)
Definition: BufferUtils.cc:101
const ExtentContainer & extents() const
Definition: BufferUtils.hh:133
virtual std::vector< ExtentHolder > convert(const ExtentHolder &extentsHolderInput) override
Take in a set of extents representing the readV requests. return a vector of each combined read reque...
is a simple implementation of IXrdCephBufferData using std::vector<char> representation for the buffe...
Definition: BufferUtils.hh:29
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