21 HDFS_STREAMTYPE_UNINITIALIZED = 0,
22 HDFS_STREAMTYPE_INPUT = 1,
23 HDFS_STREAMTYPE_OUTPUT = 2,
29 struct hdfsFile_internal {
31 enum hdfsStreamType type;
40 #include <boost/iostreams/stream.hpp> 41 #include <core/logging/assertions.hpp> 60 typedef char char_type;
62 public boost::iostreams::device_tag,
63 public boost::iostreams::multichar_tag,
64 public boost::iostreams::closable_tag,
65 public boost::iostreams::bidirectional_seekable { };
76 hdfs_device() : filesystem(NULL), file(NULL) { }
78 hdfs_device(
const hdfs& hdfs_fs,
const std::string& filename,
const bool write =
false);
85 void close(std::ios_base::openmode mode = std::ios_base::openmode());
88 inline std::streamsize optimal_buffer_size()
const {
return 0; }
90 std::streamsize read(
char* strm_ptr, std::streamsize n);
92 std::streamsize write(
const char* strm_ptr, std::streamsize n);
94 bool good()
const {
return file != NULL; }
99 std::streampos seek(std::streamoff off,
100 std::ios_base::seekdir way,
101 std::ios_base::openmode);
107 typedef boost::iostreams::stream<hdfs_device> fstream;
113 hdfs(
const std::string& host =
"default", tPort port = 0);
115 bool good()
const {
return filesystem != NULL; }
119 const int error = hdfsDisconnect(filesystem);
127 std::vector<std::string> list_files(
const std::string& path)
const;
133 std::vector<std::pair<std::string, bool> > list_files_and_stat(
const std::string& path)
const;
138 size_t file_size(
const std::string& path)
const;
143 bool path_exists(
const std::string& path)
const;
149 bool is_directory(
const std::string& path)
const;
156 bool create_directories(
const std::string& path)
const;
161 bool chmod(
const std::string& path,
short mode)
const;
168 bool delete_file_recursive(
const std::string& path)
const;
170 inline static bool has_hadoop() {
return true; }
172 static hdfs& get_hdfs();
174 static hdfs& get_hdfs(std::string host,
size_t port);
183 typedef char char_type;
184 typedef boost::iostreams::bidirectional_device_tag category;
186 hdfs_device(
const hdfs& hdfs_fs,
const std::string& filename,
187 const bool write =
false) {
192 std::streamsize read(
char* strm_ptr, std::streamsize n) {
197 std::streamsize write(
const char* strm_ptr, std::streamsize n) {
202 bool good()
const {
return false; }
209 typedef boost::iostreams::stream<hdfs_device> fstream;
215 hdfs(
const std::string& host =
"default",
int port = 0) {
220 inline std::vector<std::string> list_files(
const std::string& path)
const {
223 return std::vector<std::string>();;
226 inline std::vector<std::pair<std::string, bool> > list_files_and_stat(
const std::string& path)
const {
229 return std::vector<std::pair<std::string, bool>>();
232 inline size_t file_size(
const std::string& path)
const {
239 inline bool path_exists(
const std::string& path)
const {
243 inline bool is_directory(
const std::string& path)
const {
247 bool create_directories(
const std::string& path)
const {
251 bool delete_file_recursive(
const std::string& path)
const {
255 bool good()
const {
return false; }
258 inline static bool has_hadoop() {
return false; }
260 static hdfs& get_hdfs();
262 static hdfs& get_hdfs(std::string host,
size_t port);