Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental support for HDFS (#1243)
* Read and write datsets from hdfs. * Only enabled when cmake is run with -DUSE_HDFS:BOOL=TRUE * Introduces VirtualFile(Reader|Writer) to asbtract VFS differences
- Loading branch information
1 parent
7501faa
commit 7e186a5
Showing
18 changed files
with
418 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#ifndef LIGHTGBM_UTILS_FILE_IO_H_ | ||
#define LIGHTGBM_UTILS_FILE_IO_H_ | ||
|
||
#include <memory> | ||
|
||
namespace LightGBM{ | ||
|
||
/*! | ||
* \brief An interface for writing files from buffers | ||
*/ | ||
struct VirtualFileWriter { | ||
virtual ~VirtualFileWriter() {}; | ||
/*! | ||
* \brief Initialize the writer | ||
* \return True when the file is available for writes | ||
*/ | ||
virtual bool Init() = 0; | ||
/*! | ||
* \brief Append buffer to file | ||
* \param data Buffer to write from | ||
* \param bytes Number of bytes to write from buffer | ||
* \return Number of bytes written | ||
*/ | ||
virtual size_t Write(const void* data, size_t bytes) const = 0; | ||
/*! | ||
* \brief Create appropriate writer for filename | ||
* \param filename Filename of the data | ||
* \return File writer instance | ||
*/ | ||
static std::unique_ptr<VirtualFileWriter> Make(const std::string& filename); | ||
/*! | ||
* \brief Check filename existence | ||
* \param filename Filename of the data | ||
* \return True when the file exists | ||
*/ | ||
static bool Exists(const std::string& filename); | ||
}; | ||
|
||
/** | ||
* \brief An interface for reading files into buffers | ||
*/ | ||
struct VirtualFileReader { | ||
/*! | ||
* \brief Constructor | ||
* \param filename Filename of the data | ||
*/ | ||
virtual ~VirtualFileReader() {}; | ||
/*! | ||
* \brief Initialize the reader | ||
* \return True when the file is available for read | ||
*/ | ||
virtual bool Init() = 0; | ||
/*! | ||
* \brief Read data into buffer | ||
* \param buffer Buffer to read data into | ||
* \param bytes Number of bytes to read | ||
* \return Number of bytes read | ||
*/ | ||
virtual size_t Read(void* buffer, size_t bytes) const = 0; | ||
/*! | ||
* \brief Create appropriate reader for filename | ||
* \param filename Filename of the data | ||
* \return File reader instance | ||
*/ | ||
static std::unique_ptr<VirtualFileReader> Make(const std::string& filename); | ||
}; | ||
|
||
} // namespace LightGBM | ||
|
||
#endif // LightGBM_UTILS_FILE_IO_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.