Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

bool Impala::Util::IOBuffer::WriteIOBufferToChannel (  )  [inline, protected]

Definition at line 518 of file IOBuffer.h.

References Available(), Impala::Util::Channel::Buffer(), Impala::Util::Channel::DATA_BUFFER_SIZE, GetPosition(), ILOG_DEBUG, ILOG_ERROR, Impala::Util::Channel::LastSendHadError(), mDataChannel, mDataChannelFile, Read(), Impala::Util::Channel::SendRequest(), SetPosition(), and SetSize().

Referenced by CheckDataChannelWrite(), and ~IOBuffer().

00519     {
00520         SetSize(GetPosition()); // assume the last write designates the end
00521         char* buf = mDataChannel->Buffer();
00522         sprintf(buf, "openfilebuffer \"%s\" 0\0", mDataChannelFile.c_str());
00523         mDataChannel->SendRequest(strlen(buf)+1);
00524         if (mDataChannel->LastSendHadError())
00525         {
00526             ILOG_ERROR("WriteIOBufferToChannel: open failed for [" <<
00527                        mDataChannelFile << "]");
00528             return false;
00529         }
00530         int id;
00531         Int64 bufSize;
00532         sscanf(buf, "%d %lld", &id, &bufSize); // bufSize is dummy when writing
00533         ILOG_DEBUG(mDataChannelFile << ", id = " << id);
00534 
00535         Int64 nrWritten = 0;
00536         SetPosition(0);
00537         while (Available() > 0)
00538         {
00539             sprintf(buf, "writefilebuffer %d\0", id);
00540             int used = strlen(buf) + 1;
00541             int nrData = Min<Int64>(Channel::DATA_BUFFER_SIZE-used, Available());
00542             Read(buf+used, nrData);
00543             int len = mDataChannel->SendRequest(used+nrData);
00544             if (mDataChannel->LastSendHadError())
00545             {
00546                 ILOG_ERROR("WriteIOBufferToChannel: write failed for [" <<
00547                            mDataChannelFile << "]");
00548                 break;
00549             }
00550             nrWritten += nrData;
00551             ILOG_DEBUG("  wrote " << nrData << " bytes, total = " << nrWritten);
00552         }
00553         sprintf(buf, "closefilebuffer %d\0", id);
00554         mDataChannel->SendRequest(strlen(buf)+1);
00555         return true;
00556     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:40:21 2010 for ImpalaSrc by  doxygen 1.5.1