36 tmp_size = buffer_size;
39 int pack_count =
packInternal(pos, len, nbuf, tmp_buf, tmp_size);
41 if ((nbuf - pack_count > 0) &&
52 pack_count +=
packInternal(&pos[pack_count], &len[pack_count], nbuf-pack_count,
68 int iopb_offset =
m_iov.size();
71 assert(static_cast<IOSize>(len[0]) <= buffer_size);
76 IOSize buffer_used = len[0];
78 for (idx=1; idx < nbuf; idx++) {
79 if (buffer_used + len[idx] > buffer_size) {
84 IOOffset extra_bytes_signed = (idx == 0) ? 0 : ((pos[idx] - iopb.
offset()) - iopb.
size()); assert(extra_bytes_signed >= 0);
85 IOSize extra_bytes =
static_cast<IOSize>(extra_bytes_signed);
88 (extra_bytes <
READ_COALESCE_SIZE) && (buffer_used + len[idx] + extra_bytes <= buffer_size)) {
97 buffer_used += (len[
idx] + extra_bytes);
103 m_iov.push_back(iopb);
116 buffer_used += len[
idx];
118 m_iov.push_back(iopb);
132 char * root_result_ptr = buf;
138 char * io_result_ptr =
static_cast<char *
>(iopb.
data()) + iopb_offset;
141 memmove(root_result_ptr, io_result_ptr,
m_len[
idx]);
156 m_iov.reserve(nbuf/2);
std::vector< IOPosBuffer > m_iov
edm::propagate_const< int * > m_len
void set_data(void *new_buffer)
void set_size(IOSize new_size)
void reset(unsigned int nbuf)
std::vector< char > m_spare_buffer
void set_offset(IOOffset new_offset)
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
IOOffset offset(void) const
std::vector< int > m_idx_to_iopb_offset
static const IOSize TEMPORARY_BUFFER_SIZE
int packInternal(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
static const IOSize BIG_READ_SIZE
static const IOSize READ_COALESCE_SIZE
std::vector< int > m_idx_to_iopb