libfaster API Documentation  Development Version
Super fast distributted computing
hdfsEngine.h
1 #ifndef LIBFASTER_HFDSENGINE_H
2 #define LIBFASTER_HFDSENGINE_H
3 
4 #include <algorithm>
5 #include <string>
6 #include <vector>
7 #include <deque>
8 #include <fcntl.h>
9 
10 namespace faster{
11 
12  enum fileMode : int {
13  R = O_RDONLY,
14  W = O_WRONLY,
15  //RW = O_RDWR,
16  CR = O_RDONLY | O_CREAT,
17  CW = O_WRONLY | O_CREAT
18  //CRW = O_RDWR | O_CREAT
19  };
20 
21 
22  class hdfsFile{
23  private:
24  void * _fs;
25  void * _f;
26  bool _open;
27  std::string _path;
28  std::vector<char> _buffer;
29  size_t read(char* v);
30 
31  public:
32  hdfsFile(void * fs, std::string & path, fileMode mode);
33  ~hdfsFile();
34 
35  void close();
36 
37  size_t read(char * v, size_t n);
38  size_t write(char * v, size_t n);
39  size_t seek(size_t offset);
40 
41  size_t readLine(char * v, size_t n, char sep);
42 
43  std::vector<std::deque<int>> getBlocksLocations();
44 
45  void del();
46  };
47 
48  class hdfsEngine{
49  private:
50  void * _fs;
51  bool _ready;
52  std::string _path;
53 
54  public:
55  hdfsEngine();
56  ~hdfsEngine();
57 
58  bool isReady();
59  bool isConnected();
60 
61  faster::hdfsFile open(std::string path, fileMode mode);
62  void close(faster::hdfsFile & f);
63 
64  void del(std::string path);
65  bool exists(std::string path);
66  };
67 }
68 
69 #endif
libfaster main namespace
Definition: _workerFdd.h:11