remove out-of-date function and amend the function naming
MODIFY
Database/Database.cpp
Database/Database.cpp
@@ -5942,7 +5942,7 @@ Database::getFinalResult(SPARQLquery& _sparql_q, ResultSet& _result_set)
//garbage clean
void
-Database::version_clean(vector<unsigned> &sub_ids ,vector<unsigned>& obj_ids, vector<unsigned>& obj_literal_ids, vector<unsigned> &pre_ids)
+Database::VersionClean(vector<unsigned> &sub_ids ,vector<unsigned>& obj_ids, vector<unsigned>& obj_literal_ids, vector<unsigned> &pre_ids)
{
//vector<unsigned> sub_ids , obj_ids, obj_literal_ids, pre_ids;
(this->kvstore)->IVArrayVacuum(sub_ids, obj_ids, obj_literal_ids, pre_ids);
@@ -6045,7 +6045,7 @@ Database::version_clean(vector<unsigned> &sub_ids ,vector<unsigned>& obj_ids, ve
}
void
-Database::transaction_rollback(shared_ptr<Transaction> txn)
+Database::TransactionRollback(shared_ptr<Transaction> txn)
{
if((this->kvstore)->TransactionInvalid(txn) == false)
{
@@ -6055,7 +6055,7 @@ Database::transaction_rollback(shared_ptr<Transaction> txn)
}
void
-Database::transaction_commit(shared_ptr<Transaction> txn)
+Database::TransactionCommit(shared_ptr<Transaction> txn)
{
//cout << "transaction_commit ........" << endl;
if((this->kvstore)->ReleaseAllLocks(txn) == false)

MODIFY
Database/Database.h
Database/Database.h
@@ -100,9 +100,9 @@ public:
mutex& get_query_parse_lock();
//MVCC
- void transaction_rollback(shared_ptr<Transaction> txn);
- void transaction_commit(shared_ptr<Transaction> txn);
- void version_clean(vector<unsigned> &sub_ids ,vector<unsigned>& obj_ids, vector<unsigned>& obj_literal_ids, vector<unsigned> &pre_ids);
+ void TransactionRollback(shared_ptr<Transaction> txn);
+ void TransactionCommit(shared_ptr<Transaction> txn);
+ void VersionClean(vector<unsigned> &sub_ids ,vector<unsigned>& obj_ids, vector<unsigned>& obj_literal_ids, vector<unsigned> &pre_ids);
private:
string name;
string store_path;

MODIFY
Database/Txn_manager.cpp
Database/Txn_manager.cpp
@@ -177,7 +177,7 @@ int Txn_manager::Commit(txn_id_t TID)
txn_id_t CID = this->ArrangeCommitID();
txn->SetCommitID(CID);
if(db != nullptr)
- db->transaction_commit(txn);
+ db->TransactionCommit(txn);
else
{
cout << "error! database has been flushed or removed" << endl;
@@ -207,7 +207,7 @@ int Txn_manager::Abort(txn_id_t TID)
return -1;
}
if(db != nullptr)
- db->transaction_rollback(txn);
+ db->TransactionRollback(txn);
else
{
cout << "error! database has been flushed or removed" << endl;
@@ -294,7 +294,7 @@ void Txn_manager::Checkpoint()
//cout << "obj_ids.size(): " << obj_ids.size() << endl;
//cout << "obj_literal_ids.size(): " << obj_literal_ids.size() << endl;
if(db != nullptr)
- db->version_clean(sub_ids, obj_ids, obj_literal_ids, pre_ids);
+ db->VersionClean(sub_ids, obj_ids, obj_literal_ids, pre_ids);
checkpoint_lock.unlock();
}

MODIFY
Database/Txn_manager.h
Database/Txn_manager.h
@@ -38,8 +38,6 @@ private:
Latch checkpoint_lock;
Latch table_lock;
mutex DirtyKeys_lock;
- //not used
- mutex db_lock;
vector<IDSet> DirtyKeys;
atomic<int> committed_num = {0};
@@ -57,8 +55,6 @@ private:
inline void lock_log() { log_lock.lock(); }
inline void unlock_log() { log_lock.unlock(); }
- inline void lock_db() { db_lock.lock(); }
- inline void unlock_db() { db_lock.unlock(); }
void add_dirty_keys(shared_ptr<Transaction> txn);
public:

MODIFY
KVstore/IVArray/IVArray.cpp
KVstore/IVArray/IVArray.cpp
@@ -559,7 +559,7 @@ IVArray::search(unsigned _key, char *& _str, unsigned long & _len, VDataSet& Add
return false;
}
// try to read in main memory
- bool ret = array[_key].readVersion(AddSet, DelSet, txn, latched, is_firstread);
+ bool ret = array[_key].ReadVersion(AddSet, DelSet, txn, latched, is_firstread);
bool is_empty = AddSet.size() == 0 && DelSet.size() == 0;
if(ret == false) {
@@ -633,7 +633,7 @@ IVArray::remove(unsigned _key, VDataSet& delta, shared_ptr<Transaction> txn)
VDataSet addset;
addset.clear();
- bool ret = array[_key].writeVersion(addset, delta, txn);
+ bool ret = array[_key].WriteVersion(addset, delta, txn);
if(ret == false) txn->SetState(TransactionState::ABORTED);
ArrayUnlock();
return ret;
@@ -657,7 +657,7 @@ IVArray::insert(unsigned _key, VDataSet& delta, shared_ptr<Transaction> txn)
delset.clear();
//check if first insert
//array[_key].setDirtyFlag(true);
- int ret = array[_key].writeVersion(delta, delset, txn);
+ int ret = array[_key].WriteVersion(delta, delset, txn);
if(ret != 1) {
cerr << "write version failed!" << endl;
txn->SetState(TransactionState::ABORTED);
@@ -715,23 +715,11 @@ IVArray::TryExclusiveLatch(unsigned _key, shared_ptr<Transaction> txn, bool has_
}
//assert(_key < CurEntryNum);
- int ret = array[_key].getExclusiveLatch(txn, has_read);
+ int ret = array[_key].GetExclusiveLatch(txn, has_read);
ArrayUnlock();
return ret;
}
-/*
-bool
-IVArray::ReleaseExclusiveLock(unsigned _key, shared_ptr<Transaction> txn, bool has_read)
-{
- if (_key >= CurEntryNum || !array[_key].isUsed() )
- {
- return false;
- }
- return array[_key].releaseExlusiveLatch(txn, has_read);
-}
-*/
-
bool
IVArray::ReleaseLatch(unsigned _key, shared_ptr<Transaction> txn, IVEntry::LatchType type)
{
@@ -741,7 +729,7 @@ IVArray::ReleaseLatch(unsigned _key, shared_ptr<Transaction> txn, IVEntry::Latch
ArrayUnlock();
return false;
}
- bool ret = array[_key].unLatch(txn, type);
+ bool ret = array[_key].UnLatch(txn, type);
ArrayUnlock();
return ret;
}
@@ -756,7 +744,7 @@ IVArray::Rollback(unsigned _key, shared_ptr<Transaction> txn, bool has_read)
return false;
}
//bool delete_ret = array[_key].deleteUnCommittedVersion(txn);
- bool delete_ret = array[_key].invalidExlusiveLatch(txn, has_read);
+ bool delete_ret = array[_key].InvalidExlusiveLatch(txn, has_read);
//cerr << "delete_retdelete_ret TID:" << txn->GetTID() << " " << _key << " " << delete_ret << endl;
//bool unlock_ret = array[_key].releaseExlusiveLock(txn);
ArrayUnlock();
@@ -774,7 +762,7 @@ IVArray::CleanDirtyKey(unsigned _key)
ArrayUnlock();
return false;
}
- array[_key].cleanAllVersion();
+ array[_key].CleanAllVersion();
ArrayUnlock();
return true;

MODIFY
KVstore/IVArray/IVArray.h
KVstore/IVArray/IVArray.h
@@ -87,8 +87,6 @@ public:
//abort
//clean invalid version(release exclusive latch along) and release exclusive lock
bool Rollback(unsigned _key, shared_ptr<Transaction> txn, bool has_read );
- //unlock(abort)
- bool ReleaseExclusiveLock(unsigned _key, shared_ptr<Transaction> txn);
//garbage clean
bool CleanDirtyKey(unsigned _key) ;

MODIFY
KVstore/IVArray/IVEntry.cpp
KVstore/IVArray/IVEntry.cpp
@@ -199,8 +199,8 @@ void
IVEntry::getLatestVersion(TYPE_TXN_ID TID, VDataSet &addset, VDataSet &delset)
{
rwLatch.lockShared();
- int n = vList.size();
- for(int i = 0; i < n; i++)
+ unsigned n = vList.size();
+ for(unsigned i = 0; i < n - 1; i++)
{
vList[i]->get_version(addset, delset);
}
@@ -269,7 +269,7 @@ IVEntry::version_merge(VDataArray &addarray, VDataArray &delarray, VDataSet &Add
}
bool
-IVEntry::readVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn, bool &latched, bool first_read)
+IVEntry::ReadVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn, bool &latched, bool first_read)
{
if(txn->GetIsolationLevelType() == IsolationLevelType::READ_COMMITTED)
{
@@ -309,7 +309,7 @@ IVEntry::readVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction>
//txn aborts then delete its uncommitted version. Deleted version is always the latest version.
bool
-IVEntry::invalidExlusiveLatch(shared_ptr<Transaction> txn, bool has_read)
+IVEntry::InvalidExlusiveLatch(shared_ptr<Transaction> txn, bool has_read)
{
bool IS_SR = txn->GetIsolationLevelType() == IsolationLevelType::SERIALIZABLE;
auto TID = txn->GetTID();
@@ -341,7 +341,7 @@ IVEntry::invalidExlusiveLatch(shared_ptr<Transaction> txn, bool has_read)
}
bool
-IVEntry::unLatch(shared_ptr<Transaction> txn, LatchType latch_type)
+IVEntry::UnLatch(shared_ptr<Transaction> txn, LatchType latch_type)
{
bool IS_SR = (txn->GetIsolationLevelType() == IsolationLevelType::SERIALIZABLE);
auto TID = txn->GetTID();
@@ -394,7 +394,7 @@ IVEntry::clearVersionFlag()
}
void
-IVEntry::cleanAllVersion()
+IVEntry::CleanAllVersion()
{
rwLatch.lockExclusive();
vList.clear();
@@ -410,7 +410,7 @@ we don't need any lock in RC and SI here but only head version check
SR need exclusive lock to restrict the read operations!
*/
int
-IVEntry::getExclusiveLatch(shared_ptr<Transaction> txn, bool has_read)
+IVEntry::GetExclusiveLatch(shared_ptr<Transaction> txn, bool has_read)
{
auto TID = txn->GetTID();
shared_ptr<Version> new_version = make_shared<Version>(INVALID_TS, TID); //[-1, TID]
@@ -465,7 +465,7 @@ IVEntry::getExclusiveLatch(shared_ptr<Transaction> txn, bool has_read)
}
int
-IVEntry::writeVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn)
+IVEntry::WriteVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn)
{
//private version no need any lock here
rwLatch.lockShared();
@@ -478,10 +478,3 @@ IVEntry::writeVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction
rwLatch.unlock();
return 1;
}
-
-//abort only
-bool
-IVEntry::releaseExlusiveLatch(shared_ptr<Transaction> txn, bool has_read)
-{
- return this->invalidExlusiveLatch(txn, has_read);
-}
\ No newline at end of file

MODIFY
KVstore/IVArray/IVEntry.h
KVstore/IVArray/IVEntry.h
@@ -32,7 +32,7 @@ private:
//MVCC
atomic<bool> is_versioned;
- //Version List head point always point to the newest.
+ //Version List end point always point to the newest.
vector<shared_ptr<Version>> vList;
//protect Version list. TODO: use free-locked list for better concurrency
Latch rwLatch;
@@ -81,15 +81,14 @@ public:
void version_merge(VDataArray &addarray, VDataArray &delarray, VDataSet &AddSet, VDataSet &DelSet);
//get exclusive lock before update
- int getExclusiveLatch(shared_ptr<Transaction> txn, bool has_read);
- bool releaseExlusiveLatch(shared_ptr<Transaction> txn, bool has_read); //different from unlock
- bool invalidExlusiveLatch(shared_ptr<Transaction> txn, bool has_read); //undo
+ int GetExclusiveLatch(shared_ptr<Transaction> txn, bool has_read);
+ bool InvalidExlusiveLatch(shared_ptr<Transaction> txn, bool has_read);
- bool unLatch(shared_ptr<Transaction> txn, LatchType latch_type); //commit
+ bool UnLatch(shared_ptr<Transaction> txn, LatchType latch_type); //commit
- bool readVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn, bool &latched, bool repeated_read = false ); //read
- int writeVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn);
+ bool ReadVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn, bool &latched, bool first_read = false ); //read
+ int WriteVersion(VDataSet &AddSet, VDataSet &DelSet, shared_ptr<Transaction> txn);
- void cleanAllVersion();
+ void CleanAllVersion();
~IVEntry();
};

