Skip to content

Commit

Permalink
Rename "archive" into "persist"
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sparus committed May 22, 2024
1 parent eca43c1 commit 10a735d
Show file tree
Hide file tree
Showing 49 changed files with 582 additions and 582 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ option(ENABLE_GUILE "enable building guile module" off)
option(ENABLE_BOOST_COROUTINE "run benchmarks with boost coroutine" off)

option(immer_BUILD_TESTS "Build tests" ON)
option(immer_BUILD_ARCHIVE_TESTS "Build experimental archive tests" off)
option(immer_BUILD_PERSIST_TESTS "Build experimental persist tests" off)
option(immer_BUILD_EXAMPLES "Build examples" ON)
option(immer_BUILD_DOCS "Build docs" ON)
option(immer_BUILD_EXTRAS "Build extras" ON)
Expand Down
6 changes: 3 additions & 3 deletions extra/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ endif()

file(GLOB_RECURSE immer_fuzzers "*.cpp")
foreach(TMP_PATH ${immer_fuzzers})
string(FIND ${TMP_PATH} archive EXCLUDE_DIR_FOUND)
string(FIND ${TMP_PATH} persist EXCLUDE_DIR_FOUND)
if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM immer_fuzzers ${TMP_PATH})
endif()
Expand All @@ -36,6 +36,6 @@ foreach(_file IN LISTS immer_fuzzers)
endif()
endforeach()

if(immer_BUILD_ARCHIVE_TESTS)
add_subdirectory(archive)
if(immer_BUILD_PERSIST_TESTS)
add_subdirectory(persist)
endif()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <immer/flex_vector.hpp>

#include <fmt/ranges.h>
#include <immer/extra/archive/rbts/load.hpp>
#include <immer/extra/archive/rbts/save.hpp>
#include <immer/extra/persist/rbts/load.hpp>
#include <immer/extra/persist/rbts/save.hpp>

#include <array>

Expand All @@ -38,13 +38,13 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data,
using size_t = std::uint8_t;

