Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/arcticdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ set(arcticdb_srcs
entity/ref_key.hpp
entity/serialized_key.hpp
entity/stage_result.hpp
entity/stage_result.cpp
entity/type_conversion.hpp
entity/types.hpp
entity/type_utils.hpp
Expand Down
6 changes: 6 additions & 0 deletions cpp/arcticdb/entity/atom_key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class AtomKeyImpl {
return {str_};
}

std::string view_human() const;

private:
StreamId id_;
VersionId version_id_ = 0;
Expand Down Expand Up @@ -328,4 +330,8 @@ struct hash<arcticdb::entity::AtomKeyImpl> {
namespace arcticdb::entity {
// This needs to be defined AFTER the formatter for AtomKeyImpl
inline void AtomKeyImpl::set_string() const { str_ = fmt::format("{}", *this); }

inline std::string AtomKeyImpl::view_human() const {
return fmt::format("{}", formattable<AtomKeyImpl, DisplayAtomKeyFormat>(*this));
}
} // namespace arcticdb::entity
5 changes: 5 additions & 0 deletions cpp/arcticdb/entity/key.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ struct DefaultAtomKeyFormat {
static constexpr char format[] = "{}:{}:{:d}:0x{:x}@{:d}[{},{}]";
};

struct DisplayAtomKeyFormat {
static constexpr char format[] = "Key(type={}, id='{}', version_id={:d}, content_hash=0x{:x}, creation_ts={:d}, "
"start_index={}, end_index={})";
};

template<class T, class FormattingTag = DefaultAtomKeyFormat>
struct FormattableRef {
const T& ref;
Expand Down
5 changes: 5 additions & 0 deletions cpp/arcticdb/entity/stage_result.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <arcticdb/entity/stage_result.hpp>

namespace arcticdb {
std::string StageResult::view() const { return fmt::format("{}", *this); }
} // namespace arcticdb
24 changes: 23 additions & 1 deletion cpp/arcticdb/entity/stage_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,33 @@

#include <arcticdb/entity/atom_key.hpp>
#include <vector>
#include <ranges>
#include <fmt/format.h>
#include <fmt/ranges.h>

namespace arcticdb {
struct StageResult {
explicit StageResult(std::vector<entity::AtomKey> staged_segments) : staged_segments(std::move(staged_segments)) {}

std::vector<entity::AtomKey> staged_segments;

std::string view() const;
};
} // namespace arcticdb

namespace fmt {
template<>
struct formatter<arcticdb::StageResult> {
template<typename ParseContext>
constexpr auto parse(ParseContext& ctx) {
return ctx.begin();
}

template<typename FormatContext>
auto format(const arcticdb::StageResult& stage_result, FormatContext& ctx) const {
auto transform_view =
stage_result.staged_segments | std::views::transform([](const auto& key) { return key.view_human(); });
return fmt::format_to(ctx.out(), "StageResult(staged_segments=[{}])", fmt::join(transform_view, ", "));
}
};
} // namespace arcticdb
} // namespace fmt
14 changes: 12 additions & 2 deletions cpp/arcticdb/version/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void register_bindings(py::module& version, py::exception<arcticdb::ArcticExcept
.def_property_readonly("type", [](const AtomKey& self) { return self.type(); })
.def(pybind11::self == pybind11::self)
.def(pybind11::self != pybind11::self)
.def("__repr__", &AtomKey::view)
.def("__repr__", &AtomKey::view_human)
.def(py::self < py::self)
.def(py::pickle(
[](const AtomKey& key) {
Expand Down Expand Up @@ -375,9 +375,19 @@ void register_bindings(py::module& version, py::exception<arcticdb::ArcticExcept
.def_property_readonly("creation_ts", &DescriptorItem::creation_ts)
.def_property_readonly("timeseries_descriptor", &DescriptorItem::timeseries_descriptor);

py::class_<StageResult>(version, "StageResult")
py::class_<StageResult>(version, "StageResult", R"pbdoc(
Result returned by the stage method containing information about staged segments.

StageResult objects can be passed to finalization methods to specify which staged data to finalize.
This enables selective finalization of staged data when multiple stage operations have been performed.

Attributes
----------
staged_segments : List[AtomKey]
)pbdoc")
.def(py::init([]() { return StageResult({}); }))
.def_property_readonly("staged_segments", [](const StageResult& self) { return self.staged_segments; })
.def("__repr__", &StageResult::view)
.def(py::pickle(
[](const StageResult& s) {
constexpr int serialization_version = 0;
Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs/docs/api/library_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@

::: arcticdb.WriteMetadataPayload

::: arcticdb_ext.version_store.StageResult
Loading