MODIFY
Util/Transaction.h
Util/Transaction.h
@@ -27,8 +27,8 @@ private:
TransactionState state;
TYPE_TS timestamp;
- long int start_time;
- long int end_time;
+ unsigned long start_time;
+ unsigned long end_time;
//latch table
vector<IDSet> ReadSet; //shared latches
@@ -39,10 +39,11 @@ private:
vector<string> sparqls;
IsolationLevelType isolation;
+
int wait_lock_time;
int retry_times;
public:
- unsigned long long int update_num;
+ int update_num;
enum class IDType{SUBJECT, PREDICATE, OBJECT};
Transaction(Transaction const&) = delete;
Transaction(string name, TYPE_TS time, txn_id_t TID, IsolationLevelType _isolation = IsolationLevelType::SERIALIZABLE);
@@ -74,11 +75,6 @@ public:
void WriteSetDelete(IDTriple _Triple);
bool WriteSetFind(TYPE_ENTITY_LITERAL_ID _ID, Transaction::IDType _type);
- void AddSetInsert(IDTriple _Triple);
- void AddSetDelete(IDTriple _Triple);
- void DelSetInsert(IDTriple _Triple);
- void DelSetDelete(IDTriple _Triple);
-
//void DependedTXNSetInsert(TYPE_TXN_ID _TID);
//void DependedTXNSetDelete(TYPE_TXN_ID _TID);
@@ -92,6 +88,7 @@ public:
int get_wait_lock_time() { return this->wait_lock_time;}
int get_retry_times() { return this->retry_times; }
+ //DEBUG Function
void print_ReadSet();
void print_WriteSet();
void print_AddSet();

DELETE
api/socket/cpp/example/example
api/socket/cpp/example/example
Binary files a/api/socket/cpp/example/example and /dev/null differ

MODIFY
scripts/run_transaction
scripts/run_transaction
Binary files a/scripts/run_transaction and b/scripts/run_transaction differ

MODIFY
scripts/transaction_test
scripts/transaction_test
Binary files a/scripts/transaction_test and b/scripts/transaction_test differ

MODIFY
scripts/workload
scripts/workload
Binary files a/scripts/workload and b/scripts/workload differ

remove out-of-date function and amend the function naming