diff --git a/cypher/parser.cpp b/cypher/parser.cpp index 80137c7b8..cfdbb5d50 100644 --- a/cypher/parser.cpp +++ b/cypher/parser.cpp @@ -8,9 +8,6 @@ #include "cypher/common.hpp" #include "utils/terminate_handler.hpp" -// dumping ground for all kind of visitors -#include "query_engine/traverser/create_traverser.hpp" - using std::cout; using std::endl; @@ -33,10 +30,8 @@ int main(int argc, char *argv[]) // traversers auto traverser = get_argument(arguments, "-t", "code"); auto print_traverser = Traverser::sptr(new PrintVisitor(cout)); - auto create_traverser = Traverser::sptr(new CreateTraverser()); std::map<std::string, Traverser::sptr> traversers = { - {"print", print_traverser}, - {"create", create_traverser} + {"print", print_traverser} }; cypher::Compiler compiler; diff --git a/data_structures/bitset/dynamic_bitset.hpp b/data_structures/bitset/dynamic_bitset.hpp index 50ddaf391..c228e9571 100644 --- a/data_structures/bitset/dynamic_bitset.hpp +++ b/data_structures/bitset/dynamic_bitset.hpp @@ -17,7 +17,7 @@ class DynamicBitset : Lockable<SpinLock> Block(Block&&) = delete; static constexpr size_t size = sizeof(block_t) * 8; - + constexpr block_t bitmask(size_t group_size) const { return (block_t)(-1) >> (size - group_size); @@ -32,7 +32,7 @@ class DynamicBitset : Lockable<SpinLock> void set(size_t k, size_t n, std::memory_order order) { assert(k + n - 1 < size); - block.fetch_or(bitmask(n) << k, order); + block.fetch_or(bitmask(n) << k, order); } void clear(size_t k, size_t n, std::memory_order order) @@ -40,7 +40,7 @@ class DynamicBitset : Lockable<SpinLock> assert(k + n - 1 < size); block.fetch_and(~(bitmask(n) << k), order); } - + std::atomic<block_t> block {0}; }; @@ -136,7 +136,7 @@ private: // lock to prevent others that also want to create a new chunk // from creating it auto guard = acquire_unique(); - + // double-check locking. if the chunk exists now, some other thread // has just created it, continue searching for my chunk if(chunk->next.load() != nullptr) diff --git a/mvcc/record.hpp b/mvcc/record.hpp index 3f63bd9d6..2db8e3d10 100644 --- a/mvcc/record.hpp +++ b/mvcc/record.hpp @@ -1,9 +1,12 @@ #pragma once #include <atomic> +#include <iostream> #include "transactions/transaction.hpp" #include "transactions/commit_log.hpp" +#include "transactions/engine.hpp" + #include "mvcc/id.hpp" #include "cre_exp.hpp" #include "version.hpp" @@ -110,8 +113,7 @@ public: return false; // - you are the first one to check since it ended, consult commit log - auto& clog = tx::CommitLog::get(); - auto info = clog.fetch_info(id); + auto info = t.engine.clog.fetch_info(id); if(info.is_committed()) return hints.set_committed(), true; diff --git a/transactions/commit_log.hpp b/transactions/commit_log.hpp index 4133cfad4..be11524df 100644 --- a/transactions/commit_log.hpp +++ b/transactions/commit_log.hpp @@ -47,12 +47,6 @@ public: CommitLog operator=(CommitLog) = delete; - static CommitLog& get() - { - static CommitLog log; - return log; - } - Info fetch_info(const Id& id) { return Info { log.at(2 * id, 2) }; diff --git a/transactions/engine.hpp b/transactions/engine.hpp index 478124905..cf9174130 100644 --- a/transactions/engine.hpp +++ b/transactions/engine.hpp @@ -8,7 +8,6 @@ #include "commit_log.hpp" #include "utils/counters/simple_counter.hpp" - #include "threading/sync/spinlock.hpp" #include "threading/sync/lockable.hpp" @@ -59,7 +58,7 @@ public: void commit(const Transaction& t) { auto guard = this->acquire_unique(); - CommitLog::get().set_committed(t.id); + clog.set_committed(t.id); finalize(t); } @@ -67,7 +66,7 @@ public: void abort(const Transaction& t) { auto guard = this->acquire_unique(); - CommitLog::get().set_aborted(t.id); + clog.set_aborted(t.id); finalize(t); } @@ -92,6 +91,8 @@ public: return active.size(); } + CommitLog clog; + private: void finalize(const Transaction& t) { diff --git a/transactions/transaction.hpp b/transactions/transaction.hpp index a8e44f44c..dde533062 100644 --- a/transactions/transaction.hpp +++ b/transactions/transaction.hpp @@ -44,8 +44,9 @@ public: void commit(); void abort(); -private: Engine& engine; + +private: LockStore<RecordLock> locks; };