Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dfs.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "model/metadata.hh"
4 
5 #include <string>
6 #include <vector>
7 #include <stdint.h>
8 #define VELOX_LOGICAL_DISABLE 0
9 #define VELOX_LOGICAL_OUTPUT 1
10 #define VELOX_LOGICAL_NOOP 2
11 #define VELOX_LOGICAL_GENERATE 3
12 
13 namespace velox {
14 
15 using vec_str = std::vector<std::string>;
16 
17 class DFS {
18  public:
19  DFS();
20 
31  uint64_t write(std::string& file_name, const char* buf, uint64_t off, uint64_t len);
32  uint64_t write(std::string& file_name, const char* buf, uint64_t off, uint64_t len,
33  uint64_t block_size);
34 
44  uint64_t read(std::string& file_name, char* buf, uint64_t off, uint64_t len);
45 
55  //uint64_t read_physical(std::string& file_name, char* buf, uint64_t off, uint64_t len);
56  //uint64_t read_logical(std::string& file_name, char* buf, uint64_t off, uint64_t len);
57 
62  std::string read_all(std::string file_name);
63 
67  int append(std::string file_name, std::string buf);
68 
76  int upload(std::string file_name, bool is_binary, uint64_t block_size = 0);
77 
83  int download(std::string file_name);
84 
85  bool exists(std::string);
86 
87  bool touch(std::string);
88 
89  int remove(std::string);
90 
91  bool rename(std::string, std::string);
92 
93  int format();
94 
95  model::metadata get_metadata(std::string& fname);
96 
97  model::metadata get_metadata_optimized(std::string& fname, int type = 0);
98 
99  std::vector<model::metadata> get_metadata_all();
100 
101  void file_metadata_append(std::string, size_t, model::metadata&);
102 
104  std::string dump_metadata(std::string& fname);
105 
107  uint64_t read_chunk(std::string& fname, std::string host, char* buf,
108  uint64_t buffer_offset, uint64_t off, uint64_t len);
109 
110  private:
111  uint32_t NUM_NODES;
112  int replica;
113  std::vector<std::string> nodes;
114 };
115 
116 }
bool rename(std::string, std::string)
Definition: dfs.cc:674
DFS()
Definition: dfs.cc:395
Definition: metadata.hh:12
uint64_t write(std::string &file_name, const char *buf, uint64_t off, uint64_t len)
Write the contents into a remote file.
Definition: dfs.cc:1065
std::vector< std::string > vec_str
Definition: dfs.hh:15
void file_metadata_append(std::string, size_t, model::metadata &)
Definition: dfs.cc:1365
bool exists(std::string)
}}}
Definition: dfs.cc:972
Definition: dfs.hh:17
bool touch(std::string)
Definition: dfs.cc:985
int append(std::string file_name, std::string buf)
Append a string to the end of a remote file.
Definition: dfs.cc:768
int upload(std::string file_name, bool is_binary, uint64_t block_size=0)
Upload a local file to a the veloxdfs intance.
Definition: dfs.cc:407
model::metadata get_metadata_optimized(std::string &fname, int type=0)
Definition: dfs.cc:1275
uint64_t read_chunk(std::string &fname, std::string host, char *buf, uint64_t buffer_offset, uint64_t off, uint64_t len)
Read a chunk directly.
Definition: dfs.cc:1441
uint64_t read(std::string &file_name, char *buf, uint64_t off, uint64_t len)
Download a remote file's section into a buffer.
Definition: dfs.cc:1200
std::string read_all(std::string file_name)
Read remote logical blocks into a buffer.
Definition: dfs.cc:608
std::vector< model::metadata > get_metadata_all()
Definition: dfs.cc:1344
int download(std::string file_name)
Download a remote file to your current local directory.
Definition: dfs.cc:567
model::metadata get_metadata(std::string &fname)
Definition: dfs.cc:1262
std::string dump_metadata(std::string &fname)
Dump all the metadata for the give file.
Definition: dfs.cc:1398
int format()
Definition: dfs.cc:750