Skip to content

Commit dec4f02

Browse files
author
Jinglei Ren
committed
Renames class/file for clarity.
1 parent f35549d commit dec4f02

20 files changed

+216
-217
lines changed

db/db_factory.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88

99
#include "db/db_factory.h"
1010

11-
#include "db/lock_db.h"
11+
#include "db/lock_stl_db.h"
12+
#include "db/lock_slib_db.h"
1213
#include "db/tbb_rand_db.h"
1314
#include "db/tbb_scan_db.h"
14-
#include "db/svm_db.h"
15-
#include "db/slib_db.h"
16-
#include "db/lock_slib_db.h"
15+
#include "db/svm_stl_db.h"
16+
#include "db/svm_slib_db.h"
1717

1818
using ycsbc::DB;
1919
using ycsbc::DBFactory;
2020

2121
DB* DBFactory::CreateDB(const std::string name) {
2222
if (name == "basic") {
2323
return new BasicDB;
24-
} else if (name == "lock_db") {
25-
return new LockDB;
26-
} else if (name == "tbb_rand_db") {
27-
return new TBBRandDB;
28-
} else if (name == "tbb_scan_db") {
29-
return new TBBScanDB;
30-
} else if (name == "svm_db") {
31-
return new SVMDB;
32-
} else if (name == "slib_db") {
33-
return new SLibDB;
34-
} else if (name == "lock_slib_db") {
35-
return new LockSLibDB;
24+
} else if (name == "lock_stl") {
25+
return new LockStlDB;
26+
} else if (name == "lock_slib") {
27+
return new LockSlibDB;
28+
} else if (name == "tbb_rand") {
29+
return new TbbRandDB;
30+
} else if (name == "tbb_scan") {
31+
return new TbbScanDB;
32+
} else if (name == "svm_stl") {
33+
return new SvmStlDB;
34+
} else if (name == "svm_slib") {
35+
return new SvmSlibDB;
3636
} else return NULL;
3737
}
3838

