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
1819namespace 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
0 commit comments