Logo
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(std::string job_id, int tid, bool initializer);
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  velox::file upload_idv(std::string);
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, uint32_t boff, uint64_t , uint64_t, int);
67  uint32_t read_chunk(char *buf, uint32_t boff);
68  //int* read_chunk(std::string name, std::string host, char *buf, uint32_t boff, uint64_t , uint64_t, int);
69 
70  model::metadata get_metadata(long fid, int type);
71 
72  void append(std::string, std::string);
73 
74  std::vector<model::metadata> list(bool all, std::string name = "");
75 
76  bool rename(std::string, std::string);
77 
78  velox::file write_file(std::string, const std::string&, uint64_t);
79 
80  int get_tmg_id();
81 
82  int tmg_id;
83  std::string job_id;
85  protected:
86  DFS* dfs;
87  std::string load(std::string);
88 
89  private:
90  velox::file* get_file(long);
91  std::vector<velox::file>* opened_files;
92 };
93 
94 
95 }
Definition: dfs.hh:20
Definition: vdfs.hh:9
file(vdfs *, std::string)
Definition: vdfs.cc:15
void open()
Definition: vdfs.cc:65
std::string get()
Definition: vdfs.cc:60
void close()
Definition: vdfs.cc:70
void append(std::string)
Definition: vdfs.cc:55
long get_id()
Definition: vdfs.cc:80
file & operator=(const file &)
Definition: vdfs.cc:45
std::string get_name()
Definition: vdfs.cc:85
long get_size()
Definition: vdfs.cc:90
bool is_open()
Definition: vdfs.cc:75
Definition: metadata.hh:12
Definition: vdfs.hh:40
DFS * dfs
Definition: vdfs.hh:86
bool exists(std::string)
Definition: vdfs.cc:252
~vdfs()
Definition: vdfs.cc:117
model::metadata get_metadata(long fid, int type)
Definition: vdfs.cc:295
velox::file upload_idv(std::string)
Definition: vdfs.cc:215
bool rename(std::string, std::string)
Definition: vdfs.cc:327
velox::file upload(std::string)
Definition: vdfs.cc:210
velox::file open(std::string)
Definition: vdfs.cc:146
velox::file write_file(std::string, const std::string &, uint64_t)
Definition: vdfs.cc:339
uint32_t read(long, char *, uint64_t, uint64_t)
Definition: vdfs.cc:275
long open_file(std::string)
Definition: vdfs.cc:169
bool rm(std::string)
Definition: vdfs.cc:233
vdfs & operator=(vdfs &)
Definition: vdfs.cc:129
bool close(long)
Definition: vdfs.cc:175
vdfs(std::string job_id, int tid, bool initializer)
Definition: vdfs.cc:100
int tmg_id
Definition: vdfs.hh:82
bool format()
Definition: vdfs.cc:246
std::string load(std::string)
Definition: vdfs.cc:227
std::string job_id
Definition: vdfs.hh:83
std::vector< model::metadata > list(bool all, std::string name="")
Definition: vdfs.cc:305
void append(std::string, std::string)
Definition: vdfs.cc:221
bool initializer
Definition: vdfs.hh:84
int get_tmg_id()
Definition: vdfs.cc:344
bool is_open(long)
Definition: vdfs.cc:199
uint32_t read_chunk(char *buf, uint32_t boff)
Definition: vdfs.cc:334
uint32_t write(long, const char *, uint32_t, uint32_t)
Definition: vdfs.cc:258
Definition: dfs-modify2.cc:47