db/lock_slib_db.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
namespace ycsbc {
1919

20-
class LockSLibDB : public HashtableDB {
20+
class LockSlibDB : public HashtableDB {
2121
public:
22-
LockSLibDB() : HashtableDB(
23-
new vmp::LockSLibHashtable<HashtableDB::FieldHashtable *>) { }
22+
LockSlibDB() : HashtableDB(
23+
new vmp::LockSlibHashtable<HashtableDB::FieldHashtable *>) { }
2424

25-
~LockSLibDB() {
25+
~LockSlibDB() {
2626
std::vector<KeyHashtable::KVPair> key_pairs = key_table_->Entries();
2727
for (auto &key_pair : key_pairs) {
2828
DeleteFieldHashtable(key_pair.second);
@@ -32,7 +32,7 @@ class LockSLibDB : public HashtableDB {
3232

3333
protected:
3434
HashtableDB::FieldHashtable *NewFieldHashtable() {
35-
return new vmp::LockSLibHashtable<const char *>;
35+
return new vmp::LockSlibHashtable<const char *>;
3636
}
3737

3838
void DeleteFieldHashtable(HashtableDB::FieldHashtable *table) {

db/lock_db.h renamed to db/lock_stl_db.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
//
2-
// lock_db.h
2+
// lock_stl_db.h
33
// YCSB-C
44
//
55
// Created by Jinglei Ren on 12/25/14.
66
// Copyright (c) 2014 Jinglei Ren <jinglei@ren.systems>.
77
//
88

9-
#ifndef YCSB_C_LOCK_DB_H_
10-
#define YCSB_C_LOCK_DB_H_
9+
#ifndef YCSB_C_LOCK_STL_DB_H_
10+
#define YCSB_C_LOCK_STL_DB_H_
1111

1212
#include "db/hashtable_db.h"
1313

1414
#include <string>
1515
#include <vector>
16-
#include "lib/lock_hashtable.h"
16+
#include "lib/lock_stl_hashtable.h"
1717

1818
namespace ycsbc {
1919

20-
class LockDB : public HashtableDB {
20+
class LockStlDB : public HashtableDB {
2121
public:
22-
LockDB() : HashtableDB(
23-
new vmp::LockHashtable<HashtableDB::FieldHashtable *>) { }
22+
LockStlDB() : HashtableDB(
23+
new vmp::LockStlHashtable<HashtableDB::FieldHashtable *>) { }
2424

25-
~LockDB() {
25+
~LockStlDB() {
2626
std::vector<KeyHashtable::KVPair> key_pairs = key_table_->Entries();
2727
for (auto &key_pair : key_pairs) {
2828
DeleteFieldHashtable(key_pair.second);
@@ -32,7 +32,7 @@ class LockDB : public HashtableDB {
3232

3333
protected:
3434
HashtableDB::FieldHashtable *NewFieldHashtable() {
35-
return new vmp::LockHashtable<const char *>;
35+
return new vmp::LockStlHashtable<const char *>;
3636
}
3737

3838
void DeleteFieldHashtable(HashtableDB::FieldHashtable *table) {
@@ -56,4 +56,4 @@ class LockDB : public HashtableDB {
5656

5757
} // ycsbc
5858

59-
#endif // YCSB_C_LOCK_DB_H_
59+
#endif // YCSB_C_LOCK_STL_DB_H_

db/slib_db.cc renamed to db/svm_slib_db.cc

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
//
2-
// slib_db.cc
2+
// svm_slib_db.cc
33
// YCSB-C
44
//
55
// Created by Jinglei Ren on 12/27/14.
66
// Copyright (c) 2014 Jinglei Ren <jinglei@ren.systems>.
77
//
88

9-
#include "db/slib_db.h"
9+
#include "db/svm_slib_db.h"
1010

1111
#include <vector>
1212
#include "sitevm/sitevm.h"
1313
#include "slib/mem_alloc.h"
14+
#include "lib/slib_hashtable.h"
1415
#include "lib/trans_def.h"
1516

16-
using vmp::SLibHashtable;
17+
using vmp::SlibHashtable;
1718

1819
namespace ycsbc {
1920

20-
SLibDB::SLibDB() : HashtableDB(NULL) {
21+
SvmSlibDB::SvmSlibDB() : HashtableDB(NULL) {
2122
int err = sitevm_init();
2223
assert(!err);
2324
svm_ = sitevm_seg_create(NULL, SVM_SIZE);
@@ -26,32 +27,32 @@ SLibDB::SLibDB() : HashtableDB(NULL) {
2627
assert(!err);
2728
err = sitevm_open_and_update(svm_);
2829
assert(!err);
29-
key_table_ = SVMAlloc::New<
30-
SLibHashtable<HashtableDB::FieldHashtable *, SVMAlloc>>();
30+
key_table_ = SvmAlloc::New<
31+
SlibHashtable<HashtableDB::FieldHashtable *, SvmAlloc>>();
3132
err = sitevm_commit_and_update(svm_);
3233
assert(!err);
3334
}
3435

35-
void SLibDB::Init() {
36+
void SvmSlibDB::Init() {
3637
int err = sitevm_enter();
3738
assert(!err);
3839
err = sitevm_open_and_update(svm_);
3940
assert(!err);
4041
}
4142

42-
void SLibDB::Close() {
43+
void SvmSlibDB::Close() {
4344
sitevm_exit();
4445
}
4546

46-
SLibDB::~SLibDB() {
47+
SvmSlibDB::~SvmSlibDB() {
4748
std::vector<KeyHashtable::KVPair> key_pairs = key_table_->Entries();
4849
for (auto &key_pair : key_pairs) {
4950
DeleteFieldHashtable(key_pair.second);
5051
}
51-
SVMAlloc::Delete(key_table_);
52+
SvmAlloc::Delete(key_table_);
5253
}
5354

54-
int SLibDB::Read(const std::string &table, const std::string &key,
55+
int SvmSlibDB::Read(const std::string &table, const std::string &key,
5556
const std::vector<std::string> *fields, std::vector<KVPair> &result) {
5657
int ret;
5758
TRANS_BEGIN {
@@ -60,7 +61,7 @@ int SLibDB::Read(const std::string &table, const std::string &key,
6061
return ret;
6162
}
6263

63-
int SLibDB::Scan(const std::string &table, const std::string &key,
64+
int SvmSlibDB::Scan(const std::string &table, const std::string &key,
6465
int len, const std::vector<std::string> *fields,
6566
std::vector<std::vector<KVPair>> &result) {
6667
int ret;
@@ -70,7 +71,7 @@ int SLibDB::Scan(const std::string &table, const std::string &key,
7071
return ret;
7172
}
7273

73-
int SLibDB::Update(const std::string &table, const std::string &key,
74+
int SvmSlibDB::Update(const std::string &table, const std::string &key,
7475
std::vector<KVPair> &values) {
7576
int ret;
7677
TRANS_BEGIN {
@@ -79,7 +80,7 @@ int SLibDB::Update(const std::string &table, const std::string &key,
7980
return ret;
8081
}
8182

82-
int SLibDB::Insert(const std::string &table, const std::string &key,
83+
int SvmSlibDB::Insert(const std::string &table, const std::string &key,
8384
std::vector<KVPair> &values) {
8485
int ret;
8586
TRANS_BEGIN {
@@ -88,34 +89,34 @@ int SLibDB::Insert(const std::string &table, const std::string &key,
8889
return ret;
8990
}
9091

91-
int SLibDB::Delete(const std::string &table, const std::string &key) {
92+
int SvmSlibDB::Delete(const std::string &table, const std::string &key) {
9293
int ret;
9394
TRANS_BEGIN {
9495
ret = HashtableDB::Delete(table, key);
9596
} TRANS_END(svm_);
9697
return ret;
9798
}
9899

99-
HashtableDB::FieldHashtable *SLibDB::NewFieldHashtable() {
100-
return SVMAlloc::New<SLibHashtable<const char *, SVMAlloc>>();
100+
HashtableDB::FieldHashtable *SvmSlibDB::NewFieldHashtable() {
101+
return SvmAlloc::New<SlibHashtable<const char *, SvmAlloc>>();
101102
}
102103

103-
void SLibDB::DeleteFieldHashtable(HashtableDB::FieldHashtable *table) {
104+
void SvmSlibDB::DeleteFieldHashtable(HashtableDB::FieldHashtable *table) {
104105
std::vector<FieldHashtable::KVPair> pairs = table->Entries();
105106
for (auto &pair : pairs) {
106107
DeleteString(pair.second);
107108
}
108-
SVMAlloc::Delete(table);
109+
SvmAlloc::Delete(table);
109110
}
110111

111-
const char *SLibDB::CopyString(const std::string &str) {
112-
char *value = (char *)SVMAlloc::Malloc(str.length() + 1);
112+
const char *SvmSlibDB::CopyString(const std::string &str) {
113+
char *value = (char *)SvmAlloc::Malloc(str.length() + 1);
113114
strcpy(value, str.c_str());
114115
return value;
115116
}
116117

117-
void SLibDB::DeleteString(const char *str) {
118-
SVMAlloc::Free(str, strlen(str) + 1);
118+
void SvmSlibDB::DeleteString(const char *str) {
119+
SvmAlloc::Free(str, strlen(str) + 1);
119120
}
120121

121122
} // ycsbc

db/slib_db.h renamed to db/svm_slib_db.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
//
2-
// slib_db.h
2+
// svm_slib_db.h
33
// YCSB-C
44
//
55
// Created by Jinglei Ren on 12/27/14.
66
// Copyright (c) 2014 Jinglei Ren <jinglei@ren.systems>.
77
//
88

9-
#ifndef YCSB_C_SLIB_DB_H_
10-
#define YCSB_C_SLIB_DB_H_
9+
#ifndef YCSB_C_SVM_SLIB_DB_H_
10+
#define YCSB_C_SVM_SLIB_DB_H_
1111

1212
#include "db/hashtable_db.h"
1313

1414
#include <string>
1515
#include "sitevm/sitevm_malloc.h"
16-
#include "lib/slib_hashtable.h"
1716

1817
namespace ycsbc {
1918

20-
class SLibDB : public HashtableDB {
19+
class SvmSlibDB : public HashtableDB {
2120
public:
22-
SLibDB();
21+
SvmSlibDB();
2322
void Init();
2423
void Close();
25-
~SLibDB();
24+
~SvmSlibDB();
2625

2726
int Read(const std::string &table, const std::string &key,
2827
const std::vector<std::string> *fields,
@@ -46,4 +45,5 @@ class SLibDB : public HashtableDB {
4645

4746
} // ycsbc
4847

49-
#endif // YCSB_C_SLIB_DB_H_
48+
#endif // YCSB_C_SVM_SLIB_DB_H_
49+

0 commit comments

Comments
 (0)