Merge commit '3d11f56880521c1d45504c965ae12886e9b72ace'

This commit is contained in:
tqchen
2015-04-08 17:39:45 -07:00
29 changed files with 225 additions and 228 deletions

View File

@@ -33,9 +33,9 @@ static const char EncodeTable[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
} // namespace base64
/*! \brief the stream that reads from base64, note we take from file pointers */
class Base64InStream: public IStream {
class Base64InStream: public Stream {
public:
explicit Base64InStream(IStream *fs) : reader_(256) {
explicit Base64InStream(Stream *fs) : reader_(256) {
reader_.set_stream(fs);
num_prev = 0; tmp_ch = 0;
}
@@ -147,9 +147,9 @@ class Base64InStream: public IStream {
static const bool kStrictCheck = false;
};
/*! \brief the stream that write to base64, note we take from file pointers */
class Base64OutStream: public IStream {
class Base64OutStream: public Stream {
public:
explicit Base64OutStream(IStream *fp) : fp(fp) {
explicit Base64OutStream(Stream *fp) : fp(fp) {
buf_top = 0;
}
virtual void Write(const void *ptr, size_t size) {
@@ -198,7 +198,7 @@ class Base64OutStream: public IStream {
}
private:
IStream *fp;
Stream *fp;
int buf_top;
unsigned char buf[4];
std::string out_buf;

View File

@@ -20,7 +20,7 @@ class StreamBufferReader {
/*!
* \brief set input stream
*/
inline void set_stream(IStream *stream) {
inline void set_stream(Stream *stream) {
stream_ = stream;
read_len_ = read_ptr_ = 1;
}
@@ -45,7 +45,7 @@ class StreamBufferReader {
private:
/*! \brief the underlying stream */
IStream *stream_;
Stream *stream_;
/*! \brief buffer to hold data */
std::string buffer_;
/*! \brief length of valid data in buffer */

View File

@@ -15,7 +15,7 @@
namespace rabit {
namespace io {
/*! \brief implementation of file i/o stream */
class FileStream : public utils::ISeekStream {
class FileStream : public utils::SeekStream {
public:
explicit FileStream(const char *fname, const char *mode)
: use_stdio(false) {
@@ -84,7 +84,7 @@ class FileProvider : public LineSplitter::IFileProvider {
}
// destrucor
virtual ~FileProvider(void) {}
virtual utils::ISeekStream *Open(size_t file_index) {
virtual utils::SeekStream *Open(size_t file_index) {
utils::Assert(file_index < fnames_.size(), "file index exceed bound");
return new FileStream(fnames_[file_index].c_str(), "rb");
}

View File

@@ -16,7 +16,7 @@
/*! \brief io interface */
namespace rabit {
namespace io {
class HDFSStream : public ISeekStream {
class HDFSStream : public SeekStream {
public:
HDFSStream(hdfsFS fs,
const char *fname,
@@ -147,7 +147,7 @@ class HDFSProvider : public LineSplitter::IFileProvider {
virtual const std::vector<size_t> &FileSize(void) const {
return fsize_;
}
virtual ISeekStream *Open(size_t file_index) {
virtual SeekStream *Open(size_t file_index) {
utils::Assert(file_index < fnames_.size(), "file index exceed bound");
return new HDFSStream(fs_, fnames_[file_index].c_str(), "r", false);
}

View File

@@ -50,7 +50,7 @@ inline InputSplit *CreateInputSplit(const char *uri,
}
template<typename TStream>
class StreamAdapter : public IStream {
class StreamAdapter : public Stream {
public:
explicit StreamAdapter(TStream *stream)
: stream_(stream) {
@@ -75,9 +75,9 @@ class StreamAdapter : public IStream {
* \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) {
inline Stream *CreateStream(const char *uri, const char *mode) {
#if RABIT_USE_WORMHOLE
return new StreamAdapter<dmlc::IStream>(dmlc::IStream::Create(uri, mode));
return new StreamAdapter<dmlc::Stream>(dmlc::Stream::Create(uri, mode));
#else
using namespace std;
if (!strncmp(uri, "file://", 7)) {

View File

@@ -26,12 +26,12 @@ namespace rabit {
* \brief namespace to handle input split and filesystem interfacing
*/
namespace io {
/*! \brief reused ISeekStream's definition */
/*! \brief reused SeekStream's definition */
#if RABIT_USE_WORMHOLE
typedef dmlc::ISeekStream ISeekStream;
typedef dmlc::SeekStream SeekStream;
typedef dmlc::InputSplit InputSplit;
#else
typedef utils::ISeekStream ISeekStream;
typedef utils::SeekStream SeekStream;
/*!
* \brief user facing input split helper,
* can be used to get the partition of data used by current node
@@ -65,7 +65,7 @@ inline InputSplit *CreateInputSplit(const char *uri,
* \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);
inline Stream *CreateStream(const char *uri, const char *mode);
} // namespace io
} // namespace rabit

View File

@@ -26,7 +26,7 @@ class LineSplitter : public InputSplit {
* \return the corresponding seek stream at head of the stream
* the seek stream's resource can be freed by calling delete
*/
virtual ISeekStream *Open(size_t file_index) = 0;
virtual SeekStream *Open(size_t file_index) = 0;
/*!
* \return const reference to size of each files
*/
@@ -142,7 +142,7 @@ class LineSplitter : public InputSplit {
/*! \brief FileProvider */
IFileProvider *provider_;
/*! \brief current input stream */
utils::ISeekStream *fs_;
utils::SeekStream *fs_;
/*! \brief file pointer of which file to read on */
size_t file_ptr_;
/*! \brief file pointer where the end of file lies */