Exemplo n.º 1
0
 //! \brief Return the smallest contiguous area that needs to be
 //! uploaded. If there is no pending data, pos_start will be set to
 //! -1. You can call hasPendingData() before this method.
 std::pair<size_t, size_t> getPendingData() const
 {
   if (hasPendingData())
   {
     return std::make_pair(m_pending_start, m_pending_end);
   }
   else
   {
     return std::make_pair(0_z, 0_z);
   }
 }
Exemplo n.º 2
0
 //! \brief Update the range indexes of changed elements with a new range.
 void tagAsPending(const size_t pos_start, const size_t pos_end)
 {
   if (!hasPendingData())
     {
       m_pending_start = pos_start;
       m_pending_end = pos_end;
     }
   else
     {
       m_pending_start = maths::min(m_pending_start, pos_start);
       m_pending_end = maths::max(m_pending_end, pos_end);
     }
 }
Exemplo n.º 3
0
 //! \brief Return the smallest contiguous area that needs to be
 //! uploaded. If there is no pending data, pos_start will be set to
 //! -1. You can call hasPendingData() before this method.
 void getPendingData(size_t &pos_start, size_t &pos_end) const
 {
   if (hasPendingData())
   {
     pos_start = m_pending_start;
     pos_end = m_pending_end;
   }
   else
   {
     pos_start = 0_z;
     pos_end = 0_z;
   }
 }
Exemplo n.º 4
0
off_t ReadBufferAIO::doSeek(off_t off, int whence)
{
    off_t new_pos_in_file;

    if (whence == SEEK_SET)
    {
        if (off < 0)
            throw Exception("SEEK_SET underflow", ErrorCodes::ARGUMENT_OUT_OF_BOUND);
        new_pos_in_file = off;
    }
    else if (whence == SEEK_CUR)
    {
        if (off >= 0)
        {
            if (off > (std::numeric_limits<off_t>::max() - getPositionInFile()))
                throw Exception("SEEK_CUR overflow", ErrorCodes::ARGUMENT_OUT_OF_BOUND);
        }
        else if (off < -getPositionInFile())
            throw Exception("SEEK_CUR underflow", ErrorCodes::ARGUMENT_OUT_OF_BOUND);
        new_pos_in_file = getPositionInFile() + off;
    }
    else
        throw Exception("ReadBufferAIO::seek expects SEEK_SET or SEEK_CUR as whence", ErrorCodes::ARGUMENT_OUT_OF_BOUND);

    if (new_pos_in_file != getPositionInFile())
    {
        off_t first_read_pos_in_file = first_unread_pos_in_file - static_cast<off_t>(working_buffer.size());
        if (hasPendingData() && (new_pos_in_file >= first_read_pos_in_file) && (new_pos_in_file <= first_unread_pos_in_file))
        {
            /// Moved, but remained within the buffer.
            pos = working_buffer.begin() + (new_pos_in_file - first_read_pos_in_file);
        }
        else
        {
            /// Moved past the buffer.
            pos = working_buffer.end();
            first_unread_pos_in_file = new_pos_in_file;

            /// We can not use the result of the current asynchronous request.
            skip();
        }
    }

    return new_pos_in_file;
}