summaryrefslogtreecommitdiff
path: root/src/database/include/records.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-10-13 15:05:49 +1100
committerjacqueline <me@jacqueline.id.au>2023-10-13 15:05:49 +1100
commitafbf3c31f4d1a605c264f719531f4183ee5a3022 (patch)
tree43c75029ff6dfe3e44137f6b3d0de3498f247bf2 /src/database/include/records.hpp
parent20d1c280a77eadcea18438453dc37daaf1d85e2d (diff)
downloadtangara-fw-afbf3c31f4d1a605c264f719531f4183ee5a3022.tar.gz
Use libcppbor for much much nicer db encoding
Diffstat (limited to 'src/database/include/records.hpp')
-rw-r--r--src/database/include/records.hpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/database/include/records.hpp b/src/database/include/records.hpp
index e7d7738c..e13c6568 100644
--- a/src/database/include/records.hpp
+++ b/src/database/include/records.hpp
@@ -22,32 +22,19 @@
namespace database {
/*
- * Helper class for creating leveldb Slices bundled with the data they point to.
- * Slices are otherwise non-owning, which can make handling them post-creation
- * difficult.
- */
-class OwningSlice {
- public:
- std::pmr::string data;
- leveldb::Slice slice;
-
- explicit OwningSlice(std::pmr::string d);
-};
-
-/*
* Returns the prefix added to every TrackData key. This can be used to iterate
* over every data record in the database.
*/
-auto EncodeDataPrefix() -> OwningSlice;
+auto EncodeDataPrefix() -> std::string;
/* Encodes a data key for a track with the specified id. */
-auto EncodeDataKey(const TrackId& id) -> OwningSlice;
+auto EncodeDataKey(const TrackId& id) -> std::string;
/*
* Encodes a TrackData instance into bytes, in preparation for storing it within
* the database. This encoding is consistent, and will remain stable over time.
*/
-auto EncodeDataValue(const TrackData& track) -> OwningSlice;
+auto EncodeDataValue(const TrackData& track) -> std::string;
/*
* Parses bytes previously encoded via EncodeDataValue back into a TrackData.
@@ -56,14 +43,14 @@ auto EncodeDataValue(const TrackData& track) -> OwningSlice;
auto ParseDataValue(const leveldb::Slice& slice) -> std::shared_ptr<TrackData>;
/* Encodes a hash key for the specified hash. */
-auto EncodeHashKey(const uint64_t& hash) -> OwningSlice;
+auto EncodeHashKey(const uint64_t& hash) -> std::string;
/*
* Encodes a hash value (at this point just a track id) into bytes, in
* preparation for storing within the database. This encoding is consistent, and
* will remain stable over time.
*/
-auto EncodeHashValue(TrackId id) -> OwningSlice;
+auto EncodeHashValue(TrackId id) -> std::string;
/*
* Parses bytes previously encoded via EncodeHashValue back into a track id. May
@@ -72,17 +59,17 @@ auto EncodeHashValue(TrackId id) -> OwningSlice;
auto ParseHashValue(const leveldb::Slice&) -> std::optional<TrackId>;
/* Encodes a prefix that matches all index keys, of all ids and depths. */
-auto EncodeAllIndexesPrefix() -> OwningSlice;
+auto EncodeAllIndexesPrefix() -> std::string;
/*
*/
-auto EncodeIndexPrefix(const IndexKey::Header&) -> OwningSlice;
+auto EncodeIndexPrefix(const IndexKey::Header&) -> std::string;
-auto EncodeIndexKey(const IndexKey&) -> OwningSlice;
+auto EncodeIndexKey(const IndexKey&) -> std::string;
auto ParseIndexKey(const leveldb::Slice&) -> std::optional<IndexKey>;
/* Encodes a TrackId as bytes. */
-auto TrackIdToBytes(TrackId id) -> OwningSlice;
+auto TrackIdToBytes(TrackId id) -> std::string;
/*
* Converts a track id encoded via TrackIdToBytes back into a TrackId. May