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