59e63bc minor 6233050 ok 14477f9 add namenode 75a6d34 add libhdfs opts e3c76bf minmum fix 8b3c435 chg 2035799 test code 7751b2b add debug 7690313 ok bd346b4 ok faba1dc add testload 6f7783e add testload e5f0340 ok 3ed9ec8 chg e552ac4 ask for more ram in am b2505e3 only stop nm when sucess bc696c9 add queue info f3e867e add option queue 5dc843c refactor fileio cd9c81b quick fix 1e23af2 add virtual destructor to iseekstream f165ffb fix hdfs 8cc6508 allow demo to pass in env fad4d69 ok 0fd6197 fix more 7423837 fix more d25de54 add temporal solution, run_yarn_prog.py e5a9e31 final attempt ed3bee8 add command back 0774000 add hdfs to resource 9b66e7e fix hadoop 6812f14 ok 08e1c16 change hadoop prefix back to hadoop home d6b6828 Update build.sh 146e069 bugfix: logical boundary for ring buffer 19cb685 ok 4cf3c13 Merge branch 'master' of ssh://github.com/tqchen/rabit 20daddb add tracker c57dad8 add ringbased passing and batch schedule 295d8a1 update 994cb02 add sge 014c866 OK git-subtree-dir: subtree/rabit git-subtree-split: 59e63bc1354c9ff516d72d9a6468f6c431627202
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
#ifndef RABIT_LEARN_IO_IO_INL_H_
|
|
#define RABIT_LEARN_IO_IO_INL_H_
|
|
/*!
|
|
* \file io-inl.h
|
|
* \brief Input/Output utils that handles read/write
|
|
* of files in distrubuted enviroment
|
|
* \author Tianqi Chen
|
|
*/
|
|
#include <cstring>
|
|
|
|
#include "./io.h"
|
|
#if RABIT_USE_HDFS
|
|
#include "./hdfs-inl.h"
|
|
#endif
|
|
#include "./file-inl.h"
|
|
|
|
namespace rabit {
|
|
namespace io {
|
|
/*!
|
|
* \brief create input split given a uri
|
|
* \param uri the uri of the input, can contain hdfs prefix
|
|
* \param part the part id of current input
|
|
* \param nsplit total number of splits
|
|
*/
|
|
inline InputSplit *CreateInputSplit(const char *uri,
|
|
unsigned part,
|
|
unsigned nsplit) {
|
|
using namespace std;
|
|
if (!strcmp(uri, "stdin")) {
|
|
return new SingleFileSplit(uri);
|
|
}
|
|
if (!strncmp(uri, "file://", 7)) {
|
|
return new LineSplitter(new FileProvider(uri), part, nsplit);
|
|
}
|
|
if (!strncmp(uri, "hdfs://", 7)) {
|
|
#if RABIT_USE_HDFS
|
|
return new LineSplitter(new HDFSProvider(uri), part, nsplit);
|
|
#else
|
|
utils::Error("Please compile with RABIT_USE_HDFS=1");
|
|
#endif
|
|
}
|
|
return new LineSplitter(new FileProvider(uri), part, nsplit);
|
|
}
|
|
/*!
|
|
* \brief create an stream, the stream must be able to close
|
|
* the underlying resources(files) when deleted
|
|
*
|
|
* \param uri the uri of the input, can contain hdfs prefix
|
|
* \param mode can be 'w' or 'r' for read or write
|
|
*/
|
|
inline IStream *CreateStream(const char *uri, const char *mode) {
|
|
using namespace std;
|
|
if (!strncmp(uri, "file://", 7)) {
|
|
return new FileStream(uri + 7, mode);
|
|
}
|
|
if (!strncmp(uri, "hdfs://", 7)) {
|
|
#if RABIT_USE_HDFS
|
|
return new HDFSStream(hdfsConnect(HDFSStream::GetNameNode().c_str(), 0),
|
|
uri, mode, true);
|
|
#else
|
|
utils::Error("Please compile with RABIT_USE_HDFS=1");
|
|
#endif
|
|
}
|
|
return new FileStream(uri, mode);
|
|
}
|
|
} // namespace io
|
|
} // namespace rabit
|
|
#endif // RABIT_LEARN_IO_IO_INL_H_
|