SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
RangeBase.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
7 #ifndef swcdb_db_Columns_RangeBase_h
8 #define swcdb_db_Columns_RangeBase_h
9 
10 
11 namespace SWC { namespace DB {
12 
13 
14 
15 class RangeBase final {
16  public:
17 
18  static constexpr const char COLUMN_DIR[] = "C";
19  static constexpr const char RANGE_DIR[] = "/R";
20  static constexpr const char RANGER_FILE[] = "ranger.data";
21  static constexpr const char CELLSTORES_DIR[] = "cs";
22  static constexpr const char LOG_DIR[] = "log";
23 
24  // (swc.fs.path.data)+COLUMN_DIR+/+{cid}+/RANGE_DIR+/+{rid}+/+(types)
25 
26  static const char* get_column_path() noexcept {
27  return COLUMN_DIR;
28  }
29 
30  static const std::string get_column_path(const cid_t cid) {
31  std::string s(get_column_path());
32  //if(!s.empty())
33  s.append("/");
35  return s;
36  }
37 
38  static const std::string get_path(const cid_t cid) {
39  std::string s(get_column_path(cid));
40  s.append(RANGE_DIR);
41  return s;
42  }
43 
44  static const std::string get_path(const cid_t cid, const rid_t rid) {
45  std::string s(get_path(cid));
46  s.append("/");
48  s.append("/");
49  return s;
50  }
51 
52  static const std::string get_path_on_range(const std::string& range_path,
53  const std::string& path) {
54  std::string s;
55  s.reserve(range_path.length() + path.length() + 1);
56  s.append(range_path);
57  s.append(path);
58  s.append("/");
59  return s;
60  }
61 
62  static std::string get_path_ranger(const std::string& range_path) {
63  std::string s;
64  s.reserve(range_path.length() + strlen(RANGER_FILE));
65  s.append(range_path);
66  s.append(RANGER_FILE);
67  return s;
68  }
69 
70  #ifdef SWC_RANGER_WITH_RANGEDATA
71  static constexpr const char RANGE_FILE[] = "range.data";
72  static const std::string get_path_range_data(const std::string& range_path) {
73  std::string s;
74  s.reserve(range_path.length() + strlen(RANGE_FILE));
75  s.append(range_path);
76  s.append(RANGE_FILE);
77  return s;
78  }
79  #endif
80 
81  static const std::string get_path_cs(const std::string& range_path,
82  const std::string& folder,
83  const csid_t csid) {
84  std::string cs(std::to_string(csid));
85  std::string s;
86  s.reserve(range_path.length() + folder.length() + 4 + cs.length());
87  s.append(range_path);
88  s.append(folder);
89  s.append("/");
90  s.append(cs);
91  s.append(".cs");
92  return s;
93  }
94 
95 };
96 
97 }}
98 #endif // swcdb_db_Columns_RangeBase_h
SWC::DB::RangeBase::COLUMN_DIR
static constexpr const char COLUMN_DIR[]
Definition: RangeBase.h:18
SWC::DB::RangeBase::get_path_cs
static const std::string get_path_cs(const std::string &range_path, const std::string &folder, const csid_t csid)
Definition: RangeBase.h:81
SWC::DB::RangeBase::get_column_path
static const char * get_column_path() noexcept
Definition: RangeBase.h:26
SWC::DB::RangeBase::get_path_on_range
static const std::string get_path_on_range(const std::string &range_path, const std::string &path)
Definition: RangeBase.h:52
SWC::csid_t
uint32_t csid_t
Definition: Identifiers.h:19
SWC::DB::RangeBase::RANGER_FILE
static constexpr const char RANGER_FILE[]
Definition: RangeBase.h:20
SWC::DB::RangeBase::get_path
static const std::string get_path(const cid_t cid)
Definition: RangeBase.h:38
SWC::DB::RangeBase::get_column_path
static const std::string get_column_path(const cid_t cid)
Definition: RangeBase.h:30
SWC::DB::RangeBase::RANGE_DIR
static constexpr const char RANGE_DIR[]
Definition: RangeBase.h:19
SWC::DB::RangeBase
Definition: RangeBase.h:15
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::DB::RangeBase::CELLSTORES_DIR
static constexpr const char CELLSTORES_DIR[]
Definition: RangeBase.h:21
SWC::DB::RangeBase::get_path
static const std::string get_path(const cid_t cid, const rid_t rid)
Definition: RangeBase.h:44
SWC::DB::RangeBase::LOG_DIR
static constexpr const char LOG_DIR[]
Definition: RangeBase.h:22
SWC::DB::RangeBase::get_path_ranger
static std::string get_path_ranger(const std::string &range_path)
Definition: RangeBase.h:62
SWC::cid_t
uint64_t cid_t
Definition: Identifiers.h:16
SWC::rid_t
uint64_t rid_t
Definition: Identifiers.h:17
SWC::FS::set_structured_id
void set_structured_id(const std::string &number, std::string &s)
Definition: Interface.cc:494
SWC::Core::to_string
SWC_CAN_INLINE std::string to_string(const BitFieldInt< T, SZ > &v)
Definition: BitFieldInt.h:263