Medial Code Documentation
Loading...
Searching...
No Matches
hdfs_filesys.h
Go to the documentation of this file.
1
7#ifndef DMLC_IO_HDFS_FILESYS_H_
8#define DMLC_IO_HDFS_FILESYS_H_
9extern "C" {
10#include <hdfs.h>
11}
12#include <dmlc/filesystem.h>
13
14#include <vector>
15#include <string>
16
17namespace dmlc {
18namespace io {
20class HDFSFileSystem : public FileSystem {
21 public:
23 virtual ~HDFSFileSystem();
29 virtual FileInfo GetPathInfo(const URI &path);
35 virtual void ListDirectory(const URI &path, std::vector<FileInfo> *out_list);
45 virtual SeekStream *Open(const URI &path,
46 const char* const flag,
47 bool allow_null);
54 virtual SeekStream *OpenForRead(const URI &path, bool allow_null);
59 inline static HDFSFileSystem *GetInstance(const std::string &namenode = "default") {
60 static HDFSFileSystem instance(namenode);
61 // switch to another hdfs
62 if (namenode != "default" && instance.namenode_ != namenode) {
63 instance.ResetNamenode(namenode);
64 }
65 return &instance;
66 }
67
68 private:
70 explicit HDFSFileSystem(const std::string &namenode);
72 void ResetNamenode(const std::string &namenode);
74 std::string namenode_;
76 hdfsFS fs_;
78 int *ref_counter_;
79};
80} // namespace io
81} // namespace dmlc
82#endif // DMLC_IO_HDFS_FILESYS_H_
interface of i/o stream that support seek
Definition io.h:109
HDFS file system.
Definition hdfs_filesys.h:20
virtual SeekStream * OpenForRead(const URI &path, bool allow_null)
open a seekable stream for read
Definition hdfs_filesys.cc:200
virtual FileInfo GetPathInfo(const URI &path)
get information about a path
Definition hdfs_filesys.cc:156
virtual void ListDirectory(const URI &path, std::vector< FileInfo > *out_list)
list files in a directory
Definition hdfs_filesys.cc:166
virtual ~HDFSFileSystem()
destructor
Definition hdfs_filesys.cc:113
static HDFSFileSystem * GetInstance(const std::string &namenode="default")
get a singleton of HDFSFileSystem when needed
Definition hdfs_filesys.h:59
virtual SeekStream * Open(const URI &path, const char *const flag, bool allow_null)
open a stream, will report error and exit if bad thing happens NOTE: the Stream can continue to work ...
Definition hdfs_filesys.cc:177
Utilities to manipulate files.
namespace for dmlc
Definition array_view.h:12