const auto check_save_and_load = [&](const auto& vec) {
auto ar = immer::archive::rbts::make_save_archive_for(vec);
auto vector_id = immer::archive::container_id{};
auto ar = immer::persist::rbts::make_save_archive_for(vec);
auto vector_id = immer::persist::container_id{};
std::tie(ar, vector_id) =
immer::archive::rbts::save_to_archive(vec, ar);
immer::persist::rbts::save_to_archive(vec, ar);

auto loader =
immer::archive::rbts::make_loader_for(vec, to_load_archive(ar));
immer::persist::rbts::make_loader_for(vec, to_load_archive(ar));
auto loaded = loader.load(vector_id);
require_eq(vec, loaded);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <fuzzer/fuzzer_input.hpp>

#include <immer/extra/archive/champ/champ.hpp>
#include <immer/extra/persist/champ/champ.hpp>

#include <array>
#include <bitset>
Expand Down Expand Up @@ -77,20 +77,20 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data,
case op_check: {
const auto bitset = std::bitset<var_count>(read<size_t>(in));
auto ids =
std::vector<std::pair<std::size_t, immer::archive::node_id>>{};
std::vector<std::pair<std::size_t, immer::persist::node_id>>{};
auto archive =
immer::archive::champ::container_archive_save<set_t>{};
immer::persist::champ::container_archive_save<set_t>{};
for (auto index = std::size_t{}; index < var_count; ++index) {
if (bitset[index]) {
auto set_id = immer::archive::node_id{};
auto set_id = immer::persist::node_id{};
std::tie(archive, set_id) =
immer::archive::champ::save_to_archive(vars[index],
immer::persist::champ::save_to_archive(vars[index],
archive);
ids.emplace_back(index, set_id);
}
}

auto loader = immer::archive::champ::container_loader<set_t>{
auto loader = immer::persist::champ::container_loader<set_t>{
to_load_archive(archive)};

for (const auto& [index, set_id] : ids) {
Expand Down
12 changes: 6 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

arximboldi-cereal = pkgs.callPackage ./nix/cereal.nix {inherit arximboldi-cereal-src;};

archive-inputs = with pkgs; [
persist-inputs = with pkgs; [
spdlog
arximboldi-cereal
xxHash
Expand Down Expand Up @@ -79,8 +79,8 @@
checkPhase = ''
ctest -D ExperimentalMemCheck
valgrind --quiet --error-exitcode=99 --leak-check=full --errors-for-leak-kinds=all \
--suppressions=./test/extra/archive/valgrind.supp \
./test/extra/archive/archive-tests
--suppressions=./test/extra/persist/valgrind.supp \
./test/extra/persist/persist-tests
'';
});
};
Expand All @@ -103,7 +103,7 @@
fzf
starship
]
++ archive-inputs;
++ persist-inputs;

shellHook =
self.checks.${system}.pre-commit-check.shellHook
Expand Down Expand Up @@ -147,7 +147,7 @@

unit-tests = (withLLVM self.packages.${system}.immer).overrideAttrs (prev: {
name = "immer-unit-tests";
buildInputs = with pkgs; [catch2_3 boehmgc boost fmt] ++ archive-inputs;
buildInputs = with pkgs; [catch2_3 boehmgc boost fmt] ++ persist-inputs;
nativeBuildInputs = with pkgs; [cmake ninja];
dontBuild = false;
doCheck = true;
Expand All @@ -159,7 +159,7 @@
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Debug"
"-Dimmer_BUILD_TESTS=ON"
"-Dimmer_BUILD_ARCHIVE_TESTS=ON"
"-Dimmer_BUILD_PERSIST_TESTS=ON"
"-Dimmer_BUILD_EXAMPLES=OFF"
"-DCXX_STANDARD=20"
];
Expand Down
12 changes: 6 additions & 6 deletions immer/extra/archive/alias.hpp → immer/extra/persist/alias.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <fmt/format.h>

namespace immer::archive {
namespace immer::persist {

template <class T, class Tag>
struct type_alias
Expand Down Expand Up @@ -41,26 +41,26 @@ struct type_alias
}
};

} // namespace immer::archive
} // namespace immer::persist

/**
* Have to use this for fmt v9.
*/
template <class T, class Tag>
struct fmt::formatter<immer::archive::type_alias<T, Tag>> : formatter<T>
struct fmt::formatter<immer::persist::type_alias<T, Tag>> : formatter<T>
{
template <typename FormatContext>
auto format(const immer::archive::type_alias<T, Tag>& value,
auto format(const immer::persist::type_alias<T, Tag>& value,
FormatContext& ctx) const
{
return formatter<T>::format(value.value, ctx);
}
};

template <class T, class Tag>
struct std::hash<immer::archive::type_alias<T, Tag>>
struct std::hash<immer::persist::type_alias<T, Tag>>
{
auto operator()(const immer::archive::type_alias<T, Tag>& x) const
auto operator()(const immer::persist::type_alias<T, Tag>& x) const
{
return hash<T>{}(x.value);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <immer/extra/archive/common/archive.hpp>
#include <immer/extra/archive/errors.hpp>
#include <immer/extra/archive/traits.hpp>
#include <immer/extra/persist/common/archive.hpp>
#include <immer/extra/persist/errors.hpp>
#include <immer/extra/persist/traits.hpp>

#include <immer/box.hpp>
#include <immer/map.hpp>
Expand All @@ -12,7 +12,7 @@

#include <boost/hana/functional/id.hpp>

namespace immer::archive::box {
namespace immer::persist::box {

template <typename T, typename MemoryPolicy>
struct archive_save
Expand Down Expand Up @@ -182,9 +182,9 @@ auto transform_archive(const archive_load<T, MemoryPolicy>& ar, F&& func)
};
}

} // namespace immer::archive::box
} // namespace immer::persist::box

namespace immer::archive {
namespace immer::persist {

template <typename T, typename MemoryPolicy>
struct container_traits<immer::box<T, MemoryPolicy>>
Expand All @@ -196,7 +196,7 @@ struct container_traits<immer::box<T, MemoryPolicy>>
typename TransformF = boost::hana::id_t>
using loader_t = box::loader<T, MemoryPolicy, Archive, TransformF>;

using container_id = immer::archive::container_id;
using container_id = immer::persist::container_id;

template <class F>
static auto transform(F&& func)
Expand All @@ -206,4 +206,4 @@ struct container_traits<immer::box<T, MemoryPolicy>>
}
};

} // namespace immer::archive
} // namespace immer::persist
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#pragma once

#include <immer/extra/archive/common/archive.hpp>
#include <immer/extra/persist/common/archive.hpp>

#include <immer/map.hpp>
#include <immer/set.hpp>
#include <immer/table.hpp>
#include <immer/vector.hpp>

#include <cereal/cereal.hpp>
#include <immer/extra/archive/cereal/immer_vector.hpp>
#include <immer/extra/persist/cereal/immer_vector.hpp>

#include <boost/endian/conversion.hpp>

namespace immer::archive::champ {
namespace immer::persist::champ {

template <class T, immer::detail::hamts::bits_t B>
struct inner_node_save
Expand Down Expand Up @@ -211,4 +211,4 @@ to_load_archive(const container_archive_save<Container>& archive)
};
}

} // namespace immer::archive::champ
} // namespace immer::persist::champ
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <optional>

