Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vdfs.hh
Go to the documentation of this file.
1 #pragma once
2 #include "dfs.hh"
3 #include <vector>
4 
5 namespace velox {
6 
7 class vdfs;
8 
9 class file {
10  friend vdfs;
11  public:
12  void append(std::string);
13  std::string get();
14 
15  void open();
16  void close();
17  bool is_open();
18 
19  long get_id();
20  std::string get_name();
21  long get_size();
22 
23  file& operator=(const file&);
24 
25  file(vdfs*, std::string);
26  file(vdfs*, std::string, bool);
27  file(const file&);
28 
29  private:
30  long id;
31  std::string name;
32  vdfs* vdfs_;
33  bool opened;
34 
35  long size;
36 
37  long generate_fid();
38 };
39 
40 class vdfs {
41  friend file;
42  public:
43  vdfs();
44  vdfs(vdfs&);
45  ~vdfs();
46 
47  vdfs& operator=(vdfs&);
48 
49  velox::file open(std::string);
50 
51  long open_file(std::string);
52  bool close(long);
53  bool is_open(long);
54 
55  velox::file upload(std::string);
56 
57  bool rm(std::string);
58  bool rm(long);
59  bool format();
60 
61  bool exists(std::string);
62 
63  uint32_t write(long, const char*, uint32_t, uint32_t);
64  uint32_t write(long, const char*, uint32_t, uint32_t, uint64_t);
65  uint32_t read(long, char*, uint64_t, uint64_t);
66  uint32_t read_chunk(std::string name, std::string host, char *buf, uint64_t boff, uint64_t , uint64_t);
67 
68  model::metadata get_metadata(long fid, int type);
69 
70  void append(std::string, std::string);
71 
72  std::vector<model::metadata> list(bool all, std::string name = "");
73 
74  bool rename(std::string, std::string);
75 
76  protected:
77  DFS* dfs;
78  std::string load(std::string);
79 
80  private:
81  velox::file* get_file(long);
82  std::vector<velox::file>* opened_files;
83 };
84 
85 
86 }
bool close(long)
Definition: vdfs.cc:176
bool rm(std::string)
Definition: vdfs.cc:230
uint32_t read_chunk(std::string name, std::string host, char *buf, uint64_t boff, uint64_t, uint64_t)
Definition: vdfs.cc:332
Definition: metadata.hh:12
std::string get_name()
Definition: vdfs.cc:85
std::vector< model::metadata > list(bool all, std::string name="")
Definition: vdfs.cc:306
~vdfs()
Definition: vdfs.cc:117
vdfs()
Definition: vdfs.cc:100
DFS * dfs
Definition: vdfs.hh:77
void open()
Definition: vdfs.cc:65
velox::file upload(std::string)
Definition: vdfs.cc:211
model::metadata get_metadata(long fid, int type)
Definition: vdfs.cc:297
std::string load(std::string)
Definition: vdfs.cc:224
long get_size()
Definition: vdfs.cc:90
long get_id()
Definition: vdfs.cc:80
Definition: dfs.hh:17
bool rename(std::string, std::string)
Definition: vdfs.cc:327
bool is_open(long)
Definition: vdfs.cc:200
Definition: vdfs.hh:9
long open_file(std::string)
Definition: vdfs.cc:170
velox::file open(std::string)
Definition: vdfs.cc:146
vdfs & operator=(vdfs &)
Definition: vdfs.cc:129
bool exists(std::string)
Definition: vdfs.cc:249
void close()
Definition: vdfs.cc:70
bool format()
Definition: vdfs.cc:243
void append(std::string)
Definition: vdfs.cc:55
file & operator=(const file &)
Definition: vdfs.cc:45
bool is_open()
Definition: vdfs.cc:75
uint32_t write(long, const char *, uint32_t, uint32_t)
Definition: vdfs.cc:257
file(vdfs *, std::string)
Definition: vdfs.cc:15
Definition: vdfs.hh:40
void append(std::string, std::string)
Definition: vdfs.cc:218
uint32_t read(long, char *, uint64_t, uint64_t)
Definition: vdfs.cc:275