test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ReadRepacker.h
Go to the documentation of this file.
1 
28 #include <vector>
29 
32 
33 class ReadRepacker {
34 
35 public:
36 
37 // Returns the number of input buffers it was able to pack into the IO operation.
38 int
39 pack(long long int *pos, // An array of file offsets to read.
40  int *len, // An array of lengths to read.
41  int nbuf, // Size of the pos and len array.
42  char *buf, // Temporary buffer to hold I/O result.
43  IOSize buffer_size); // Size of the temporary buffer.
44 
45 void
46 unpack(char *buf); // Buffer to unpack the I/O results into. Not the temporayr buffer and result buffer may overlap.
47 
48 std::vector<IOPosBuffer> & iov() { return m_iov; } // Returns the IO vector, optimized for storage.
49 
50 IOSize bufferUsed() const {return m_buffer_used;} // Returns the total amount of space in the temp buffer used.
51 IOSize extraBytes() const {return m_extra_bytes;} // Returns the number of extra bytes to be issued to the I/O system
52  // Note that (buffer_used - extra_bytes) should equal the number of "real" bytes serviced.
53 IOSize realBytesProcessed() const {return m_buffer_used-m_extra_bytes;} // Return the number of bytes of the input request that would be processed by the IO vector
54 
55 // Two reads distanced by less than READ_COALESCE_SIZE will turn into one
56 // large read.
57 static const IOSize TEMPORARY_BUFFER_SIZE = 256 * 1024;
58 
59 // A read larger than BIG_READ_SIZE will not be coalesced.
60 static const IOSize READ_COALESCE_SIZE = 32 * 1024;
61 
62 // The size of the temporary holding buffer for read-coalescing.
63 static const IOSize BIG_READ_SIZE = 256 * 1024;
64 
65 private:
66 
67 int packInternal(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size); // Heart of the implementation of Pack; because we pack up to 2 buffers,
68  // its easier to break the method into two.
69 
70 void reset(unsigned int nbuf); // Reset all the internal counters and arrays. Resize arrays to be about nbuf long.
71 
72 std::vector<int> m_idx_to_iopb; // Mapping from idx in the input array to the iopb in the IO vector
73 std::vector<int> m_idx_to_iopb_offset; // Mapping from idx in the input array to the data offset in the results of the iopb.
74 std::vector<IOPosBuffer> m_iov; // Vector of IO for the storage system to perform.
75 edm::propagate_const<int*> m_len; // Pointed to the array of read sizes.
76 IOSize m_buffer_used; // Bytes in the temporary buffer used.
77 IOSize m_extra_bytes; // Number of bytes read from storage that will be discarded.
78 std::vector<char> m_spare_buffer; // The spare buffer; allocated if we cannot fit the I/O results into the ROOT buffer.
79 
80 };
81 
std::vector< IOPosBuffer > m_iov
Definition: ReadRepacker.h:74
IOSize extraBytes() const
Definition: ReadRepacker.h:51
edm::propagate_const< int * > m_len
Definition: ReadRepacker.h:75
void reset(unsigned int nbuf)
IOSize realBytesProcessed() const
Definition: ReadRepacker.h:53
std::vector< char > m_spare_buffer
Definition: ReadRepacker.h:78
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
Definition: ReadRepacker.cc:22
void unpack(char *buf)
IOSize m_extra_bytes
Definition: ReadRepacker.h:77
IOSize bufferUsed() const
Definition: ReadRepacker.h:50
std::vector< int > m_idx_to_iopb_offset
Definition: ReadRepacker.h:73
std::vector< IOPosBuffer > & iov()
Definition: ReadRepacker.h:48
static const IOSize TEMPORARY_BUFFER_SIZE
Definition: ReadRepacker.h:57
int packInternal(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
Definition: ReadRepacker.cc:61
size_t IOSize
Definition: IOTypes.h:14
static const IOSize BIG_READ_SIZE
Definition: ReadRepacker.h:63
static const IOSize READ_COALESCE_SIZE
Definition: ReadRepacker.h:60
IOSize m_buffer_used
Definition: ReadRepacker.h:76
std::vector< int > m_idx_to_iopb
Definition: ReadRepacker.h:72