namespace immer::archive {
namespace immer::persist {
namespace champ {

template <class Node>
Expand Down Expand Up @@ -186,4 +186,4 @@ save_to_archive(Container container, container_archive_save<Container> archive)
}

} // namespace champ
} // namespace immer::archive
} // namespace immer::persist
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <immer/extra/archive/champ/archive.hpp>
#include <immer/extra/archive/errors.hpp>
#include <immer/extra/archive/node_ptr.hpp>
#include <immer/extra/persist/champ/archive.hpp>
#include <immer/extra/persist/errors.hpp>
#include <immer/extra/persist/node_ptr.hpp>

#include <immer/flex_vector.hpp>

Expand All @@ -11,7 +11,7 @@

#include <spdlog/spdlog.h>

namespace immer::archive {
namespace immer::persist {
namespace champ {

class children_count_corrupted_exception : public archive_exception
Expand Down Expand Up @@ -65,7 +65,7 @@ class nodes_loader
using champ_t =
immer::detail::hamts::champ<T, Hash, Equal, MemoryPolicy, B>;
using node_t = typename champ_t::node_t;
using node_ptr = immer::archive::node_ptr<node_t>;
using node_ptr = immer::persist::node_ptr<node_t>;

using values_t = immer::flex_vector<immer::array<T>>;

Expand Down Expand Up @@ -251,4 +251,4 @@ class nodes_loader
};

} // namespace champ
} // namespace immer::archive
} // namespace immer::persist
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include <immer/extra/archive/champ/archive.hpp>
#include <immer/extra/persist/champ/archive.hpp>

#include <spdlog/spdlog.h>

namespace immer::archive {
namespace immer::persist {
namespace champ {

template <class T, immer::detail::hamts::bits_t B>
Expand Down Expand Up @@ -70,7 +70,7 @@ struct nodes_archive_builder

node_id get_node_id(auto* ptr)
{
auto [ar2, id] = immer::archive::champ::get_node_id(std::move(ar), ptr);
auto [ar2, id] = immer::persist::champ::get_node_id(std::move(ar), ptr);
ar = std::move(ar2);
return id;
}
Expand Down Expand Up @@ -98,4 +98,4 @@ auto save_nodes(
}

} // namespace champ
} // namespace immer::archive
} // namespace immer::persist
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include <immer/extra/archive/champ/archive.hpp>
#include <immer/extra/archive/champ/champ.hpp>
#include <immer/extra/archive/traits.hpp>
#include <immer/extra/persist/champ/archive.hpp>
#include <immer/extra/persist/champ/champ.hpp>
#include <immer/extra/persist/traits.hpp>

#include <boost/hana/functional/id.hpp>

namespace immer::archive {
namespace immer::persist {

/**
* A bit of a hack but currently this is the simplest way to request a type of
Expand All @@ -21,15 +21,15 @@ template <class Container>
struct champ_traits
{
using save_archive_t =
immer::archive::champ::container_archive_save<Container>;
immer::persist::champ::container_archive_save<Container>;
using load_archive_t =
immer::archive::champ::container_archive_load<Container>;
using container_id = immer::archive::node_id;
immer::persist::champ::container_archive_load<Container>;
using container_id = immer::persist::node_id;

template <typename Archive = load_archive_t,
typename TransformF = boost::hana::id_t>
using loader_t =
immer::archive::champ::container_loader<Container, Archive, TransformF>;
immer::persist::champ::container_loader<Container, Archive, TransformF>;

template <class F>
static auto transform(F&& func)
Expand Down Expand Up @@ -106,10 +106,10 @@ struct container_traits<champ::incompatible_hash_wrapper<Container>>
template <typename Archive = typename base_t::load_archive_t,
typename TransformF = boost::hana::id_t>
using loader_t =
immer::archive::champ::container_loader<Container,
immer::persist::champ::container_loader<Container,
Archive,
TransformF,
enable_incompatible_hash_mode>;
};

} // namespace immer::archive
} // namespace immer::persist
Loading

0 comments on commit 10a735d

Please sign in to comment.