Create and an IOBuffer and fill it with data from fileName obtained via a Channel. If useLocalFile is an empty string a memory buffer will be used, otherwise the data will be copied to the given local file. Definition at line 17 of file ReadIOBufferFromChannel.h. References Impala::Util::Channel::Buffer(), Impala::Util::Channel::DATA_BUFFER_SIZE, Impala::Util::Channel::GetServerInfo(), ILOG_DEBUG, ILOG_VAR, Impala::Util::Channel::LastSendHadError(), and Impala::Util::Channel::SendRequest(). Referenced by Impala::Application::Client::ExampleReadRaw(), Impala::Util::Database::GetIOBuffer(), and Impala::Persistency::FileSystem::GetIOBuffer(). 00019 { 00020 ILOG_VAR(Impala.Util.ReadIOBufferFromChannel); 00021 char* buf = channel->Buffer(); 00022 sprintf(buf, "openfilebuffer \"%s\" 1\0", fileName.c_str()); 00023 channel->SendRequest(strlen(buf)+1); 00024 if (channel->LastSendHadError()) 00025 return 0; 00026 int id = 0; 00027 Int64 bufSize = 0; 00028 sscanf(buf, "%d %lld", &id, &bufSize); 00029 ILOG_DEBUG(fileName << ", id=" << id << ", size=" << bufSize << " from " 00030 << channel->GetServerInfo()); 00031 00032 IOBuffer* ioBuf = 0; 00033 if (useLocalFile.empty()) 00034 ioBuf = new IOBuffer(bufSize); 00035 else 00036 ioBuf = new IOBufferFile(useLocalFile, false, false); 00037 Int64 nrRead = 0; 00038 while (nrRead < bufSize) 00039 { 00040 sprintf(buf, "readfilebuffer %d %d\0", id, Channel::DATA_BUFFER_SIZE); 00041 int len = channel->SendRequest(strlen(buf)+1); 00042 if (channel->LastSendHadError()) 00043 break; 00044 ioBuf->Write(buf, len); 00045 nrRead += len; 00046 ILOG_DEBUG(" wrote " << len << " bytes, total = " << nrRead); 00047 } 00048 sprintf(buf, "closefilebuffer %d\0", id); 00049 channel->SendRequest(strlen(buf)+1); 00050 if (useLocalFile.empty()) 00051 { 00052 ioBuf->SetPosition(0); // to allow for subsequent reading by client 00053 } 00054 else 00055 { 00056 delete ioBuf; 00057 ioBuf = new IOBufferFile(useLocalFile, true, false); 00058 } 00059 return ioBuf; 00060 }
Here is the call graph for this function:
|