diff --git a/src/storage/v3/key_store.hpp b/src/storage/v3/key_store.hpp index 1762273fb..4bc3c25e3 100644 --- a/src/storage/v3/key_store.hpp +++ b/src/storage/v3/key_store.hpp @@ -26,12 +26,11 @@ using PrimaryKey = std::vector; class KeyStore { public: - KeyStore() = default; explicit KeyStore(const PrimaryKey &key_values); - KeyStore(const KeyStore &) = default; + KeyStore(const KeyStore &) = delete; KeyStore(KeyStore &&other) noexcept = default; - KeyStore &operator=(const KeyStore &) = default; + KeyStore &operator=(const KeyStore &) = delete; KeyStore &operator=(KeyStore &&other) noexcept = default; ~KeyStore() = default; diff --git a/src/storage/v3/property_store.cpp b/src/storage/v3/property_store.cpp index bf8460003..fc7bd6984 100644 --- a/src/storage/v3/property_store.cpp +++ b/src/storage/v3/property_store.cpp @@ -928,16 +928,6 @@ void SetSizeData(uint8_t *buffer, uint64_t size, uint8_t *data) { PropertyStore::PropertyStore() { memset(buffer_, 0, sizeof(buffer_)); } -PropertyStore::PropertyStore(const PropertyStore &other) { memcpy(buffer_, other.buffer_, sizeof(buffer_)); } - -PropertyStore &PropertyStore::operator=(const PropertyStore &other) { - if (this == &other) { - return *this; - } - memcpy(buffer_, other.buffer_, sizeof(buffer_)); - return *this; -} - PropertyStore::PropertyStore(PropertyStore &&other) noexcept { memcpy(buffer_, other.buffer_, sizeof(buffer_)); memset(other.buffer_, 0, sizeof(other.buffer_)); diff --git a/src/storage/v3/property_store.hpp b/src/storage/v3/property_store.hpp index 00dc4d40f..477795203 100644 --- a/src/storage/v3/property_store.hpp +++ b/src/storage/v3/property_store.hpp @@ -25,9 +25,9 @@ class PropertyStore { public: PropertyStore(); - PropertyStore(const PropertyStore &); + PropertyStore(const PropertyStore &) = delete; PropertyStore(PropertyStore &&other) noexcept; - PropertyStore &operator=(const PropertyStore &); + PropertyStore &operator=(const PropertyStore &) = delete; PropertyStore &operator=(PropertyStore &&other) noexcept; ~PropertyStore(); diff --git a/src/storage/v3/vertex.hpp b/src/storage/v3/vertex.hpp index cbfac4ee8..2ed4c6e4c 100644 --- a/src/storage/v3/vertex.hpp +++ b/src/storage/v3/vertex.hpp @@ -31,8 +31,6 @@ namespace memgraph::storage::v3 { struct Vertex { using EdgeLink = std::tuple; - Vertex() = default; - Vertex(Delta *delta, const std::vector &primary_properties) : keys{primary_properties}, delta{delta} { MG_ASSERT(delta == nullptr || delta->action == Delta::Action::DELETE_OBJECT, "Vertex must be created with an initial DELETE_OBJECT delta!"); diff --git a/tests/benchmark/data_structures_random.cpp b/tests/benchmark/data_structures_random.cpp deleted file mode 100644 index f130d6faf..000000000 --- a/tests/benchmark/data_structures_random.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2022 Memgraph Ltd. -// -// Use of this software is governed by the Business Source License -// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source -// License, and you may not use this file except in compliance with the Business Source License. -// -// As of the Change Date specified in that file, in accordance with -// the Business Source License, use of this software will be governed -// by the Apache License, Version 2.0, included in the file -// licenses/APL.txt. - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "btree_map.hpp" -#include "skip_list_common.hpp" -#include "utils/skip_list.hpp" - -DEFINE_int32(max_element, 20000, "Maximum element in the intial list"); -DEFINE_int32(max_range, 2000000, "Maximum range used for the test"); -DEFINE_string(ds, "skip_list", "Which DS to test"); - -template -concept BasicIndexStructure = requires(ContainerType a, const ContainerType b) { - { a.contains() } -> std::same_as; - { a.find() } -> std::same_as; - { a.insert() } -> std::same_as>; - { a.remove() } -> std::same_as; -}; - -template -class BppStructure final { - using value_type = typename tlx::btree_map::value_type; - using iterator = typename tlx::btree_map::iterator; - - public: - bool contains(const T key) const { return data.exists(key); } - - auto find(const T key) const { return data.find(key); } - - std::pair insert(T val) { return data.insert({val, val}); } - - bool remove(const T key) { return data.erase(key); } - - size_t size() const { return data.size(); }; - - iterator end() { return data.end(); } - - private: - tlx::btree_map data; -}; - -template -class MapStructure final { - using value_type = typename std::map::value_type; - using iterator = typename std::map::iterator; - - public: - bool contains(const T key) const { return data.contains(key); } - - auto find(const T key) const { return data.find(key); } - - std::pair insert(T val) { return data.insert({val, val}); } - - bool remove(const T key) { return data.erase(key); } - - size_t size() const { return data.size(); }; - - iterator end() { return data.end(); } - - private: - std::map data; -}; - -template -void RunDSTest(DataStructure &ds) { - RunTest([&ds](const std::atomic &run, auto &stats) { - std::mt19937 generator(std::random_device{}()); - std::uniform_int_distribution distribution(0, 3); - std::mt19937 i_generator(std::random_device{}()); - std::uniform_int_distribution i_distribution(0, FLAGS_max_range); - - while (run.load(std::memory_order_relaxed)) { - auto value = distribution(generator); - - auto item = i_distribution(i_generator); - switch (value) { - case 0: - stats.succ[OP_INSERT] += static_cast(ds.insert(item).second); - break; - case 1: - stats.succ[OP_CONTAINS] += static_cast(ds.contains(item)); - break; - case 2: - stats.succ[OP_REMOVE] += static_cast(ds.remove(item)); - break; - case 3: - stats.succ[OP_FIND] += static_cast(ds.find(item) != ds.end()); - break; - default: - std::terminate(); - } - ++stats.total; - } - }); -} - -template -void GenerateData(Accessor &acc) { - for (uint64_t i = 0; i <= FLAGS_max_element; ++i) { - MG_ASSERT(acc.insert(i).second); - } -} - -template -void AsserData(Accessor &acc) { - if constexpr (std::is_same_v>) { - uint64_t val = 0; - for (auto item : acc) { - MG_ASSERT(item == val); - ++val; - } - MG_ASSERT(val == FLAGS_max_element + 1); - } else { - MG_ASSERT(acc.size() == FLAGS_max_element + 1); - } -} - -int main(int argc, char **argv) { - gflags::ParseCommandLineFlags(&argc, &argv, true); - - if (FLAGS_ds == "skip_list") { - std::cout << "#### Testing skip list" << std::endl; - memgraph::utils::SkipList list; - auto acc = list.access(); - - GenerateData(acc); - AsserData(acc); - - RunDSTest(acc); - } else if (FLAGS_ds == "map") { - std::cout << "#### Testing map" << std::endl; - MapStructure map; - - GenerateData(map); - AsserData(map); - - RunDSTest(map); - } else if (FLAGS_ds == "bpp") { - std::cout << "#### Testing B+ tree" << std::endl; - BppStructure bpp; - - GenerateData(bpp); - AsserData(bpp); - - RunDSTest(bpp); - } else { - throw std::runtime_error("Select an existing data structure!"); - } - - return 0; -} diff --git a/tools/plot/benchmark_datastructures.sh b/tools/plot/benchmark_datastructures.sh index 2c9885ad4..2ab15be31 100755 --- a/tools/plot/benchmark_datastructures.sh +++ b/tools/plot/benchmark_datastructures.sh @@ -10,7 +10,7 @@ CPUS=$(grep -c processor < /proc/cpuinfo) BENCHMARK_FILES=$(find ${WORKSPACE_DIR}/tests/benchmark -type f -iname "data_structures_*") function test_all() { - for BENCH_FILE in ${BENCHMARK_FILES}; do + for BENCH_FILE in ${BENCHMARK_FILES[@]}; do local BASE_NAME=$(basename $BENCH_FILE) local NAME=${BASE_NAME%%.*} echo "Running $NAME"