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

Util::IOBuffer* Impala::Persistency::FileSystem::GetIOBuffer ( CString  fileName,
bool  readMode,
bool  useMemoryIfLocal,
String  useLocalFileIfRemote,
Int64  useLocalSizeIfRemote = 0,
bool  useIOBufferChannel = false 
) [inline]

Obtain a new IOBuffer to read/write the given fileName.

Ownership lies with caller.

The function checks whether the data server should be used. The user has some control over the type of buffer returned via the other parameters: useMemoryIfLocal determines whether the buffer should be memory or file based in case there is no data server. In case there is a data server, useLocalFileIfRemote determines whether the buffer should be file based or memory based. In the latter case, useLocalSizeIfRemote determines the (fixed) size of the buffer.

The SAFE way to use this function is. For a read mode buffer: GetIOBuffer(fileName, true, false, ""); For a write mode buffer: GetIOBuffer(fileName, false, false, "tmp");

The BEST way to use this function is. Read mode buffer: GetIOBuffer(fileName, true, false, "", 0, true); Write mode buffer: GetIOBuffer(fileName, false, false, "tmp", 0, true);

Definition at line 129 of file FileSystem.h.

References Impala::FileNameTmp(), ILOG_DEBUG, mDataChannel, mDataServer, Impala::Util::ReadIOBufferFromChannel(), Impala::Util::IOBuffer::SetUseChannel(), and Impala::Util::IOBuffer::Valid().

Referenced by Impala::Persistency::File::GetReadBuffer(), and Impala::Persistency::File::GetWriteBuffer().

00132     {
00133         Util::IOBuffer* res = 0;
00134         ILOG_DEBUG("GetIOBuffer [" << fileName << "]");
00135         if (mDataChannel)
00136         {
00137             if (readMode)
00138             {
00139                 if (useIOBufferChannel)
00140                 {
00141                     ILOG_DEBUG("GetIOBuffer: Read using Channel to " <<
00142                                mDataServer << ": " << fileName);
00143                     res = new Util::IOBufferChannel(fileName, true,
00144                                                     mDataChannel);
00145                 }
00146                 else
00147                 {
00148                     ILOG_DEBUG("GetIOBuffer: Read using File: " << fileName);
00149                     /* the race condition that occurs when someone passes in
00150                        "tmp" while reading a file is very difficult to track
00151                        down (only happens with MPI-jobs). Therefore, generate 
00152                        a temporary filename even in read mode */
00153                     if (useLocalFileIfRemote == "tmp")
00154                         useLocalFileIfRemote = FileNameTmp();
00155                     res = Util::ReadIOBufferFromChannel(mDataChannel, fileName,
00156                                                         useLocalFileIfRemote);
00157                 }
00158             }
00159             else
00160             {
00161                 if (useIOBufferChannel)
00162                 {
00163                     ILOG_DEBUG("GetIOBuffer: Write using Channel " << fileName);
00164                     res = new Util::IOBufferChannel(fileName, false,
00165                                                     mDataChannel);
00166                 }
00167                 else if (useLocalFileIfRemote.empty())
00168                 {
00169                     ILOG_DEBUG("GetIOBuffer: Write using mem " << fileName);
00170                     res = new Util::IOBuffer(useLocalSizeIfRemote);
00171                 }
00172                 else
00173                 {
00174                     ILOG_DEBUG("GetIOBuffer: Write using File " << fileName);
00175                     if (useLocalFileIfRemote == "tmp")
00176                         useLocalFileIfRemote = FileNameTmp();
00177                     res = new Util::IOBufferFile(useLocalFileIfRemote, false,
00178                                                  false);
00179                 }
00180                 if (!useIOBufferChannel)
00181                     res->SetUseChannel(mDataChannel, fileName,
00182                                        useLocalFileIfRemote);
00183             }
00184         }
00185         else
00186         {
00187             res = new Util::IOBufferFile(fileName, readMode, useMemoryIfLocal);
00188         }
00189 
00190         if (res)
00191         {
00192             if (!res->Valid())
00193             {
00194                 delete res;
00195                 res = 0;
00196             }
00197         }
00198         return res;
00199     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:35:17 2010 for ImpalaSrc by  doxygen 1.5.1